Dim filterpzh As String
Dim zzlx As String
Dim cmb As WinForm.ComboBox = e.Form.Controls("ComboBox1")
Dim doc As New PrintDoc '定义一个报表
Dim cs As List(Of String) = Tables(vars("pzsybtb")).DataTable.GetValues("号码", filterpzh, "号码")
For Each c As String In cs
Dim r1 As Integer=0
Dim drs As List(Of DataRow)
drs = DataTables(vars("pzsybtb")).Select("[号码] = " & CInt(c) & " And 经营单位 = '"& _jydw &"'","分录序号")
Dim n0 As Integer
n0= drs.count Mod 6 '计算余数
Dim yecount As Integer
yecount =drs.count \6
If n0 > 0 Then
yecount =drs.count \6 + 1
Else
End If
For ye As Integer = 1 To yecount
r1=r1+6
Dim sn As Integer = ye* 6
Dim k As Integer = (ye -1) *6
Dim ra As New prt.RenderArea '定义一个容器
ra.SplitVertBehavior = prt.SplitBehaviorEnum.Never '禁止容器因为分页而被垂直分割
Dim rt As New prt.RenderTable() '定义一个表格对象
Dim rt1 As New prt.RenderTable() '定义一个表格对象
' Dim rt2 As New prt.RenderTable '定义一个表格对象
Dim rx As New prt.RenderText '定义一个文本对象
rx.text = drs(k)("凭证字")
rx.Style.FontBold = True '字体加粗
rx.Style.FontSize = 16 '大体大小为16磅
rx.Style.F
rx.Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中排列
rx.Style.Spacing.Bottom = 1 '和下面的对象(表格)距离3毫米
ra.Children.Add(rx) '加入到容器中
Dim Sum,sum1 As Double
Dim sum2 As Integer
Sum = Tables(vars("pzsybtb")).Compute("Sum(借方金额)","[顺序号] = " & drs(k)("顺序号") & "And 经营单位 = '"& _jydw &"'")
Sum1 = Tables(vars("pzsybtb")).Compute("Sum(贷方金额)","[顺序号] = " & drs(k)("顺序号") & "And 经营单位 = '"& _jydw &"'")
Sum2 = Tables(vars("pzsybtb")).Compute("Sum(附件数)","[顺序号] = " & drs(k)("顺序号") & "And 经营单位 = '"& _jydw &"'")
rt.Cells(0,0).Text = "摘要"
rt.Cells(0,1).Text = "科目名称"
rt.Cells(0,2).Text = "币别"
rt.Cells(0,3).Text = "原币金额"
rt.Cells(0,4).Text = "汇率"
rt.Cells(0,5).Text = "借方金额"
rt.Cells(0,6).Text = "贷方金额"
If ye = yecount Then
rt.Cells(7,0).Text = "合 计:"
rt.Cells(7,1).Text =CUMoney(sum)
rt.Cells(7,1).SpanCols = 4
rt.Cells(7,5).Text = sum
rt.Cells(7,6).Text = sum1
Else
rt.Cells(7,0).Text = "转下页"
End If
rt1.Cells(1,0).Text = ""
rt1.Cells(1,6).Text = drs(k)("号码") & " ("& ye &"/" & yecount & ")"
rt1.Cells(1,3).Text = ""
rt.Cells(8,1).Text = "主管: "
rt.Cells(8,5).Text = "制单: "
rt1.Rows.Count = 2 '设置总行数
rt1.Cols.Count = 7 '设置总列数
rt.Rows(0).Style.FontBold = True '字体加粗
rt.Rows(7).Style.FontBold = True
For i As Integer = 0 To 7
rt.rows(i).Style.GridLines.All = New prt.Linedef(Color.Gray) '灰色网格线
Next
rt.Rows.Count = 9 '设置总行数
rt.Cols.Count = 7 '设置总列数
rt.Height = 120 '设置表格的高度为120毫米
rt1.rows(0).Height= 5
rt1.rows(1).Height= 5
rt.rows(0).Height= 10
rt.rows(7).Height= 8
rt.rows(8).Height= 8
rt.Cols(0).Width =40
rt.Cols(1).Width =60
rt.Cols(2).Width =10
rt.Cols(4).Width =12
Dim m As Integer =1
For j As Integer = (ye -1) *6 To drs.count - 1
If m<= 6 Then
rt.Cells(m,0).Text = drs(j)("摘要")
rt.Cells(m,1).Text = drs(j)("科目名称")
rt.Cells(m,2).Text = drs(j)("币别")
rt.Cells(m,5).Text = drs(j)("借方金额")
rt.Cells(m,6).Text = drs(j)("贷方金额")
m=m+1
End If
Next
rt1.Style.Spacing.Top = 1
rt1.Cells(1,1).Style.TextAlignHorz=prt.AlignHorzEnum.Center
rt1.Cells(1,1).Style.TextAlignVert = prt.AlignVertEnum.Top
rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center
rt.Style.TextAlignVert = prt.AlignVertEnum.Center '垂直居中
rt.Style.Spacing.Bottom = 20 '和下一个资料卡的距离是5毫米
rt.Style.F
rt1.Style.F
rt.Style.FontSize = 9 '字体大小为10磅
ra.Children.Add(rt1) '加入到容器中
ra.Children.Add(rt) '加入到容器中
If cmb.value = "自定义" Then
doc.PageSetting.Width = val(e.Form.Controls("TextBox3").text) '纸张宽度为100毫米
doc.PageSetting.Height = val(e.Form.Controls("TextBox4").text) '纸张高度为120毫米
If val(e.Form.Controls("TextBox3").text) > val(e.Form.Controls("TextBox4").text) Then
doc.AutoRotate = False '如果纸张的宽度超过高度,要加上这行代码
End If
Else
doc.PageSetting.PaperKind = zzlx '纸张类型改为a4
End If
Doc.PageSetting.TopMargin = 15
Doc.PageSetting.BottomMargin = 5
Doc.PageSetting.LeftMargin = 10 '设置左边距
Doc.PageSetting.RightMargin = 10 '设置右边距
doc.Body.Children.Add(ra)
Next
'开始加入图片
If 1= 1 Then
Dim gr As DataRow
gr = DataTables("GLVchFileAddress").Find("凭证号 = '" & drs(0)("凭证号") & "'")
If gr IsNot Nothing Then
Dim lst As New List(of String)
lst = gr.Lines("FFileAddress")
For p As Integer = 0 To lst.count -1
Dim rm As New prt.RenderImage '定义一个图片对象
rm.Width = "Parent.Width" '对象宽度为页面的90% ,190
If cmb.value = "A4" Then
rm.Height = "50%Parent.High" '"Auto" '高度由图片大小自动决定130
ElseIf cmb.value = "自定义" Then
rm.Height = "Parent.High" '"Auto" '高度由图片大小自动决定
End If
rm.Image = GetImage(lst(p)) '设置图片
rm.Style.ImageAlign.AlignHorz = prt.ImageAlignHorzEnum.Center '居中显示
doc.Body.Children.Add(rm) '将图片对象加入报表
Next
End If
End If
Next
Doc.Preview() '预览报表
图片有时候无法生成,请教一下,是不是代码问题?还是缓存问题?
软件关掉,重新运行后又可以生成图片。