以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 专业报表 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=192820) |
-- 作者:keli0917 -- 发布时间:2024/7/24 22:59:00 -- 专业报表 Dim tx1 As WinForm.TextBox = e.Form.Controls("TextBox1") Dim tx2 As WinForm.TextBox = e.Form.Controls("TextBox2") If tx1.text = "" Or tx1.text = "0" tx1.text = "1" End If If tx2.text = "" messagebox.show("请填写最后凭证数目","^_^") Return End If If val(tx2.text) > val(Forms("凭证序时簿专业报表打印").Controls("Label5").text.split(":")(1)) messagebox.show("c超过了最大凭证数目","^_^") Return End If DataTables("凭证序时簿").LoadFilter = "凭证号 >= " & tx1.text & " And 凭证号 <= " & tx2.text & " " DataTables("凭证序时簿").Load() Tables("凭证序时簿").Filter = "凭证号 >= " & tx1.text & " And 凭证号 <= " & tx2.text & " " \'Dim tbl As Table = Tables("凭证序时簿") \'Dim cp As String = DataTables("凭证序时簿").GetComboListString("凭证号") Dim doc As New PrintDoc \'定义一个报表 Dim cs As List(Of String) = DataTables("凭证序时簿").GetValues("凭证号") For Each c As String In cs Dim r1 As Integer=0 Dim n0 As Integer Dim drs As List(Of DataRow) drs = DataTables("凭证序时簿").Select("[凭证号] = " & CInt(c) ) \'MessageBox.Show("当前凭证号总行数"& drs.count) If drs.count >= 6 Then n0= drs.count Mod 6 \'计算余数 Else n0 =0 End If Dim n1 As Integer=drs.count \\6 + 1 \'\\整除,只返回结果的整数部分,例如:12\\8,等于1 MessageBox.Show("凭证页数="& n1) For rr As Integer = 1 To n1 \'循环当前凭证号的每一页,如果要分3页才能打完一个凭证号,则N1=3 r1=r1+6 Dim sn As Integer = rr* 6 \' MessageBox.Show("r1:="& r1) For k As Integer = (rr -1) *6 To drs.count - 1 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 \'定义一个文本对象 \' Dim dr As DataRow MessageBox.Show("k:="& k) If k = sn -1 Or k = drs.count -1 Then Exit For End If \'dr = drs(k) MessageBox.Show(11) If k = (rr -1) *6 Then \'每页的首行 \'加入标题 rx.text = drs(k)("凭证字").Chars(0) & " " & drs(k)("凭证字").Chars(1) & " 凭 证" MessageBox.Show(12) rx.Style.FontBold = True \'字体加粗 rx.Style.FontSize = 16 \'大体大小为16磅 rx.Style.F rx.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'水平居中排列 rx.Style.Spacing.Bottom = 3 \'和下面的对象(表格)距离3毫米 ra.Children.Add(rx) \'加入到容器中 End If \'Dim tb As Table = tbl Dim m As Integer Dim Sum,sum1 As Double Dim sum2 As Integer Sum = Tables("凭证序时簿").Compute("Sum(借方金额)","[顺序号] = " & drs(k)("顺序号")) Sum1 = Tables("凭证序时簿").Compute("Sum(贷方金额)","[顺序号] = " & drs(k)("顺序号")) Sum2 = Tables("凭证序时簿").Compute("Sum(附件数)","[顺序号] = " & drs(k)("顺序号")) 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 = "贷方金额" rt.Cells(7,0).Text = "合 计:" rt.Cells(7,1).Text = CUMoney(sum) rt.Cells(7,1).SpanCols = 2 rt.Cells(7,3).Text = sum rt.Cells(7,4).Text = sum1 rt1.Cells(1,0).Text = " 凭证类别: "& drs(k)("凭证字") rt1.Cells(1,2).Text = " 凭证号: "& drs(k)("凭证号") rt1.Cells(1,1).Text = Format(drs(k)("日期"),"yyyy年MM月dd日") rt1.Cells(0,2).Text = " 附件数: " & sum2 &" 张" \'rt.Cells(8,0).Text = "主管: " & drs(k)("会计主管") rt.Cells(8,2).Text = "审核: " & drs(k)("审核人") rt.Cells(8,4).Text = "制单: " & drs(k)("制单人") rt1.Rows.Count = 2 \'设置总行数 rt1.Cols.Count = 3 \'设置总列数 rt.Rows(0).Style.FontBold = True \'字体加粗 rt.Rows(7).Style.FontBold = True ra.Children.Add(rt1) \'加入到容器中 ra.Children.Add(rt) \'加入到容器中 MessageBox.Show(33) \' doc.Body.Children.Add(rt1) \' doc.Body.Children.Add(rt) \'将表格对象加入到报表中 For i As Integer = 0 To 7 rt.rows(i).Style.GridLines.All = New prt.Linedef \'设置网格线 Next rt.Rows.Count = 9 \'设置总行数 rt.Cols.Count = 7 \'设置总列数 rt.Height = 65 \'设置表格的高度为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(2).Width =35 \' m=1 MessageBox.Show(88) \' Tables("凭证序时簿").Filter ="[顺序号] = " & drs(k)("顺序号") \' For Each r As Row In Tables("凭证序时簿").Rows \' If m<= 6 Then rt.Cells(m,0).Text = drs(k)("摘要") rt.Cells(m,1).Text = drs(k)("科目名称") rt.Cells(m,2).Text = drs(k)("币别") rt.Cells(m,3).Text =drs(k)("原币金额") rt.Cells(m,4).Text = drs(k)("汇率") rt.Cells(m,5).Text = drs(k)("借方金额") rt.Cells(m,6).Text = drs(k)("贷方金额") \' m=m+1 \' End If \' Next rt1.Style.Spacing.Top = 6 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.F rt1.Style.F MessageBox.Show(99) \' Tables("凭证序时簿").Filter = "" \' Tables("凭证序时簿").DataTable.ReplaceFor("A",0,"") Doc.PageSetting.TopMargin = 20 Doc.PageSetting.BottomMargin = 15 doc.Body.Children.Add(ra) Next Next Next Doc.Preview() \'预览报表
|
-- 作者:keli0917 -- 发布时间:2024/7/24 23:00:00 -- \'加入标题 rx.text = drs(k)("凭证字").Chars(0) & " " & drs(k)("凭证字").Chars(1) & " 凭 证" MessageBox.Show(12) 运行到加入标题以后就错了。麻烦帮忙修改一下。
|
-- 作者:keli0917 -- 发布时间:2024/7/24 23:13:00 -- 希望实现将tx1.text到tx2.text所有凭证号打印在一个报表中。每个凭证号有N1页,每个分页的凭证上分别要打印表头+6行数据。 |
-- 作者:有点蓝 -- 发布时间:2024/7/25 9:02:00 -- 提示什么错误? |
-- 作者:keli0917 -- 发布时间:2024/7/25 9:42:00 -- 索引超出了数组界限。 |
-- 作者:有点蓝 -- 发布时间:2024/7/25 9:45:00 -- 说明这个drs(k)("凭证字")没有数据,或者数据不超过1个字符。应该加上判断 if drs(k).isnull("凭证字")=false andalso drs(k)("凭证字").length >= 2 rx.text = drs(k)("凭证字").Chars(0) & " " & drs(k)("凭证字").Chars(1) & " 凭 证" end if
|