以文本方式查看主题 - 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=174009) |
-- 作者:繁羽 -- 发布时间:2021/12/27 11:02:00 -- 怎么从excel 里面提取每张图片 Dim dlg As New OpenFileDialog \'定义一个新的OpenFileDialog dlg.Filter= "Excel文件|*.xlsx|Word文件|*.doc|Access文件|*.mdb" \'设置筛选器 If dlg.ShowDialog = DialogResult.Ok Then \'如果用户单击了确定按钮 Dim nms() As String = {"状态","记录时间","店铺名称","产品类别","单号","产品SKU","责任方","状况描述 原因","客户姓名","联系方式","寄送地址","处理方式","寄送SKU","配件SKU","数量","备注","发货仓库","系统单号","追踪号","物流公司","发货日期","收货日期","下单日期","回访","记录日期","结束日期","赠送SKU","处理时间"} Dim nms2() As String = {"状态","记录时间","店铺名称","产品类别","单号z","产品SKU","责任方","状况描述 原因","客户姓名","联系方式","寄送地址","处理方式","寄送SKU","配件SKU","数量","备注","发货仓库","系统单号","追踪号","物流公司","发货日期","收货日期","下单日期","回访","记录日期","结束日期","赠送SKU","处理时间"} Dim dict As new Dictionary(of String,String) For m As Integer = 0 To nms.Length - 1 dict.add(nms2(m),nms(m)) Next Dim Book As New XLS.Book(dlg.FileName) Dim Sheet As XLS.Sheet = Book.Sheets(0) Tables("table_3").StopRedraw() \'注意下面的循环变量从1开始,而不是从0开始,因为Excel表的第一行是标题 For n As Integer = 1 To Sheet.Rows.Count -1 Dim bh As String = sheet(n,3).Text If DataTables("table_3").Find("单号 = \'"& bh &"\'")Is Nothing Then If Sheet(n,0).text > "" Then Dim r As Row = Tables("table_3").AddNew() For m1 As Integer = 0 To Sheet.Cols.Count - 1 If dict.ContainsKey(Sheet(0,m1).Value) r(dict(Sheet(0,m1).Value)) = Sheet(n,m1).Value End If Next r("处理人") = user.name r("记录")=Datetime.Today & "批量导入" r("状态")="已结案" End If End If Next Tables("table_3").ResumeRedraw() msgbox("导入成功") End If 老师您好,我想导入图片,我想问一下如何导入图片进foxtable里面,我想提取每一个行的图片用ftp上传到服务器里面
|
-- 作者:有点蓝 -- 发布时间:2021/12/27 11:11:00 -- 参考:http://www.foxtable.com/webhelp/topics/2492.htm |
-- 作者:繁羽 -- 发布时间:2021/12/27 11:45:00 -- 老师我不是报表导入的喔,我是excel图片如何提出来 |
-- 作者:有点蓝 -- 发布时间:2021/12/27 11:54:00 -- 里面有提取图片的代码 |
-- 作者:繁羽 -- 发布时间:2021/12/27 11:56:00 -- If Sheet(4,4).SaveImage(fl) Then \'如果照片保存成功 dr("照片") = fileSys.GetName(fl) ,是这个吗老师我想问一下这个4,4是什么意思 |
-- 作者:有点蓝 -- 发布时间:2021/12/27 11:59:00 -- 1楼有大量这种用法啊,现在还搞不清楚是什么意思?!您说1楼代码里If Sheet(n,0).text > "" Then的n,0是什么意思? |
-- 作者:繁羽 -- 发布时间:2021/12/27 13:04:00 -- Dim dlg As New OpenFileDialog \'定义一个新的OpenFileDialog dlg.Filter= "Excel文件|*.xlsx|Word文件|*.doc|Access文件|*.mdb" \'设置筛选器 If dlg.ShowDialog = DialogResult.Ok Then \'如果用户单击了确定按钮 Dim nms() As String = {"状态","记录时间","店铺名称","产品类别","单号","产品SKU","责任方","状况描述 原因","客户姓名","联系方式","寄送地址","处理方式","寄送SKU","配件SKU","数量","备注","发货仓库","系统单号","追踪号","物流公司","发货日期","收货日期","下单日期","回访","记录日期","结束日期","赠送SKU","处理时间"} Dim nms2() As String = {"状态","记录时间","店铺名称","产品类别","单号z","产品SKU","责任方","状况描述 原因","客户姓名","联系方式","寄送地址","处理方式","寄送SKU","配件SKU","数量","备注","发货仓库","系统单号","追踪号","物流公司","发货日期","收货日期","下单日期","回访","记录日期","结束日期","赠送SKU","处理时间"} Dim dict As new Dictionary(of String,String) For m As Integer = 0 To nms.Length - 1 dict.add(nms2(m),nms(m)) Next Dim Book As New XLS.Book(dlg.FileName) Dim Sheet As XLS.Sheet = Book.Sheets(0) Tables("table_3").StopRedraw() \'注意下面的循环变量从1开始,而不是从0开始,因为Excel表的第一行是标题 For n As Integer = 1 To Sheet.Rows.Count -1 Dim bh As String = sheet(n,3).Text If DataTables("table_3").Find("单号 = \'"& bh &"\'")Is Nothing Then If Sheet(n,0).text > "" Then Dim r As Row = Tables("table_3").AddNew() For m1 As Integer = 0 To Sheet.Cols.Count - 1 If dict.ContainsKey(Sheet(0,m1).Value) r(dict(Sheet(0,m1).Value)) = Sheet(n,m1).Value Dim fl As String = ProjectPath & "Attachments\\" & r("单号") & ".jpg" If Sheet(4,4).SaveImage(fl) Then \'如果照片保存成功 r("图片") = fileSys.GetName(fl) End If End If Next r("处理人") = user.name r("记录")=Datetime.Today & "批量导入" r("状态")="已结案" End If End If Next Tables("table_3").ResumeRedraw() msgbox("导入成功") End If 老师我觉得应该放在这里但是这个不知道应该怎么改
|
-- 作者:有点蓝 -- 发布时间:2021/12/27 13:39:00 -- 把4,4改为图片所在的单元格的索引 |
-- 作者:繁羽 -- 发布时间:2021/12/27 16:08:00 -- Dim dlg As New OpenFileDialog \'定义一个新的OpenFileDialog dlg.Filter= "Excel文件|*.xlsx|Word文件|*.doc|Access文件|*.mdb" \'设置筛选器 If dlg.ShowDialog = DialogResult.Ok Then \'如果用户单击了确定按钮 Dim nms() As String = {"状态","记录时间","店铺名称","产品类别","单号","产品SKU","责任方","状况描述 原因","客户姓名","联系方式","寄送地址","处理方式","寄送SKU","配件SKU","数量","备注","发货仓库","系统单号","追踪号","物流公司","发货日期","收货日期","下单日期","回访","记录日期","结束日期","赠送SKU","处理时间"} Dim nms2() As String = {"状态","记录时间","店铺名称","产品类别","单号z","产品SKU","责任方","状况描述 原因","客户姓名","联系方式","寄送地址","处理方式","寄送SKU","配件SKU","数量","备注","发货仓库","系统单号","追踪号","物流公司","发货日期","收货日期","下单日期","回访","记录日期","结束日期","赠送SKU","处理时间"} Dim dict As new Dictionary(of String,String) For m As Integer = 0 To nms.Length - 1 dict.add(nms2(m),nms(m)) Next Dim Book As New XLS.Book(dlg.FileName) Dim Sheet As XLS.Sheet = Book.Sheets(0) Tables("table_3").StopRedraw() \'注意下面的循环变量从1开始,而不是从0开始,因为Excel表的第一行是标题 For n As Integer = 1 To Sheet.Rows.Count -1 Dim bh As String = sheet(n,3).Text If DataTables("table_3").Find("单号 = \'"& bh &"\'")Is Nothing Then If Sheet(n,0).text > "" Then Dim r As Row = Tables("table_3").AddNew() For m1 As Integer = 0 To Sheet.Cols.Count - 1 If dict.ContainsKey(Sheet(0,m1).Value) r(dict(Sheet(0,m1).Value)) = Sheet(n,m1).Value Dim fl As String = ProjectPath & "Attachments\\" & r("单号") & ".jpg" If Sheet(n,1).SaveImage(fl) Then \'如果照片保存成功 \'r("图片") = fileSys.GetName(fl) Dim ftp1 As New FtpClient Dim i As Integer = 0 Dim dr As Row = Tables("Table_3").Current ftp1.host="172.16.120.41" ftp1.Account ="admin" ftp1.password ="qw123" If ftp1.MakeDir(dr("单号") & "\\") Then Else End If If ftp1.Upload(fl) = True Then \'msgbox("成功") Else \'msgbox("不成功") End If If ftp1.FileExists("\\" &dr("单号")& "\\" & dr("单号") & ".jpg") Then For i = 1 To 999 If ftp1.FileExists("\\" &dr("单号")& "\\" & dr("单号")& "("& i &").jpg")=False Then Exit For End If Next End If If i > 0 Then ftp1.Rename(FileSys.GetName(r("单号") & ".jpg"),"\\" &dr("单号") & "\\" & dr("单号") &"("& i &").jpg") r("图片") = "\\" &dr("单号") & "\\" & dr("单号") &"("& i &").jpg" ftp1.Delete("/" & FileSys.GetName( r("单号") & ".jpg")) Else ftp1.Rename(FileSys.GetName(r("单号") & ".jpg"),"\\" &dr("单号") & "\\" & dr("单号") &".jpg") r("图片") = "\\" &dr("单号")& "\\" & dr("单号") & ".jpg" ftp1.Delete("/" & FileSys.GetName( r("单号") & ".jpg")) End If End If End If Next r("处理人") = user.name r("记录")=Datetime.Today & "批量导入" r("状态")="已结案" End If End If Next Tables("table_3").ResumeRedraw() msgbox("导入成功")
|
-- 作者:有点蓝 -- 发布时间:2021/12/27 16:29:00 -- foxtable仅支持一个单元格一张图片。 试试使用vba:http://foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=107390&replyID=734188&skin=1
|