Question about Computers & Internet

1 Answer

Export data in excel sheet and in specific column

Hi,

I want the following query to be exported in an excel sheet through VB
SELECT IPADDRESS FROM TRANSFER_MANAGER

I want IPADDRESS to be executed in the 3rd column in an excel sheet.

Can any body provide me the code for it.

Thanks in advance
Sneha

Posted by on

Ad

1 Answer

  • Level 2:

    An expert who has achieved level 2 by getting 100 points

    All-Star:

    An expert that got 10 achievements.

    MVP:

    An expert that got 5 achievements.

    Vice President:

    An expert whose answer got voted for 100 times.

  • Expert
  • 233 Answers

I did not write this but look towards the end of the code and it will give you an idea on how to do it

Sub ExportToExcel(strOutputFile As String, Optional boolSuppressMessages As Boolean = False)

Dim strTemplateFile As String
Dim fso As Scripting.FileSystemObject
Dim cnn As ADODB.Connection
Dim rstTarget As ADODB.Recordset
Dim rstCustomers As ADODB.Recordset
Dim rstServiceReps As ADODB.Recordset

On Error GoTo ErrorHandler: On Error GoTo 0

Set fso = New Scripting.FileSystemObject

' Get template file path
strTemplateFile = CurrentProject.path & "\CompaniesEmployeesList.xlt"

' Copy template to the target
fso.CopyFile strTemplateFile, strOutputFile, False

' Open a connection to the workbook
Set cnn = New ADODB.Connection
cnn.Provider = "Microsoft.Jet.OLEDB.4.0"
cnn.ConnectionString = "Data Source=" & strOutputFile & ";" & _
"Extended Properties=""Excel 8.0"""
cnn.Mode = adModeReadWrite
cnn.Open

' Open the target recordset (the Excel sheet)
Set rstTarget = New ADODB.Recordset
rstTarget.Open "SELECT [ID], [Name], [City] " & _
"FROM [Sheet1$]", cnn, adOpenDynamic, adLockOptimistic

' Open Customer data recodset
Set rstCustomers = New ADODB.Recordset
rstCustomers.Open "SELECT CompanyID, CompanyName, City " & _
"FROM Customers " & _
"WHERE City = 'Madrid' " & _
"ORDER BY CompanyName", CurrentProject.Connection

' Open Service Rep data recodset
Set rstServiceReps = New ADODB.Recordset
rstServiceReps.Open "SELECT EmployeeID, [LastName] & "", "" & [FirstName] AS Name, City " & _
"FROM Employees " & _
"WHERE City = 'Madrid' " & _
"ORDER BY [LastName]", CurrentProject.Connection

' Loop through Customers result set and copy to target
Do While Not rstCustomers.EOF
rstTarget.AddNew
rstTarget![ID] = rstCustomers!CompanyID
rstTarget![Name] = rstCustomers!CompanyName
rstTarget![City] = rstCustomers!City
rstCustomers.MoveNext
Loop

' Insert blank line between result sets.
rstTarget.AddNew
rstTarget![ID] = ""
rstTarget![Name] = ""
rstTarget![City] = ""
rstTarget.Update

' Loop through Service Reps result set and copy to target
Do While Not rstServiceReps.EOF
rstTarget.AddNew
rstTarget![ID] = rstServiceReps!EmployeeID
rstTarget![Name] = rstServiceReps!Name
rstTarget![City] = rstServiceReps!City
rstTarget.Update
rstServiceReps.MoveNext
Loop

rstTarget.Close
rstCustomers.Close
rstServiceReps.Close

cnn.Close

If Not boolSuppressMessages Then
MsgBox "Workbook Created", vbInformation + vbOKOnly, "ExcelExport"
End If

ExitHere:
On Error Resume Next
Set rstTarget = Nothing
Set cnn = Nothing
Set rstCustomers = Nothing
Set rstServiceReps = Nothing
Exit Sub

ErrorHandler:
Eval "MsgBox(""Error " & Err.Number & "@" & Err.Description & "@"")"

On Error Resume Next

If Not cnn Is Nothing Then
cnn.Close
End If

Resume ExitHere

End Sub

Posted on Jan 06, 2008

Ad

1 Suggested Answer

6ya6ya
  • 2 Answers

SOURCE: I have freestanding Series 8 dishwasher. Lately during the filling cycle water hammer is occurring. How can this be resolved

Hi there,
Save hours of searching online or wasting money on unnecessary repairs by talking to a 6YA Expert who can help you resolve this issue over the phone in a minute or two.

Best thing about this new service is that you are never placed on hold and get to talk to real repairmen in the US.

Here's a link to this great service

Good luck!

Posted on Jan 02, 2017

Ad

Add Your Answer

Uploading: 0%

my-video-file.mp4

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

×

Loading...
Loading...

Related Questions:

1 Answer

How to export tally 9 to excel sheet


