以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 导入Excel表 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=115138) |
||||
-- 作者:Springamy -- 发布时间:2018/3/1 16:53:00 -- 导入Excel表 如图,要一次性导入多个Excel表单,怎么样做到如下图期望的那样呢?
表:货单 窗口1
|
||||
-- 作者:有点甜 -- 发布时间:2018/3/1 18:10:00 -- Dim dlg As new OpenFileDialog dlg.MultiSelect = True dlg.Filter = "excel|*.xls;*.xlsx" If dlg.ShowDialog = DialogResult.OK Then Dim Book As New XLS.Book(dlg.FileName) Dim Sheet As XLS.Sheet = Book.Sheets(0) For i As Integer = 6 To Sheet.Rows.Count-1 If sheet(i,0).text > "" Then Dim dr As DataRow = DataTables("货单").addnew dr("单号") = sheet(1,1).Text dr("办事处") = sheet(2,1).Text dr("责任人") = sheet(2,2).Text dr("仓储地点") = sheet(0,2).Text dr("项目名称") = sheet(1,2).Text dr("编号") = sheet(i,0).text dr("数量") = sheet(i,1).text End If Next End If |
||||
-- 作者:Springamy -- 发布时间:2018/3/2 9:53:00 -- 甜大,代码有问题,可以选择多个文件,但是只能读取第一个文件 |
||||
-- 作者:Springamy -- 发布时间:2018/3/2 10:25:00 -- 以下是引用Springamy在2018/3/2 9:53:00的发言:
甜大,代码有问题,可以选择多个文件,但是只能读取第一个文件 问题已解决 |
||||
-- 作者:有点甜 -- 发布时间:2018/3/2 10:26:00 -- Dim dlg As new OpenFileDialog dlg.MultiSelect = True dlg.Filter = "excel|*.xls;*.xlsx" If dlg.ShowDialog = DialogResult.OK Then For Each f As String In dlg.FileNames Dim Book As New XLS.Book(f) Dim Sheet As XLS.Sheet = Book.Sheets(0) For i As Integer = 6 To Sheet.Rows.Count-1 If sheet(i,0).text > "" Then Dim dr As DataRow = DataTables("货单").addnew dr("单号") = sheet(1,1).Text dr("办事处") = sheet(2,1).Text dr("责任人") = sheet(2,2).Text dr("仓储地点") = sheet(0,2).Text dr("项目名称") = sheet(1,2).Text dr("编号") = sheet(i,0).text dr("数量") = sheet(i,1).text End If Next next End If |