我想在一个文本框中读取整个 Excel 工作表的数据。
这可能吗?
我知道将单元格数据从 excel 读取到文本框的代码。
PrivateSub Button18_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button18.Click
Dim xlaTest As Excel.Application = CType(CreateObject("Excel.Application"), Excel.Application)
xlaTest.Visible = True
Dim wbkTest As Excel.Workbook = xlaTest.Workbooks.Open("D:\Tests\VBTrials\ExcelTests\TestWorkbook.xls")
Dim wshTest As Excel.Worksheet = DirectCast(wbkTest.Worksheets("Sheet1"), Excel.Worksheet)
TextBox1.Text = wshTest.Range("B2").Value
wbkTest.Close()
xlaTest.Quit()
EndSub