以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- excel合并数据 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=160044) |
-- 作者:yifan3429 -- 发布时间:2021/1/18 18:42:00 -- excel合并数据 希望实现导入时可以选择文件地址,还有就是一个表格多个Sheet,也要可以选择导入的Sheet 在客户选择后 按在确认在导入数据 Dim Book As New XLS.Book(projectpath & "\\20201128素冉报价册.xls") Dim Sheet As XLS.Sheet = Book.Sheets(0) Tables("素冉报价册").StopRedraw() \'注意以下数组中列名称的顺序,必须和Excel表中的列顺序一致 Dim nms() As String = {"序号","产品名称","型号","产品图片","规格(mm)长","规格(mm)宽","规格(mm)高","销售价","材质说明","颜色","配布/面料","备注","重量(KG)","体积(方)","包件数","分类"} \'注意下面的循环变量从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 Dim fl As String = ProjectPath & "Attachments\\" & r("_Identify") & ".jpg" If Sheet(n,3).SaveImage(fl) Then \'如果照片保存成功 r("产品图片") = fileSys.GetName(fl) End If Next Tables("素冉报价册").ResumeRedraw()
|
-- 作者:有点蓝 -- 发布时间:2021/1/18 20:15:00 -- 选择文件:http://www.foxtable.com/webhelp/topics/0328.htm Dim dlg As New OpenFileDialog \'定义一个新的OpenFileDialog dlg.Filter= "Excel文件|*.xls|Word文件|*.doc|Access文件|*.mdb" \'设置筛选器 If dlg.ShowDialog = DialogResult.Ok Then \'如果用户单击了确定按钮 Dim Book As New XLS.Book(dlg.FileName) …… End If 可以参考一下:http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=105144
|