Thank you Paul for your friendly help and support!
Hi Carl,
Besides, here are more tutorials and code samples for you to check.
Topic: How to read/writeExcel documentvia Excel Automation in VB.NET?
Firstly Add Reference to COM component “Microsoft Excel Object Library�into your project.
Code sample: Get/Set cell value in Excel Spreadsheet.
|
Imports Microsoft.Office.Interop.Excel
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim oExcel As Object = CreateObject("Excel.Application")
Dim oBook As Object = oExcel.Workbooks.Open("C:\Book1.xls")
Dim oSheet As Object = oBook.Worksheets(1)
'e.g. Read value in A2 cell
Dim cellValue As String = oSheet.Range("A2").Value
'e.g. Change value in A2 cell
oSheet.Range("A2").Value = ""
'Save this Excel document
oBook.SaveAs("C:\Book1.xls", True)
oExcel.Quit()
End Sub
End Class
|
Many code samples about: How to manipulate Excel Spreadsheet data in VB.NET.
1) Store each Array element to Excel in consecutive cells
http://social.msdn.microsoft.com/forums/en-US/vbgeneral/thread/1a41f104-73ff-4de4-9002-687b5243ba94/
2) Sum those consecutive cells horizontally or vertically
http://social.msdn.microsoft.com/forums/en-US/vbgeneral/thread/6cbe0a15-4e21-4bd1-aad9-ea364443d3f4/
3) Retrieve all WorkSheet names in Excel file and binding specific WorkSheet content to DataGridView
http://social.msdn.microsoft.com/forums/en-US/vbgeneral/thread/ce4bbe9c-7d13-44c5-a26c-4b84912a51f3/
4) Retrieve a range of cells and bind to DataGridView
http://social.msdn.microsoft.com/forums/en-US/vbgeneral/thread/91f1f3a7-05e6-4b75-934f-b49e6f0f4f54/
Best regards,
Martin Xie
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.