以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]打印设置每页行问题 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=158282) |
-- 作者:hanlingli111999 -- 发布时间:2020/11/14 9:18:00 -- [求助]打印设置每页行问题 老师好,帮助文件有打印设置本页小计及总汇总代码,设定了每页20行, 怎么修改不指定每页行数呀,代码如下 Dim doc As
New PrintDoc Dim tb As Table = Tables("计算表") Dim prs As
Integer = 20
\'每页20行 Dim sum1 As
Integer = 0
\'数量小计 Dim sum2 As
Double = 0 \'金额小计 Dim tsum1 As
Integer = 0
\'数量总计 Dim tsum2 As
Double = 0 \'金额总计 Dim idx1 As Integer= tb.cols("重量t").Index Dim idx2 As Integer= tb.cols("油漆面积㎡").Index For p As Integer = 0 To math.Ceiling(tb.Rows.Count / prs) - 1 Dim rt As New prt.RenderTable rt.Style.Gridlines.All = New prt.Linedef(Color.Gray) rt.CellStyle.Spacing.All = 0.5 sum1 = 0 sum2 = 0 For c As Integer = 0 To tb.Cols.Count - 1 rt.Cells(0,c).Text = tb.Cols(c).Name Next For r As Integer = p * prs To math.min(tb.Rows.Count - 1,( p + 1) * prs - 1) sum1 =sum1 + tb.rows(r)("重量t")
sum2 =sum2 + tb.rows(r)("油漆面积㎡") For c As Integer = 0 To tb.Cols.Count - 1 rt.Cells(r - p * prs + 1, c).Text = tb.rows(r)(c) Next Next tsum1 = tsum1 + sum1 tsum2 = tsum2 + sum2 rt.Rows.Count = rt.Rows.Count + 1 \'增加本页小计行 rt.Rows(rt.Rows.count -1)(0).text = "本页小计" rt.Rows(rt.Rows.count -1)(idx1).text = sum1 rt.Rows(rt.Rows.count -1)(idx2).text = sum2 If p = math.Ceiling(tb.Rows.Count / prs) - 1 \'如果是最后一页 rt.Rows.Count = rt.Rows.Count + 1 \'增加总计行 rt.Rows(rt.Rows.count -1)(0).text = "总计" rt.Rows(rt.Rows.count -1)(8).text = tsum1 rt.Rows(rt.Rows.count -1)(9).text = tsum2 Else rt.BreakAfter = prt.BreakEnum.Page \'否则换页 End If doc.Body.Children.Add(rt) Next doc.Preview() |
-- 作者:有点蓝 -- 发布时间:2020/11/14 10:10:00 -- 这个就是:http://www.foxtable.com/webhelp/topics/2239.htm |
-- 作者:hanlingli111999 -- 发布时间:2020/11/14 15:20:00 -- 老师,我设置的排除隐藏列怎么隐藏不了呢 Syscmd.Column.UnHide() Dim doc As New PrintDoc Dim rt As New Prt.RenderTable Dim rx As prt.RenderText Dim cnt As Integer Dim tb As Table = Tables("计算表") Dim ColNames As New List(Of String) For Each cl As Col In tb.Cols \'排除隐藏列 If cl.Visible Then ColNames.Add(cl.Name) End If Next rt.Style.Font = tb.Font rt.Style.GridLines.All = New prt.LineDef(0.3,Color.LightGray) rt.CellStyle.Spacing.All = 1 rt.Style.Font = tb.Font Dim drs As List(Of DataRow) Dim pds As List(Of String) = tb.DataTable.GetValues("计算部位",tb.Filter) Dim md As New prt.RenderText md.Text = ApplicationTitle.split(".")(0) md.Style.Font = New Font("宋体", 16, FontStyle.Bold) md.Style.TextAlignHorz = prt.AlignHorzEnum.Center md.Style.Spacing.Bottom = 3 Doc.body.Children.Add(md) For c As Integer = 0 To tb.Cols.Count - 1 \'生成列标题 rt.Cells(0,c).Text = tb.Cols(c).Name rt.Cols(c).Width = tb.Cols(c).PrintWidth Next For Each pd As String In pds \'分产品打印 If tb.Filter > "" Then drs = tb.DataTable.Select("计算部位 = \'" & pd & "\' And " & tb.Filter) Else drs = tb.DataTable.Select("计算部位 = \'" & pd & "\'" ) End If For Each dr As DataRow In drs \'逐行打印此产品的订单 cnt = rt.Rows.Count For c As Integer = 0 To tb.Cols.Count - 1 rt.Cells(cnt, c).Text = dr(tb.Cols(c).Name) Next Next cnt = rt.Rows.Count rt.Cells(cnt, 0).Text = "小计 " & pd \'打印产品的小计 rt.Cells(cnt,8).Text = tb.compute("Sum(重量t)", "计算部位 = \'" & pd & "\'") rt.Cells(cnt,9).Text = tb.compute("Sum(油漆面积㎡)", "计算部位 = \'" & pd & "\'") Next cnt = rt.Rows.Count rt.Cells(cnt, 0).Text = "合计 " \'打印合计 rt.Cells(cnt, 8).Text = tb.compute("Sum(重量t)") rt.Cells(cnt, 9).Text = tb.compute("Sum(油漆面积㎡)") rt.Cols.Insert(0) \'在左边插入一列,用于打印行号 rt.Cols(0).Width = 10 \'设置行号列的宽度 For i As Integer = 1 To rt.Rows.Count - 1 rt.Cells(i,0).text = i \'逐行写入行号 Next doc.Body.Children.Add(rt) doc.PageSetting.Landscape = True \'横向打印 Dim my As New prt.RenderTable my.Cells(0,0).Text = Date.Today my.Cells(0,1).Text = ApplicationTitle.split(".")(0) my.Cells(0,2).Text = "第[PageNo]页,共[PageCount]页" my.Cols(0).Style.TextAlignHorz = prt.AlignHorzEnum.Left my.Cols(1).Style.TextAlignHorz = prt.AlignHorzEnum.Center my.Cols(2).Style.TextAlignHorz = prt.AlignHorzEnum.Right my.Style.FontSize = 8 \'字体大小为8磅 Doc.PageFooter = my \'作为页眉使用 doc.Preview() |
-- 作者:有点蓝 -- 发布时间:2020/11/14 15:25:00 -- 比如 For c As Integer = 0 To tb.Cols.Count - 1 \'生成列标题 rt.Cells(0,c).Text = tb.Cols(c).Name rt.Cols(c).Width = tb.Cols(c).PrintWidth Next 改为 For c As Integer = 0 To ColNames.length - 1 \'生成列标题 rt.Cells(0,c).Text = ColNames(c) rt.Cols(c).Width = tb.Cols(ColNames(c)).PrintWidth Next |
-- 作者:hanlingli111999 -- 发布时间:2020/11/14 15:32:00 -- 老师,修改后提示出错 此主题相关图片如下:(a4nk49crcdi{rsqwe$ivq.png |
-- 作者:有点蓝 -- 发布时间:2020/11/14 16:17:00 -- For c As Integer = 0 To ColNames.count - 1 |
-- 作者:hanlingli111999 -- 发布时间:2020/11/14 16:36:00 -- 老师,打印表预览成这样了,咋整 此主题相关图片如下:y1$20h~}cvvt%hk4_bjkw05.png |
-- 作者:有点蓝 -- 发布时间:2020/11/14 16:57:00 -- 其它使用tb.Cols的地方都相应改为使用ColNames |
-- 作者:hanlingli111999 -- 发布时间:2020/11/14 17:00:00 -- 谢谢老师 |
-- 作者:hanlingli111999 -- 发布时间:2020/11/14 17:14:00 -- 修改后有错误提示 此主题相关图片如下:ntd_}dwofsd@67_{c}~~o)1.png |