你好,我现在遇到同样的问题,我想通过vb.net程序读取excel中的单元格数据,你实现了吗?教教我啊,,邮箱

2024-12-22 19:25:04
推荐回答(1个)
回答1:

1,先添加excel的引用,然后添加如下代码:
Imports Microsoft.Office.Interop.Excel
Imports Microsoft.Office.Interop
Imports Microsoft.Office
2,添加一个button空间,添加如下代码:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim xlapp As New Excel.Application
Dim xlbook As Excel.Workbook
Dim xlsheet As Excel.Worksheet
xlbook = xlapp.Workbooks.Open("c:\1.xls")
xlsheet = xlbook.Worksheets(0)
Console.WriteLine(xlsheet.Cells(1, 1).text)
xlbook = Nothing
xlapp.Quit()

End Sub
到此,应该就能读取了。