老师:
图片存放的是一张张图片。路径正确。msgbox("E:\不良照片\工序检验\不良照片\dt.rows(6)(nms(7)) ") 后显示:
导出的报表如下:
这个是按钮代码:
Dim dt As Table = Tables("整车质量报表_table1")
Dim nms() As String = {"日期1","编号","代号","底盘号","发动机号","序号","不良描述","本地不良照片","部门","检验岗1","班组","操作人","考核","原因分析","预防措施"} '要导出的列名
Dim caps() As String = {"日期","编号","代号","底盘号","发动机号","序号","不良描述","照片","部门","检验岗","班组","操作人","考核","原因分析","预防措施"} '对应的列标题
Dim szs() As Integer = {90,50,50,80,100,45,350,120,40,60,60,70,40,400,550} '对应的列宽
Dim Book As New XLS.Book '定义一个Excel工作簿
Dim Sheet As XLS.Sheet = Book.Sheets(0) '引用工作簿的第一个工作表
Dim at As XLS.Style = Book.NewStyle '日期列的显示格式
at.Format = "yyyy-MM-dd"
at.BorderTop = XLS.LineStyleEnum.Thin
at.BorderBottom = XLS.LineStyleEnum.Thin
at.BorderLeft = XLS.LineStyleEnum.Thin
at.BorderRight = XLS.LineStyleEnum.Thin
at.BorderColorTop = Color.Black
at.BorderColorBottom = Color.Black
at.BorderColorLeft = Color.Black
at.BorderColorRight = Color.Black
at.AlignHorz = XLS.AlignHorzEnum.Center '水平居中
at.AlignVert = XLS.AlignVertEnum.Center '垂直居中
Dim bt As XLS.Style = Book.NewStyle() 'ct样式为:黑线网格线,内容居左
bt.BorderTop = XLS.LineStyleEnum.Thin
bt.BorderBottom = XLS.LineStyleEnum.Thin
bt.BorderLeft = XLS.LineStyleEnum.Thin
bt.BorderRight = XLS.LineStyleEnum.Thin
bt.BorderColorTop = Color.Black
bt.BorderColorBottom = Color.Black
bt.BorderColorLeft = Color.Black
bt.BorderColorRight = Color.Black
bt.AlignHorz = XLS.AlignHorzEnum.Center '水平居中
bt.AlignVert = XLS.AlignVertEnum.Center '垂直居中
Dim ct As XLS.Style = Book.NewStyle() 'ct样式为:黑线网格线,内容居左
ct.BorderTop = XLS.LineStyleEnum.Thin
ct.BorderBottom = XLS.LineStyleEnum.Thin
ct.BorderLeft = XLS.LineStyleEnum.Thin
ct.BorderRight = XLS.LineStyleEnum.Thin
ct.BorderColorTop = Color.Black
ct.BorderColorBottom = Color.Black
ct.BorderColorLeft = Color.Black
ct.BorderColorRight = Color.Black
ct.AlignHorz = XLS.AlignHorzEnum.Left '水平居左
ct.AlignVert = XLS.AlignVertEnum.Center '垂直居中
For c As Integer = 0 To nms.length -1 '指定表头
Sheet(0, c).Value = caps(c) '指定列标题
Sheet(0, c).Style = bt
Sheet.Cols(c).Width = szs(c) '指定列宽
Next
For r As Integer = 0 To dt.Rows.Count - 1 '填入数据
For c As Integer = 0 To nms.length -1
Sheet(r +1, c).Value = dt.rows(r)(nms(c))
Sheet(r +1, c).Style = bt '指定其余列显示居中带边框
Sheet(r +1, 0).Style = at '指定0列显示日期格式
Sheet(r +1, 6).Style = ct '指定6列显示居左带边框
Sheet(r +1, 12).Style = ct '指定6列显示居左带边框
Sheet(r +1, 13).Style = ct '指定6列显示居左带边框
Next
Next
Sheet(7,1).Value = New XLS.Picture(GetImage("E:\不良照片\工序检验\不良照片\JJ2199841.jpg"),6,6,190,190) '照片的名字能随当前行图片列名字一起导出到报表中
'Sheet(r,8).Value = New XLS.Picture(GetImage("E:\不良照片\工序检验\不良照片\dt.rows(r)(nms(7)) "),6,6,190,190) '最终的效果是这样的,现在不能动态提出行中图片名称?
msgbox("E:\不良照片\工序检验\不良照片\dt.rows(6)(nms(7)) ")
Book.Save( "D:\质量管理系统\日报\工序检验报表.xls" )
Dim Proc As New Process
Proc.File = "D:\质量管理系统\日报\工序检验报表.xls"
Proc.Start()
请老师费心!
此主题相关图片如下:微信图片_20180819093523.png
此主题相关图片如下:微信图片_20180819093611.png