你好,我现在遇到同样的问题,我想通过vb.net程序读取excel中的单元格数据,你实现了吗?教教我啊,,邮箱
展开全部
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
到此,应该就能读取了。
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
到此,应该就能读取了。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询