--
老师,现在这个代码,第一题是数据库第二题的图片,第二题是数据库第三题的图片,错位了,最后一题没有图片
Dim tm As String = ProjectPath & "Attachments\\试题.doc" \'指定模板文件
Dim fl As String = ProjectPath & "Reports\\试题.doc" \'指定目标文件
Dim wrt As New WordReport(Tables("基础库_数据导入"),tm,fl) \'定义一个WordReport
Dim m As Integer
For Each r As Row In Tables("基础库_数据导入").rows \'逐行生成报表
m=m+1
output.show("第" & m & "个,共" & CurrentTable.Rows.count & "个")
\'标题开始
Dim st As String
Dim st2 As String
st=r("a").replace(chr(10),"")\'逐行累计
st2=r("b").replace(chr(10),"")
If st2.Trim().Length>0 Then \'如果有图片
Dim d As Date = Date.Now()
Dim sj As String =d.Hour & d.Minute & d.Second
Dim wjm As String="c:\\data\\" &sj & FileSys.GetName(st2)
Network.DownloadFile(st2,wjm )
wrt.ReplaceOne("[试题]",st.replace(chr(10),""))
wrt.ReplaceOne("[试题2]","[试题3]")
Dim img As Image = GetImage(wjm)
If img.width>400 Then
wrt.ReplaceWithImage("[试题3]",wjm,400,400*img.height/img.width)
Else
wrt.ReplaceWithImage("[试题3]",wjm,img.width,img.height)
End If
Else
output.show("into")
wrt.ReplaceOne("[试题]",st)
wrt.ReplaceOne("[试题3]","")
End If
wrt.BuildOne(r)
Next
wrt.Show() \'显示报表
[此贴子已经被作者于2021/12/2 16:34:31编辑过]