Hi,
Great question and there are two way export date. Please follow step by step instruction.
  1. In the Balance sheet screen click E : Export or press Alt+E.
  2. Select the required language from the list of Languages displayed.
  3. Select a format from the list of Formats displayed.
  4. By default, the exported file will be stored in C:\Program Files\Tally.ERP 9 for Windows 7 and C:\Tally.ERP 9 for Windows XP operating systems
  5. Press Enter to accept the default Output Filename or type the filename of your choice in order to save the file with a different name.
  6. Press Enter to accept the default Output Sheet Name.
  7. To update the existing file select Yes in Update Existing File.
  8. To format the contents of the file select Yes in Excel (Spreadsheet) formatting.
  9. Select Yes for the Field with Colour, to retain the background colour in the exported file.
And Second:
selecting the ASCII (Comma Delimited) format, the user can export all the reports or data from Tally.ERP 9. The data exported is converted to plain text separated with commas and stored in a file with the extension .txt. This file format is widely used for emailing and used for importing data into another company using Tally.ERP 9

More information please visit this link.
http://www.tallysolutions.com/website/CHM/TallyERP9/Data_Management/Export_Formats.htm

Thanks,

Jun 10, 2014 | HP Office Equipment & Supplies

1 Answer

EXPORT TALLY7.2 DATA INTO EXCEL SPREADSHEET


Hi,

Please follow the below step for your problem.

Go to Gateway of Tally> Balance Sheet (Here you can choose any report which you want export in tally)

Step 1: In the Balance sheet screen click E: Export or press Alt+E.

Step 2: Select the required language from the list of languages displayed.

Step 3: Select a format from the list of formats displayed.

Step 4: By default, the exported file will be stored in C:\Program files\Tally.ERP 9 for windows 7 and C:\Tally.ERP 9 for windows XP operating systems.

Step 5: Press Enter to accept the default output sheet name.

Step 6: To update the existing file select yes in update existing file.

Step 7: To format the contents of the file selects yes in Excel (Spreadsheet) formatting.

Step 8: Select yes for the filed with color, to retain the background color in the exported file.

Step 9: Accept to export the Balance Sheet to an excel file.

Thanking you

davevipul197

Jun 04, 2011 | Tally T2245 Matrix Printer

2 Answers

How can i export the data tally to excel


Hi,

There are 2 ways to do it..

Step 1
You can export as text and import it back to excel using the text file you created.
Or
You can select HTML and give the file name as eg-XYZ.xls


Step 2

You can export all reports and statements. For this a separate export button is provided in right hand button bar. To do this go to any report e.g. day book you to export or any statement e.g. balance sheet. You would see export button on top right hand side on button bar. Press it and a screen would pop up with export related options.

The first option is format of data to be exported namely ASCII, HTML, SDF, and XML. Which ever application you are importing this data in would decide in which format you should export the data.
For statements like balance sheets and trial balance which we use to send and import file in word and excel etc. HTML format is good. We need minimum formatting in this format while using it in MS Word and MS Excel.
certain applications accept continuous data where we have defined field length. Then ASCII format is better.
For application which accept SDF and XML format these formats can be chosen.

Give a file name and the exported file is saved in the parent Tally directory on your computer. You can now use that file to import its contents into another program, send it as it is (say if it is HTML file) to a colleague or view it using a browser.

Step 3

Consider exporting day-book.Go to day book press export button or use shot cut key Alt+E. Exporting screen will displayed.

tally-export-screen-300x82.gif

Press Back space on your keyboard. And select Format as ASCII (comma delimited). Now give output File Name as Daybook.csv, now select some other option you want to export from the bottom of the screen.

tally-export-ready-screen-300x81.gif

Press enter to accept screen. Day book is exported in to tally program folder. Check program folder for file daybook.csv,

csv-file.gif

Double click on it, the file will open in excel program. If you want it in excel work sheet file, use the option Saveas, and save it in Microsoft excel workbook (*.xls) format.



Hope this is helpful. Let us know if the issue is resolved.





*Rating and Comments are invited for this solution

Nov 24, 2010 | Tally T2245 Matrix Printer

1 Answer

I HOW I EXPORT TALLY 7.2 DATA IN EXCEL FORMAT


Hi,

There are 2 ways to do it..

Step 1
You can export as text and import it back to excel using the text file you created.
Or
You can select HTML and give the file name as eg-XYZ.xls


Step 2

You can export all reports and statements. For this a separate export button is provided in right hand button bar. To do this go to any report e.g. day book you to export or any statement e.g. balance sheet. You would see export button on top right hand side on button bar. Press it and a screen would pop up with export related options.

