以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 下面这个汇总什么和统计合一起 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=189282) |
-- 作者:qazlinle6 -- 发布时间:2023/11/21 22:15:00 -- 下面这个汇总什么和统计合一起 \'根据输入的年月,统计各产品的销售数量 Dim g As New SQLGroupTableBuilder("统计表1", "标签明细") \'这里使用后台统计,如果数据已经全部加载可以直接用GroupTableBuilder g.C \'外部数据表的话要指定数据源名称 g.Groups.AddDef("对账品名", "对账品名") g.Groups.AddDef("库存店名") g.Totals.AddDef("数量") g.Totals.AddDef("金重") g.Totals.AddDef("总重量") g.Totals.AddDef("标签价格") g.VerticalTotal = True g.Filter = "库存备注 = \'柜台货\' And 库存店名 In (\'周六福(1)\',\'周六福(4)\',\'周六福(7)\') And 对账品名 In (\'5G黄金\', \'金Au750\', \'足金999‰硬金\', \'足金999‰\', \'足金999.9‰\',\'足金999.9非素\') "\'后台统计才可以使用这种表达式的哦 With wb.AddTable("", "Table1") .CreateFromDataTable(g.Build(True)) Dim nms() As String Dim qty As Integer Dim amt As Double .Head.AddRow( "对账品名", "库存店名", "数量", "金重", "总重量", "标签价格") For i As Integer = 0 To g.DataRows.count - 1 Dim r As DataRow = g.DataRows(i) If i > 0 Then Dim lr As DataRow = g.DataRows(i - 1) If r("库存店名") <> lr("库存店名") Then qty = g.compute("sum(数量)", "对账品名=\'" & lr("对账品名") & "\' And 库存店名= \'" & lr("库存店名") & "\'") amt = g.compute("sum(金重)", "对账品名=\'" & lr("对账品名") & "\' And 库存店名= \'" & lr("库存店名") & "\'") With .Body.AddRow() .Attribute = "style=\'background-color:#F0FFFF\'" .AddCell("小计 " & lr("库存店名"), "colspan=\'3\'") .AddCells(qty, "", amt, "") End With End If If r("对账品名") <> lr("对账品名") Then qty = g.compute("sum(数量)", "对账品名=\'" & lr("对账品名") & "\'") amt = g.compute("sum(金重)", "对账品名=\'" & lr("对账品名") & "\'") With .Body.AddRow() .Attribute = "style=\'background-color:#FFFFE0\'" .AddCell("小计 " & lr("对账品名"), "colspan=\'3\'") .AddCells(qty, "", amt, "") End With End If End If .Body.AddRow( r("对账品名"), r("库存店名"), r("数量"), r("金重"), r("总重量"), r("标签价格")) Next qty = g.compute("sum(数量)") amt = g.compute("sum(金重)") If EndRow >= Count Then .Body.AddRow("总计", "", "", qty, "", amt, "").Attribute = "style=\'background-color:#98FB98\'" End If End With 下面这个汇总什么和统计合一起 |
-- 作者:有点蓝 -- 发布时间:2023/11/21 22:40:00 -- …… With wb.AddTable("", "Table1") dim dt as datatable = g.Build(True) Dim nms() As String Dim qty As Integer Dim amt As Double .Head.AddRow( "对账品名", "库存店名", "数量", "金重", "总重量", "标签价格") For i As Integer = 0 To dt .DataRows.count - 1 Dim r As DataRow = dt .DataRows(i) If i > 0 Then Dim lr As DataRow = dt .DataRows(i - 1) If r("库存店名") <> lr("库存店名") Then qty = dt .compute("sum(数量)", "对账品名=\'" & lr("对账品名") & "\' And 库存店名= \'" & lr("库存店名") & "\'") …… |