我正在做一个项目,我基本上必须将数据(单元格)从 excel 文件显示到文本框。我使用了以下代码
Option Explicit On
Imports System.IO
Imports Microsoft.VisualBasic.FileIO
Partial Public Class Window2
Dim objexcel As New Excel._ExcelApplication
Dim objwork As Excel._ExcelSheet
Dim objworksheet As Excel.Worksheet
Private Sub Window1_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Window1.Loaded
objwork = objexcel.Workbooks.open("D:\jkj.xlsx")
objworksheet = CType(objwork.Worksheets.Item("Sheet1"), Excel.Worksheet)
TextBox1.Text = objwork.cells(1, 1).text
Textbox2.Text = objwork.cells(2, 1).text
objexcel.Workbooks.close()
objexcel.Workbooks.Quit()
End Sub
End Class
但它显示以下错误
未找到成员。(来自 HRESULT 的异常:0x80020003 (DISP_E_MEMBERNOTFOUND))
有人可以建议代码有什么问题吗?我已经在网上搜索并阅读了高低。
谢谢!