--
With Tables("损益总体比率") \'隐藏部分列
.Cols(dic("主营业务收入_本月")).Visible = False
.Cols(dic("主营业务收入_累计")).Visible = False
.Cols(dic("主营业务成本_本月")).Visible = False
.Cols(dic("主营业务成本_累计")).Visible = False
.Cols("营业费用_本月").Visible = False
.Cols("营业费用_累计").Visible = False
.Cols(dic("资产减值损失_本月")).Visible = False
.Cols(dic("资产减值损失_累计")).Visible = False
.Cols("其他支出_本月").Visible = False
.Cols("其他支出_累计").Visible = False
.Cols("利润_本月").Visible = False
.Cols("利润_累计").Visible = False
End With
Dim t As Table = Tables("损益总体比率")
Dim g As Subtotalgroup \'以下为设置自定义汇总模式,b.Subtotal = True 不适用通过表达式生成的列
Dim cs As String = ""
For Each c As Col In Tables("损益总体比率").cols
If c.Visible AndAlso c.IsNumeric Then
cs &= c.name & ","
End If
Next
t.SubtotalGroups.Clear()
t.GroupAboveData = False
t.TreeVisible = False
t.SpillNode = False
g = New Subtotalgroup
g.Aggregate = AggregateEnum.Sum
g.GroupOn = "部门类型"
g.TotalOn = cs.trim(",")
g.Caption = "{0} 小计"
t.SubtotalGroups.Add(g)
g = New Subtotalgroup
g.Aggregate = AggregateEnum.Sum
g.GroupOn = "*"
g.TotalOn = cs.trim(",")
g.Caption = "总计"
t.SubtotalGroups.Add(g)
t.Subtotal()
Dim r As Row
For i As Integer = 0 To t.Rows.Count(True) - 1
r = t.Rows(i,True)
If r.IsGroup And (r(dic("主营业务收入_本月")) = 0 Or r(dic("主营业务收入_本月")) Is Nothing) Then
r("利润率_本月") = 0
r("利润率_累计") = 0
r("毛利率_本月") = 0
r("毛利率_累计") = 0
r("费用率_本月") = 0
r("费用率_累计") = 0
r("打折率_本月") = 0
r("打折率_累计") = 0
Else
r("利润率_本月") = r("利润_本月")/r(dic("主营业务收入_本月"))
r("利润率_累计") = r("利润_累计")/r(dic("主营业务收入_累计"))
r("毛利率_本月") = (r(dic("主营业务收入_本月"))-r(dic("主营业务成本_本月")))/r(dic("主营业务收入_本月"))
r("毛利率_累计") = (r(dic("主营业务收入_累计"))-r(dic("主营业务成本_累计")))/r(dic("主营业务收入_累计"))
r("费用率_本月") = r("营业费用_本月")/r(dic("主营业务收入_本月"))
r("费用率_累计") = r("营业费用_累计")/r(dic("主营业务收入_累计"))
r("打折率_本月") = r(dic("资产减值损失_本月"))/r(dic("主营业务收入_本月"))
r("打折率_累计") = r(dic("资产减值损失_累计"))/r(dic("主营业务收入_累计"))
End If
Next
上面代码有什么问题吗,我隐藏了各相关比率计算公式里的相关列后,汇总里的小计和总计都变成0了,如图
此主题相关图片如下:123.jpg