'-----定义导入参数
'-----获取Excel文件名
Dim dlg As New OpenFileDialog
dlg.Filter = "Excel文件|*.xls;*.xlsx"
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
这是我导入窗口的代码
但是导入空表时会报错呢.