Question about Computers & Internet

1 Answer

Export data in excel shld yoeet through VB

Hi,

I want to execute the output of the folowing query
SELECT IPADDRESS FROM TRANSFER_MANAGER

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

Ad

1 Answer

  • Level 2:

    An expert who has achieved level 2 by getting 100 points

    MVP:

    An expert that gotĀ 5 achievements.

    Novelist:

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

    Governor:

    An expert whose answer gotĀ voted for 20 times.

  • Expert
  • 167 Answers

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

Posted on Jan 04, 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:

2 Answers

Transfer contacts to gmail


use a mini usb to computer.

Just sign into your Gmail account on your phone or computer, click the "Mail" menu at the top left corner of the Gmail page and select "Contacts." You'll see all your contacts - you can export and download them from there.
press the helpful button and folow me on fixya for more tips

How to put phone contacts on PC

Samsung Galaxy S4 How to Export Your Contact List Via Bluetooth

Jan 28, 2016 | Cell Phones

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

1 Answer

Vb 6.0 to oracle connectivity problem


Your SQL query does not look valid. Test the query in SQL Query analyzer, and then once it is working, copy it into your VB source. You will of course then need to make the query a string that VB will accept.

Mar 23, 2009 | Microsoft Computers & Internet

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
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'
(field1, filed2, field3);

Feb 20, 2009 | Microsoft Office Computers & Internet

1 Answer

Dos telnet command with vb 6.0


http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
PLink allows for command link execution passing a username, password and host.
To get the response to a file you could use Shell "C:\windows\cmd.exe /c batch.bat > C:\file.txt"
Batch.bat contains your plink script and file.txt is the output.

Feb 03, 2009 | Microsoft Windows XP Professional With...

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 fromhttp://www.rtslink.com/images/udimagic-free-edition-setup.zip 

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

1 Answer

Export data in excel sheet and in specific column


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

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:

603 people viewed this question

Ask a Question

Usually answered in minutes!

Top Computers & Internet Experts

Les Dickinson
Les Dickinson

Level 3 Expert

18424 Answers

Doctor PC
Doctor PC

Level 3 Expert

7733 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...