Rss & SiteMap
Foxtable(狐表) http://www.foxtable.com
有好多表格格式一样的文件、要把那些文件里的内容合并到一个表里去。该怎么处理?
Dim dlg As New OpenFileDialog '定义一个新的OpenFileDialog
dlg.Filter= "excel文件|*.xlsx" '设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
Dim mg As New Merger
mg.SourcePath = dlg.FileName
mg.Format = "excel" '指定格式
mg.SourceTableName = "国铁商城广综财"
mg.DataTableName = "国铁商城低值易耗品清单表"
mg.Merge()
End If
此主题相关图片如下:微信图片_20240428115249.png
所选的文件中、有"国铁商城广综财"这个表、但是却提示错误
这是固定导入某一个文件、如果要改为打开文件对话框,合并用户指定的文件;要怎么改?
Dim Book As New XLS.Book("D:\我的文件\Mylave\输出报表\三个系统低值易耗品台账\2024-04-28【三个系统低值易耗品】\行政办【三个系统低值易耗品】.xlsx")
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Tables("国铁商城低值易耗品清单表").StopRedraw()
'注意以下数组中列名称的顺序,必须和Excel表中的列顺序一致
Dim nms() As String = {"序号","系统编号","订单号","商品名称","一级类目","售价","数量","售价小计","站段归属","申请站段","备注","采购单提交时间","使用站段","存放地点","保管人","低值易耗品备注"}
'注意下面的循环变量从1开始,而不是从0开始,因为Excel表的第一行是标题
For n As Integer = 4 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
Tables("国铁商城低值易耗品清单表").ResumeRedraw()
不管选哪个文件、执行后都只新装了两条空白行
Dim dlg As New OpenFileDialog '定义一个新的OpenFileDialog
dlg.Filter= "excel文件|*.xlsx" '设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
Dim Book As New XLS.Book(dlg.FileName)
'Dim Book As New XLS.Book("D:\我的文件\Mylave\输出报表\三个系统低值易耗品台账\2024-04-28【三个系统低值易耗品】\行政办【三个系统低值易耗品】.xlsx")
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Tables("国铁商城低值易耗品清单表").StopRedraw()
'注意以下数组中列名称的顺序,必须和Excel表中的列顺序一致
Dim nms() As String = {"序号","系统编号","订单号","商品名称","一级类目","售价","数量","售价小计","站段归属","申请站段","备注","采购单提交时间","使用站段","存放地点","保管人","低值易耗品备注"}
'注意下面的循环变量从1开始,而不是从0开始,因为Excel表的第一行是标题
For n As Integer = 4 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
Tables("国铁商城低值易耗品清单表").ResumeRedraw()
End If
现在可以导进去啦、现在如果我想同时选择好几个文件;一起导进去、而不用选一个文件导进去后、再去选另外一个文件导进去。增加了【允许同时选择多个文件】、但是导进去还是只导了一个文件。该怎么改?
Dim dlg As New OpenFileDialog '定义一个新的OpenFileDialog
dlg.Filter= "excel文件|*.xlsx" '设置筛选器
dlg.MultiSelect = True '允许选择多个文件
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
Dim Book As New XLS.Book(dlg.FileName)
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Tables("国铁商城低值易耗品清单表").StopRedraw()
'注意以下数组中列名称的顺序,必须和Excel表中的列顺序一致
Dim nms() As String = {"序号","系统编号","订单号","商品名称","型号 ","单价","数量","金额","站段归属","申请站段","订单备注","领用时间","使用站段","存放地点","保管人","低值备注"}
'注意下面的循环变量从1开始,而不是从0开始,因为Excel表的第一行是标题
For n As Integer = 4 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