以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]打印表 “直接进行统计” 数量、金额 垂直合计或汇总 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=139320) |
-- 作者:dxjwlf -- 发布时间:2019/8/11 9:11:00 -- [求助]打印表 “直接进行统计” 数量、金额 垂直合计或汇总 Dim Names As List(Of String) = Tables("订单").DataTable.GetValues("产品") Dim doc As New PrintDocDim rt As New prt.RenderTable rt.Cells(0,0).Text = "产品" rt.Cells(0,1).Text = "订购次数" rt.Cells(0,2).Text = "数量" rt.Cells(0,3).Text = "金额" For i As integer = 0 To Names.Count -1 rt.Cells(i+1,0).Text= Names(i) rt.Cells(i+1,1).Text = Tables("订单").DataTable.Compute("Count(日期)","产品=\'" & Names(i) & "\'") rt.Cells(i+1,2).Text = Tables("订单").DataTable.Compute("Sum(数量)","产品=\'" & Names(i) & "\'") rt.Cells(i+1,3).Text = Tables("订单").DataTable.Compute("Sum(金额)","产品=\'" & Names(i) & "\'") Next rt.Style.Gridlines.All = New prt.Linedef(Color.Gray) \'灰色网格线 rt.CellStyle.Spacing.All = 1 \'内容距离网格线1毫米 rt.Rows(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'第一行内容水平居中 doc.Body.Children.Add(rt) doc.Preview() |
-- 作者:有点蓝 -- 发布时间:2019/8/11 21:52:00 -- 没看懂,到底什么问题? |
-- 作者:dxjwlf -- 发布时间:2019/8/13 6:39:00 -- [求助]打印表 “直接进行统计” 数量、金额 垂直合计或汇总 就是对统计数据 如何进行汇总。 产品 订购次数 数量 金额 XX 3 50 200 XXX 2 80 450 合计: 130 650 在编写 直接进行统计打印时 如何写 合计或汇总的代码。 [此贴子已经被作者于2019/8/13 6:42:40编辑过]
|
-- 作者:有点蓝 -- 发布时间:2019/8/13 8:44:00 -- 循环后直接合计即可 …… For i As integer = 0 To Names.Count -1 rt.Cells(i+1,0).Text= Names(i) rt.Cells(i+1,1).Text = Tables("订单").DataTable.Compute("Count(日期)","产品=\'" & Names(i) & "\'") rt.Cells(i+1,2).Text = Tables("订单").DataTable.Compute("Sum(数量)","产品=\'" & Names(i) & "\'") rt.Cells(i+1,3).Text = Tables("订单").DataTable.Compute("Sum(金额)","产品=\'" & Names(i) & "\'") Next rt.Cells(Names.Count+1,2).Text = Tables("订单").DataTable.Compute("Sum(数量)","")
rt.Cells(Names.Count+1,3).Text = Tables("订单").DataTable.Compute("Sum(金额)","") |
-- 作者:dxjwlf -- 发布时间:2019/8/13 22:03:00 -- [求助]打印表 “直接进行统计” 数量、金额 垂直合计或汇总 这个又如何 写合计呢(垂直方向) Dim dtb As New DataTableBuilder("配送单") dtb.AddDef("客户", Gettype(String), 16) dtb.AddDef("地址", Gettype(String), 20) dtb.AddDef("收货人", Gettype(String), 16) dtb.AddDef("联系电话", Gettype(String), 16) For Each prds As String() In DataTables("订单明细").GetValues("产品|规格") dtb.AddDef(prds(0)& "_" & prds(1), Gettype(String)) Next dtb.Build() For Each cus As String() In DataTables("订单").GetValues("客户名称|客户地址|收货人|联系电话","送货员= \'侯先童\'","所属乡镇") Dim dr As DataRow = DataTables("配送单").AddNew() dr("客户") = cus(0) dr("地址") = cus(1) dr("收货人") = cus(2) dr("联系电话") = cus(3) For Each prds As String() In DataTables("订单明细").GetValues("产品|规格") dr(prds(0)& "_" & prds(1))= DataTables("订单明细").Compute("Sum(数量)","客户名称 = \'" & cus(0) & "\' And [产品] = \'" & prds(0) & "\' And [规格] = \'" & prds(1) & "\'") Next Next MainTable= Tables("配送单") Dim doc As New PrintDoc \'定义一个新报表 Dim rt As New prt.RenderTable \'定义一个新表格 Dim rs As New prt.RenderText rs.Text = "侯先童配送单" &" " & Date.Today.AddDays(1) \'设置文本对象的内容 rs.Style.Spacing.Bottom = 10 \'表和和后续对象的垂直间隔为10毫米 rs.Style.Font = New Font("宋体", 20 , FontStyle.Bold) \'设置文本对象的字体 rs.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'文本内容水平居中 doc.Body.Children.Add(rs) \'将文本对象加入到表格中 Dim tb As Table = Tables("配送单") Dim hd As Integer = tb.HeaderRows \'获得表头的层数 rt.Style.Font = New Font("宋体",12) \'设置字体 rt.Style.Gridlines.All = New prt.Linedef(Color.Gray) \'灰色网格线 rt.CellStyle.Spacing.All = 0.8 \'单元格内距设为0.5毫米 rt.RowGroups(0, tb.HeaderRows).Header = prt.TableHeaderEnum.All \'利用行组功能设置表头 tb.CreateReportHeader(rt,False) \'生成表头,包括所有列 For c As Integer = 0 To tb.Cols.Count -1 \'逐列设置和填入内容 rt.Cols(c).Width = tb.Cols(c).PrintWidth \'列宽等于实际列宽 If tb.Cols(c).IsNumeric OrElse tb.Cols(c).IsDate Then \'如果是数值或日期列 rt.Cols(c).Style.TextAlignHorz = prt.AlignHorzEnum.Right \'数据水平靠右 End If For r As Integer = 0 To tb.Rows.Count -1 \'开始填入该列内容 rt.Cells(r + hd, c).Text = tb(r,c) Next Next rt.Cols(0).Width = 100 rt.Cols(1).Width = 80 rt.Cols(2).Width = 30 rt.Cols(3).Width = 50 \'rt.width = "Auto" \'表格宽度为自动,也就是等于各列设置宽度之和 \'rt.height= 40 doc.Body.Children.Add(rt) \'将表格加入到报表 doc.PageSetting.Landscape = True \'横向打印 Doc.PageSetting.LeftMargin = 10 \'设置左边距 Doc.PageSetting.RightMargin = 10 \'设置右边距 Doc.PageSetting.TopMargin = 10 \'设置上边距 Doc.PageSetting.BottomMargin = 10 \'设置下边距 doc.Preview() |
-- 作者:有点蓝 -- 发布时间:2019/8/13 22:16:00 -- 方法一样啊,没啥区别。在循环之后添加合计行 |