Click here to Skip to main content
15,892,697 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hai All,
I need to implement the function., ie., String data has been saved into Excel file.
Already i develop code for these operation in VB6 ..
But in VB.NET i don't know how to get it..
Please any body help me.
Here is my VB6 Code...
When form has been load
XML
Data1.Connect = "Excel 8.0"
Data1.DatabaseName = CurDir & "\" & "data.xls"
Data1.RecordSource = "Sheet1$"
Data1.Refresh
If Err <> 0 Then
    MsgBox "Select Excel File"
    Alarmcmd.Visible = False
End if


And this to write the data to the respective fields in Excel
alm.Data1.Recordset("ALARM") = "DG Low Fuel"

alm.Data1.Recordset("ALARM") = "Smoke/Fire"

alm.Data1.Recordset("DATE") = Mid(rxd, alarm_count, 2) & "/" & Mid(rxd, alarm_count + 2, 2) & "/" & Mid(rxd, alarm_count + 2 + 2, 2)

and this is to update and save the data in Excel
SQL
alm.Data1.Recordset.Update
            alm.Data1.Refresh



How i need to do the same task in VB.NET...........
Please help me.
Posted

1 solution

It's been ages since I've used VB6 so I'm unable to remember exactly what was the technique you have used. But with .Net, one way to modify an Excel file is to use Interop.

Few links for this topic (not in any order):
- How to automate Excel from Visual Basic .NET to fill or to obtain data in a range by using arrays[^]
- How to automate Microsoft Excel from Visual Basic .NET[^]
- Export to Excel using VB.Net[^]
- Microsoft.Office.Interop.Excel Namespace [^]
 
Share this answer
 
Comments
Espen Harlinn 2-Jan-12 19:04pm    
Nice set of useful links, my 5
Wendelius 3-Jan-12 0:25am    
Thank you :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900