Question about Business & Productivity Software

1 Answer

Export data in excel shld yoeet through VB


I want to execute the output of the folowing query

I want ipaddress to be dispalyed in the 3rd column of the excel sheet.

Could you please help me how can i write the code

Posted by on

1 Answer

  • Level 2:

    An expert who has achieved level 2 by getting 100 points


    An expert that gotĀ 5 achievements.


    An expert who has written 50 answers of more than 400 characters.


    An expert whose answer gotĀ voted for 20 times.

  • Expert
  • 167 Answers
Re: Export data in excel shld yoeet through VB

When i first figured out how to pull data from SQL and put the results in an excel file i referenced these two articles....
Reading and writing excel file using VB.NET (
Get the Values From DataBase and Stored into excell Sheet (

This is the code i ended up using.... (check out those links to see how you need to import the ms office excel reference file with visual basic)

Const stcon As String = "Provider=SQLNCLI;server=xxxxx;database=xxxxx;uid=xxxxx;pwd=xxxxx;DataTypeCompatibility=80"
Dim stSQL As String = "select * from scs_rate_class_money where irate_book = 124 and snew_used = 'U' and sclass = '2' and splan = 'T4' and sopt_code = 'F1'"
Dim cnt As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim fld As ADODB.Field
'Open the connection.

'Open the recordset.
With rst
.CursorLocation = ADODB.CursorLocationEnum.adUseClient
.Open(stSQL, cnt, ADODB.CursorTypeEnum.adOpenForwardOnly, _
ADODB.LockTypeEnum.adLockReadOnly , _
.ActiveConnection = Nothing 'Disconnect the Recordset.
End With
'Close the connection
cnt.Close ()
Dim exp As Export = New Export()
Dim xlApp As New Microsoft.Office.Interop.Excel.Application
Dim xlWBook As Microsoft.Office.Interop.Excel.Workbook = xlApp.Workbooks.Add(Microsoft.Office.Interop.Excel.XlWBATemplate.xlWBATWorksheet )
Dim xlWSheet As Microsoft.Office.Interop.Excel.Worksheet = CType(xlWBook.Worksheets(1), Microsoft.Office.Interop.Excel.Worksheet)
Dim xlRange As Microsoft.Office.Interop.Excel.Range = CType(xlWSheet, Microsoft.Office.Interop.Excel.Worksheet).Range("A2")
Dim xlCalc As Microsoft.Office.Interop.Excel.XlCalculation
Dim i As Short

'Turn off Excel's calculation.
With xlApp
xlCalc = .Calculation
.Calculation = Microsoft.Office.Interop.Excel.XlCalculation.xlCalculationManual
End With
'Write the fieldnames.
For Each fld In rst.Fields
xlRange.Offset(0, i).Value = fld.Name
i = i + 1
'Populate the range.
xlRange.Offset(1, 0).CopyFromRecordset(rst)
'Close the recordset.
'Make Excel available to the user.
With xlApp
.Visible = True
.UserControl = True
'Restore the calculation mode.
.Calculation = xlCalc
End With
'Release variables from memory.
fld = Nothing
rst = Nothing
cnt = Nothing
xlRange = Nothing
xlWSheet = Nothing
xlWBook = Nothing
xlApp = Nothing

Posted on Jan 04, 2008

Add Your Answer

0 characters

Uploading: 0%


Complete. Click "Add" to insert your video. Add


3 Points

Related Questions:

1 Answer

I want to save and retrieve some data from html page to excel. how to do this


  1. In a blank Excel sheet (or blank tab), click on the cell where you want the html page to begin placing data.
  2. From the top menu, select [Data] and choose [Get External Data] from the drop-down menu.
  3. Select [New web query] (view other options for future queries)
  4. A pop-up screen will have a few options, of course enter the html page location in the first box (Web address)
  5. You probably want to also select *The entire page (instead of only 'tables' default)
  6. Click [OK] and look at the data in your Excel sheet!
  7. You may want to adjust the options in future data retrievals.
Thanks for choosing FixYa!

Oct 11, 2010 | Microsoft Office Standard for PC

2 Answers

How to automatically import data from tally to excel. Want to display auto imported data in sharepoint.

Import TALLY Data / Export TALLY Data
Tally allows users to Import data from other software's as well as Export data from Tally to other software's. Tally allows users to Import and Export in ASCII, SDF and XML formats. XML is now the most widely used format of exporting data in the world. Any transactions can be exported from Tally and imported in other software after suitably altering the current structures to accept Tally data structure. The reverse is also possible by writing a small TDL program to accept the data from other software's. The data that is to be imported into Tally can be in either XML or DBF format. Easy Tally data transfer or Tally data migration from Tally 4.5 & Tally 5.4 to Tally 6.3 , Tally 7.2 , etc.
Tally is now ODBC compliant. Hence, any program like MS-Excel, Oracle etc that is ODBC compliant can use data from Tally. Here, data connectivity is dynamic i.e. any new updation in Tally is reflected in other ODBC Compliant Software immediately. Now, with ODBC facility the user can extract data out of Tally and design his own report formats in other ODBC compliant software's.
Procedure :
Now, Load Company -> specify period -> minimize Tally -> Open a new Excel file -> select data -> select 'Get External Data' -> select New database query -> choose Data Source
Tally connects to data source and displays Tally Wizard query screen -> select the columns you would want to include in the query.
Once all the columns are selected, the user returns to excel and excel displays all the columns selected
Graphical Analysis of Tally Data
Sometimes, pictures can say better than figures. Tally also provides graphical (Bar graph) analysis of data. The user can do a graphical analysis reports like Sales register, Purchase register, Ledgers, Funds flow, Cash flow, Item registers etc. This helps the user in deeper analysis of data. In Tally, a graphical analysis can also show month wise graphs for the year in comparison with any other period. This will help the management in quickly locating the highs and lean periods in a financial year and hence be better prepared for difficult times.
Web Enabled
Tally ees 6.3 is now Web enabled. This will help the user in reducing his paper work further. Now, report in Tally can be e-mailed directly from Tally. It is not just reports, but even invoices and purchase orders can also be e-mailed directly from Tally. Hence, the user does not have to send printed invoice or purchase orders from Tally.
Procedure :
Select any report (e.g. Balance sheet) -> select Alt+M (E-mail) -> specify all details as required by Tally
Ability to Publish Reports and Documents on the Internet
Now, Tally allows users to upload reports on the web site directly from Tally. So companies that would want to publish reports on the web site can do so directly from Tally. Many companies would also like to publish their price list on their websites along with the product they deal with.
Procedure :
Select any report (Profit and Loss A/C) -> select Upload (Alt + O) -> specify all details as required by Tally.
Direct Internet Access
Tally now offers direct Internet access. A Tally user while working on Tally can directly log on to tally website get details of all the facilities offered by Tally. The user can also download the latest releases of Tally 6.3 as and when available. Tally website also offers a facility of Tally Chat. Any user can now chat with a Tally representative and get any information regarding Tally.
Procedure :
Start Tally -> now, from any screen select Web Browser (Alt+W). Tally now takes you to the Tally Web site.
Print Preview
Any user would ideally like to view format of reports / Invoices / Vouchers before printing the same. Tally now offers a facility of print preview. Now any report can be viewed before printing or before it is mailed. Once Tally shows the preview the user can either opt to print or mail the same.

Apr 15, 2010 | Microsoft Office Excel 2007

1 Answer

Using Microsoft Query to bring Access 2007 data into a spreadsheet

Try using Data > From Other Sources and select From Microsoft Query. In the Excel sheet, select the cell that you want the results to start in. Your MS Query would be pulling the data from your Access database.

May 04, 2009 | Microsoft Excel for PC

2 Answers

Import data to excelsheet insert in mysqltable query

You can save it as csv and use the file to insert using
LOAD DATA LOCAL INFILE '/importfile.csv'
INTO TABLE test_table
(field1, filed2, field3);

Feb 20, 2009 | Microsoft Office Standard 2007: Windows

1 Answer

How to convert Excel data in to Tally a accounting software

Select ASCII. Give output file name Eg:d:/exp Open the file using EXcel.Select Delimite  nexxt comma finish.Export is completed or You can do 2 things , first you could export as text and import it back to excel using the text file you created , secondly you can select HTML and give the file name as eg-XYZ.xls
or Try using UDIMagic Free Edition to Export Tally data. Download it from 

Jan 06, 2009 | Microsoft Excel for PC

1 Answer

How to export table in ms access to excel

yes you can export your access data into excel, follow steps on how to export.

1. open your access database
2. open the table data you to export
3. under table data view click tools menu
4. select analyze
5. select ms excel
6. this will open your seleted access table in excel

hope this will help you..

Dec 13, 2008 | Microsoft Access 2002 for PC

4 Answers

How to Export trial Balance from Tally 9.2 version to Excel sheet

you select the trial balace--and press Alt+E or click export---then the export details screen came,

Language: Default(all language)
Format: Excel (spreadsheet)
Output file name: trial bal.xls (any name you select)

Excel (spreadsheet) formating: yes
other details you select and accept the screen. then minimise or close the Tally, you open the tally file name at my computer. at the time you can see the file trialbal.

Mar 20, 2008 | Business & Productivity Software

1 Answer

Import excel sheet in 5

you have to make link in you vb then you can save the xls files on same format

Oct 08, 2007 | Microsoft Office Standard for PC

4 Answers

Running SQL queries on Excel

Another way to do it is to use the SQL Drill freeware Excel addin (

Aug 14, 2007 | Microsoft Office 2003 Basic Edition...

Not finding what you are looking for?
Business & Productivity Software Logo

Related Topics:

576 people viewed this question

Ask a Question

Usually answered in minutes!

Top Business & Productivity Software Experts

Brian Sullivan
Brian Sullivan

Level 3 Expert

27725 Answers


Level 3 Expert

18259 Answers

Sudeep Chatterjee
Sudeep Chatterjee

Level 3 Expert

3267 Answers

Are you a Business and Productivity Software Expert? Answer questions, earn points and help others

Answer questions

Manuals & User Guides