以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]设置统计表的格式怎么样设置?  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=92330)

--  作者:77611471
--  发布时间:2016/11/1 8:55:00
--  [求助]设置统计表的格式怎么样设置?
Dim bd1 As New GroupTableBuilder("统计表1",DataTables("板材用料表"))
Dim dt1 As fxDataSource
bd1.Groups.AddDef("产品编号") \'根据型号分组
bd1.Totals.AddDef("金额","板材成本") \'对数量进行统计
bd1.Decimals = 2
dt1 = bd1.BuildDataSource()


Dim bd2 As New GroupTableBuilder("统计表2",DataTables("包装箱板材用量"))
Dim dt2  As fxDataSource
bd2.Groups.AddDef("产品编号") \'根据型号分组
bd2.Totals.AddDef("金额","包装箱板材成本") \'对数量进行统计
bd2.Decimals = 2
dt2 = bd2.BuildDataSource()

Dim bd3 As New GroupTableBuilder("统计表3",DataTables("油漆用量表"))
Dim dt3  As fxDataSource
bd3.Groups.AddDef("产品编号") \'根据型号分组
bd3.Totals.AddDef("单机金额","油漆成本") \'对数量进行统计

bd3.Decimals = 2
dt3 = bd3.BuildDataSource()


Dim bd4 As New GroupTableBuilder("统计表4",DataTables("BOM表"))
Dim dt4  As fxDataSource
bd4.Groups.AddDef("产品编号") \'根据型号分组
bd4.Totals.AddDef("金额","BOM成本") \'对数量进行统计
bd4.Decimals = 2
dt4 = bd4.BuildDataSource()

Dim bd5 As New GroupTableBuilder("统计表5",DataTables("订单工时成本"))
Dim dt5  As fxDataSource
bd5.Filter = "[部门] = \'木工\'"
bd5.Groups.AddDef("产品编号") \'根据型号分组
bd5.Totals.AddDef("单位工时成本","工时成本_木工") \'对数量进行统计
bd5.Decimals = 2
dt5 = bd5.BuildDataSource()

Dim bd6 As New GroupTableBuilder("统计表6",DataTables("订单工时成本"))
Dim dt6  As fxDataSource
bd6.Filter = "[部门] = \'涂装\'"
bd6.Groups.AddDef("产品编号") \'根据型号分组
bd6.Totals.AddDef("单位工时成本","工时成本_涂装") \'对数量进行统计
bd6.Decimals = 2
dt6 = bd6.BuildDataSource()

Dim bd7 As New GroupTableBuilder("统计表7",DataTables("订单工时成本"))
Dim dt7  As fxDataSource
bd7.Filter = "[部门] = \'装配\'"
bd7.Groups.AddDef("产品编号") \'根据型号分组
bd7.Totals.AddDef("单位工时成本","工时成本_装配") \'对数量进行统计
bd7.Decimals = 2
dt7 = bd7.BuildDataSource()

Dim bd8 As New GroupTableBuilder("统计表8",DataTables("订单工时成本"))
Dim dt8  As fxDataSource
bd8.Filter = "[部门] = \'五金\'"
bd8.Groups.AddDef("产品编号") \'根据型号分组
bd8.Totals.AddDef("单位工时成本","工时成本_五金") \'对数量进行统计
bd8.Decimals = 2
dt8 = bd8.BuildDataSource()

Dim bd9 As New GroupTableBuilder("统计表9",DataTables("订单工时成本"))
Dim dt9  As fxDataSource
bd9.Filter = "[部门] = \'光电\'"
bd9.Groups.AddDef("产品编号") \'根据型号分组
bd9.Totals.AddDef("单位工时成本","工时成本_光电") \'对数量进行统计
bd9.Decimals = 2
dt9 = bd9.BuildDataSource()



dt1.Combine("产品编号",dt2,"产品编号") \'
dt1.Combine("产品编号",dt3,"产品编号")
dt1.Combine("产品编号",dt4,"产品编号")
dt1.Combine("产品编号",dt5,"产品编号")
dt1.Combine("产品编号",dt6,"产品编号")
dt1.Combine("产品编号",dt7,"产品编号")
dt1.Combine("产品编号",dt8,"产品编号")
dt1.Combine("产品编号",dt9,"产品编号")


Tables("统计_Table1").DataSource = dt1 

With DataTables("统计_Table1").DataCols  
    .Add("工时成本_小计",Gettype(Integer), "IsNull([工时成本_木工],0) + ISNULL([工时成本_涂装],0) + ISNULL([工时成本_装配],0)  + ISNULL([工时成本_五金],0)+ ISNULL([工时成本_光电],0)   ")
   
End With



With DataTables("统计_Table1").DataCols  
    .Add("合计",Gettype(Integer), "IsNull([板材成本],0) + ISNULL([包装箱板材成本],0) + ISNULL([油漆成本],0)  + ISNULL([BOM成本],0)+ ISNULL([工时成本_小计],0)   ")
   
End With


以上代码,我想设置每个格里的数据都居中,数值都带两位小数,如何设置?



--  作者:有点蓝
--  发布时间:2016/11/1 9:27:00
--  
参考:http://www.foxtable.com/webhelp/scr/1786.htm


For Each c As Col In Tables("表A").Cols
    c.TextAlign  = TextAlignEnum.Center
    If c.IsNumeric Then
        c.DataCol.SetFormat("0.00")
    End If
Next