还是上次那案例。
Dim Values() As String = {"总分"}
Dim s1() As String = New String() {"总分"}
Dim lm1s() As String = {"年级","类别","单位代码"}
Dim lm2s() As String = {"单位","项目"}
Dim dt As Table = Tables("成绩库")
Dim km1s() As String = {"语文","数学","英语"}
Dim km2s() As String = {"物理","化学","生物","政治","历史","地理"}
Dim tjnj As String = "2020"
Dim tjlb As String = "4期"
For Each Value As String In Values
'建表
Dim bm As String = "高" & tjnj & "级" & tjlb & "市级重点有效分及贡献率统计表"
Dim dtb As New DataTableBuilder(bm)
For Each lm1 As String In lm1s
dtb.AddDef(""& lm1 &"",Gettype(String),8)
Next
For Each lm2 As String In lm2s
dtb.AddDef(""& lm2 &"",Gettype(String),8)
Next
For Each bb As String In DataTables("目标设置").GetValues("部别", "[年级]= '" & tjnj & "'And 类别 = '" & tjlb & "'")
dtb.AddDef("总分"& bb ,Gettype(Double),"","总分上线_"& bb & "")
Next
For Each km1 As String In km1s
For Each bb As String In DataTables("目标设置").GetValues("部别", "[年级]= '" & tjnj & "'And 类别 = '" & tjlb & "'")
dtb.AddDef( bb & km1 ,Gettype(Double),"", km1 &"_"& bb )
Next
Next
For Each km2 As String In km2s
dtb.AddDef(""& km2 &"",Gettype(Double),"")
Next
dtb.Build()
'表处理
Tables( "高" & tjnj & "级" & tjlb & "市级重点有效分及贡献率统计表").SetHeaderRowHeight(35,35) '表名的标题行的行高
Tables( "高" & tjnj & "级" & tjlb & "市级重点有效分及贡献率统计表").DefaultRowHeight = 35 '设置默认的行高
Dim str As String = ""
For Each lm1 As String In lm1s
str = str & "|" & lm1 & "|40"
Next
For Each lm2 As String In lm2s
str = str & "|" & lm2 & "|60"
Next
For Each bb As String In DataTables("目标设置").GetValues("部别", "[年级]= '" & tjnj & "'And 类别 = '" & tjlb & "'")
For Each lm1 As String In lm1s
Tables( "高" & tjnj & "级" & tjlb & "市级重点有效分及贡献率统计表").Cols(""& lm1 &"").TextAlign = TextAlignEnum.Center
Next
For Each lm2 As String In lm2s
Tables( "高" & tjnj & "级" & tjlb & "市级重点有效分及贡献率统计表").Cols(""& lm2 &"").TextAlign = TextAlignEnum.Center
Next
Tables( "高" & tjnj & "级" & tjlb & "市级重点有效分及贡献率统计表").Cols("总分"& bb ).TextAlign = TextAlignEnum.Center
str = str & "|总分" & bb & "|42"
Next
For Each bb As String In DataTables("目标设置").GetValues("部别", "[年级]= '" & tjnj & "'And 类别 = '" & tjlb & "'")
For Each km1 As String In km1s
str = str & "|"& bb & km1 &"|40"
Next
Next
For Each km2 As String In km2s
str = str & "|" & km2 & "|40"
Next
Tables( "高" & tjnj & "级" & tjlb & "市级重点有效分及贡献率统计表").SetColVisibleWidth("" & str.trim("|"))
'统计
Next
StatusBar.Reset
StatusBar.DefaultMessage = "统计完毕!"
Tables("成绩库").ResumeRedraw
[此贴子已经被作者于2019/11/14 11:35:32编辑过]