The first option is format of data to be exported namely ASCII, HTML, SDF, and XML. Which ever application you are importing this data in would decide in which format you should export the data.
For statements like balance sheets and trial balance which we use to send and import file in word and excel etc. HTML format is good. We need minimum formatting in this format while using it in MS Word and MS Excel.
certain applications accept continuous data where we have defined field length. Then ASCII format is better.
For application which accept SDF and XML format these formats can be chosen.

Give a file name and the exported file is saved in the parent Tally directory on your computer. You can now use that file to import its contents into another program, send it as it is (say if it is HTML file) to a colleague or view it using a browser.

Step 3

Consider exporting day-book.Go to day book press export button or use shot cut key Alt+E. Exporting screen will displayed.

tally-export-screen-300x82.gif

Press Back space on your keyboard. And select Format as ASCII (comma delimited). Now give output File Name as Daybook.csv, now select some other option you want to export from the bottom of the screen.

tally-export-ready-screen-300x81.gif

Press enter to accept screen. Day book is exported in to tally program folder. Check program folder for file daybook.csv,

csv-file.gif

Double click on it, the file will open in excel program. If you want it in excel work sheet file, use the option Saveas, and save it in Microsoft excel workbook (*.xls) format.


Hope this is helpful. Let us know if the issue is resolved.



*Rating and Comments are invited for this solution

Nov 10, 2010 | Tally T2245 Matrix Printer

3 Answers

Export the data from excel to tally


  1. make a sale entry in tally
  2. Export the voucher from tally in xml format (this is to give u how the xml looks)
  3. Open the excel file where all the data is ther.
  4. open a word file, so that we can prepare the xml for mutiple vouchers. For this we will use Mail Merge facility
  5. in the XML which we did in step two, copy the data from "<TALLYMESSAGE xmlns:UDF="TallyUDF">" till the </TALLYMESSAGE>
  6. Now open the word file, go to mail merger, select the fields which needs to be changed, that is the Debtors and the amount (for normal sale entries) which should change for every sale voucher.
  7. create the mail merge.
  8. copy the data what you got in word file to a note pad and name it as sample.
  9. open again the step 2 - copy data from " <ENVELOPE> to <REQUESTDATA>" and paste in the begining of the notepad sample
  10. go the end of the notepad sample and copy the data from first file -"step 2" from " </REQUESTDATA> to </ENVELOPE>" and save the file
  11. Open tally
  12. go to import vocuhers
  13. specify the path of the notepad sample and yes ur data got imported.

Apr 21, 2010 | Microsoft Windows XP Professional

3 Answers

Export tally data to excel


tally data to excel converting . i have some data export to excel but no excel formating you have some tally data to excel spred sheet software

Aug 27, 2009 | Tally T2245 Matrix Printer

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 | Computers & Internet

4 Answers

How can i export tally data to excel format?


Export to Excel With new release now you would get one more options while exporting data. One added format option is Excel format. excelexport.jpgIf you export in this format then file would be saved in xls format. More over if you put Excel formating option to Yes then tally would automatically format the data in presentable format. Tally would automatically bold the headlines and main fields for you and format data in a good way. Take a look at excel snapshot of balance sheet exported from Tally.

excelexport2.jpgThe special thing here is that you can do the calculation on any amount figure or any row or column, which was earlier not possible. The only drawback which i could find was that amount figures are not right aligned which is must for numbers for easy calculation, although you can do it by selecting the amount figures and putting them right aligned.

Feb 27, 2008 | Computers & Internet

1 Answer

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 (http://www.codeproject.com/KB/vb/Work_with_Excel__VBNET_.aspx)
Get the Values From DataBase and Stored into excell Sheet (http://www.codeproject.com/KB/vb/Getvaluesfromdatabase.aspx)

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.
cnt.Open(stcon)

'Open the recordset.
With rst
.CursorLocation = ADODB.CursorLocationEnum.adUseClient
.Open(stSQL, cnt, ADODB.CursorTypeEnum.adOpenForwardOnly, _
ADODB.LockTypeEnum.adLockReadOnly , _
ADODB.CommandTypeEnum.adCmdText)
.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
Next
'Populate the range.
xlRange.Offset(1, 0).CopyFromRecordset(rst)
'Close the recordset.
rst.Close()
'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

Jan 03, 2008 | Computers & Internet

15 Answers

Export tally data to excel format


Select ASCII. Give output file name Eg:d:/exp Open the file using EXcel.Select Delimite  nexxt comma finish.Export is completed

Jan 02, 2008 | Tally T2245 Matrix Printer

Not finding what you are looking for?
Computers & Internet Logo

Related Topics:

553 people viewed this question

Ask a Question

Usually answered in minutes!

Top Computers & Internet Experts

Les Dickinson
Les Dickinson

Level 3 Expert

18425 Answers

Alun Cox

Level 3 Expert

2678 Answers

David Payne
David Payne

Level 3 Expert

14162 Answers

Are you a Computer and Internet Expert? Answer questions, earn points and help others

Answer questions

Manuals & User Guides

Loading...