老师,添加一个文件对话框,必须指定文件路径吗?Dim Book As New XLS.Book(dlg.Filter)提示错误。黄色代码该如何修改?谢谢!
Dim dlg As New OpenFileDialog '定义一个新的OpenFileDialog
dlg.Filter= "Excel文件|*.xls" '设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
Dim Book As New XLS.Book("c:\test\订单.xls")
Dim
Sheet As XLS.Sheet = Book.Sheets(0)
Tables("订单").StopRedraw()
' 注意以下数组中列名称的顺序,必须和Excel表中的列顺序一致
Dim nms() As String = {"编号","产品","客户","雇员","单价","折扣","数量","日期"}
'注意下面的循环变量从1开始,而不是从0开始,因为Excel表的第一行是标题
For n As Integer = 1 To Sheet.Rows.Count -1
Dim r As Row = Tables("订单").AddNew()
For m As Integer = 0 To nms.Length - 1
r(nms(m)) = Sheet(n,m).Value
Next
Next
end if
Tables("订单").ResumeRedraw()
[此贴子已经被作者于2017/2/6 21:21:16编辑过]