老师好,下面代码找不到Excel(2010)的文件。另存为2013工作簿是找得到的。
'-----获取Excel文件名
Dim dlg As New OpenFileDialog
dlg.Filter = "Excel文件|*.xls"
Dim bookName,sheetName As String
If dlg.ShowDialog = DialogResult.OK Then
bookname = dlg.FileName
e.Form.Controls("bookName").text = bookName
'-----定义excel文件-----
Dim Book As New XLS.Book(bookname)
'------遍历表名-----
For Each st As xls.sheet In book.sheets
sheetName = sheetName & st.name & "|"
Next
'------设置默认值
Dim stname As WinForm.ComboBox = e.Form.Controls("sheetname")
stname.combolist = sheetname.TrimEnd("|")
stname.SelectedIndex = 0
Dim btn As WinForm.Button = e.Form.Controls("读出数据")
btn.PerformClick()
End If
[此贴子已经被作者于2018/7/21 7:54:03编辑过]