以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  如何进行按月分类汇总  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=64935)

--  作者:youngling
--  发布时间:2015/3/5 12:41:00
--  如何进行按月分类汇总

请问要如何编写专业报表的代码实现以下的汇总效果?

 

 


图片点击可在新窗口打开查看此主题相关图片如下:按月分类汇总.bmp
图片点击可在新窗口打开查看

--  作者:Bin
--  发布时间:2015/3/5 14:05:00
--  
你可以先生成这样的交叉统计表,再基于这个表生成专业报表

参考专业报表表格部分http://www.foxtable.com/help/topics/1199.htm



--  作者:youngling
--  发布时间:2015/3/5 15:53:00
--  
可以问下怎么生成交叉统计表吗?
--  作者:有点甜
--  发布时间:2015/3/5 15:54:00
--  

http://www.foxtable.com/help/topics/0165.htm

 


--  作者:youngling
--  发布时间:2015/3/5 17:31:00
--  


图片点击可在新窗口打开查看此主题相关图片如下:123.bmp
图片点击可在新窗口打开查看

完成了,可是生产的报表里面的表头上的月份没有了,该怎么改下呀?谢谢!

 

代码如下:

 

Dim g As New CrossTableBuilder("统计表1", DataTables("订单明细表"))
Dim dt As DataTable
g.HGroups.AddDef("客户产品号")
g.VGroups.AddDef("下单日期", "{0}月")
g.Totals.AddDef("订货数量", "订货数量")
g.Totals.AddDef("未税总价", "未税总价")
g.Decimals = 2
g.Build()
MainTable = Tables("统计表1")

dt = g.Build(True)
Dim doc As New PrintDoc
Dim rt As New prt.RenderTable
Dim Count As Integer = 0
For Each Col As DataCol In Dt.DataCols
    rt.Cells(0,Count).Text = Col.Name
    For r As Integer = 0 To dt.DataRows.Count - 1
        rt.Cells(r +1,Count).Text = dt.DataRows(r)(Col.Name)
    Next
    Count = Count + 1
Next
rt.Style.Gridlines.All = New prt.Linedef(Color.Gray)
rt.CellStyle.Spacing.All = 1
rt.Rows(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center
doc.Body.Children.Add(rt)
doc.Preview()


--  作者:有点甜
--  发布时间:2015/3/5 17:34:00
--  
没有的,就用代码动态添加进去,具体问题,请上传例子。
--  作者:有点甜
--  发布时间:2015/3/5 17:51:00
--  

Dim g As New CrossTableBuilder("统计表1", DataTables("订单明细表"))
Dim dt As DataTable
g.HGroups.AddDef("客户产品号")
g.VGroups.AddDef("下单日期", "{0}月")
g.Totals.AddDef("订货数量", "订货数量")
g.Totals.AddDef("未税总价", "未税总价")
g.Decimals = 2

dt = g.Build(True)
Dim doc As New PrintDoc
Dim rt As New prt.RenderTable
Dim Count As Integer = 0
For Each Col As DataCol In Dt.DataCols
    If count > 0 Then
        If Col.Caption.StartsWith(count) = False Then
            For i As Integer = count To Col.Caption.Split("月")(0) - 1
                rt.Cells(0,Count).Text = i & "月_订货数量"
                For r As Integer = 0 To dt.DataRows.Count - 1
                    rt.Cells(r +1,Count).Text = ""
                Next
                count += 1
                rt.Cells(0,Count).Text = i & "月_未税总价"
                For r As Integer = 0 To dt.DataRows.Count - 1
                    rt.Cells(r +1,Count).Text = ""
                Next
                count += 1
            Next
        End If
    End If
    rt.Cells(0,Count).Text = Col.Name
    For r As Integer = 0 To dt.DataRows.Count - 1
        rt.Cells(r +1,Count).Text = dt.DataRows(r)(Col.Name)
    Next
    Count = Count + 1
Next
rt.Style.Gridlines.All = New prt.Linedef(Color.Gray)
rt.CellStyle.Spacing.All = 1
rt.Rows(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center
doc.Body.Children.Add(rt)
doc.Preview()


--  作者:youngling
--  发布时间:2015/3/5 18:09:00
--  

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:管理项目5.table

例子已经上传了,请看下,谢谢!


--  作者:有点甜
--  发布时间:2015/3/5 19:21:00
--  

Dim g As New CrossTableBuilder("统计表1", DataTables("aa"))
Dim dt As DataTable
g.HGroups.AddDef("客户产品号")
g.VGroups.AddDef("下单日期", "{0}月")
g.Totals.AddDef("订货数量", "订货数量")
g.Totals.AddDef("未税总价", "未税总价")
g.Decimals = 2

dt = g.Build(True)

Dim doc As New PrintDoc
Dim rt As New prt.RenderTable
Dim Count As Integer = 0
For Each Col As DataCol In Dt.DataCols
    If count > 0 Then
        If Col.Caption.StartsWith(count) = False Then
msgbox(2)
            For i As Integer = count To Col.Caption.Split("月")(0) - 1
                rt.Cells(0,Count).Text = i & "月_订货数量"
                For r As Integer = 0 To dt.DataRows.Count - 1
                    rt.Cells(r +1,Count).Text = ""
                Next
                count += 1
                rt.Cells(0,Count).Text = i & "月_未税总价"
                For r As Integer = 0 To dt.DataRows.Count - 1
                    rt.Cells(r +1,Count).Text = ""
                Next
                count += 1
            Next
        End If
    End If
    rt.Cells(0,Count).Text = Col.Caption
    For r As Integer = 0 To dt.DataRows.Count - 1
        rt.Cells(r +1,Count).Text = dt.DataRows(r)(Col.Name)
    Next
    Count = Count + 1
Next
rt.Style.Gridlines.All = New prt.Linedef(Color.Gray)
rt.CellStyle.Spacing.All = 1
rt.Rows(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center
doc.Body.Children.Add(rt)
doc.Preview()

 


--  作者:youngling
--  发布时间:2015/3/5 21:09:00
--  

谢谢甜老师