Dim dlg As New OpenFileDialog '定义一个新的OpenFileDialog
dlg.Filter = "Excel文件|*.xlsx" '设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
MessageBox.Show("你选择的是:" & dlg.FileName, "提示") '提示用户选择的文件
Dim stryu1 As String = dlg.FileName 'args(0) '导入的excel含路径的文件名
Dim st As Date = Date.Now
'要测试耗时的代码
Dim Book As New XLS.Book(stryu1) '定义一个Excel工作簿
Dim Sheet As XLS.Sheet = Book.Sheets("数据表") '引用工作簿的第一个工作表
Dim rowcount As Integer = 0
Do While Sheet(rowcount, 0).Value <> ""
rowcount = rowcount + 1
Loop
Dim arr(rowcount, 44) As String
For i As Integer = 0 To rowcount
For j As Integer = 0 To 44
arr(i, j) = Sheet(i, j).value
Next
Next
1.将数组的值写入到内部表,可以做到。这样不需要安装Office,在只安装了wps的环境是否成立?
2.book及sheet是否需要关闭?