请各位老师指点一下:
问题一:下列解法能否更进一步优化?
1、6次填充数据过程能否用循环语句或其它更优语句代替?
2、能否精简过程,直接在”另表”中得到结果,不经过”统计数据”这样的过渡表,行吗?
问题二:是否还有其它解法?
‘将”表2”中的数据填充到”另表”中
DataTables("另表").DataRows.Clear()
Syscmd.Project.Compact(False)
‘填充表2第一组数据到另表
dim f1 As New Filler
f1.SourceTable = DataTables("表2")
f1.SourceCols = "名称1,数量1"
f1.Distinct = True
f1.DataTable = DataTables("另表")
f1.DataCols = "名称,数量"
f1.Fill()
‘填充表2第二组数据到另表
dim f2 As New Filler
f2.SourceTable = DataTables("表2")
f2.SourceCols = "名称2,数量2"
f2.Distinct= False
f2.DataTable = DataTables("另表")
f2.DataCols = "名称,数量"
f2.Fill()
‘填充表2第三组数据到另表
dim f3 As New Filler
f3.SourceTable = DataTables("表2")
f3.SourceCols = "名称3,数量3"
f3.Distinct= False
f3.DataTable = DataTables("另表")
f3.DataCols = "名称,数量"
f3.Fill()
‘填充表2第四组数据到另表
dim f4 As New Filler
f4.SourceTable = DataTables("表2")
f4.SourceCols = "名称4,数量4"
f4.Distinct= False
f4.DataTable = DataTables("另表")
f4.DataCols = "名称,数量"
f4.Fill()
‘填充表2第五组数据到另表
dim f5 As New Filler
f5.SourceTable = DataTables("表2")
f5.SourceCols = "名称5,数量5"
f5.Distinct= False
f5.DataTable = DataTables("另表")
f5.DataCols = "名称,数量"
f5.Fill()
‘填充表2第六组数据到另表
dim f6 As New Filler
f6.SourceTable = DataTables("表2")
f6.SourceCols = "名称6,数量6"
f6.Distinct= False
f6.DataTable = DataTables("另表")
f6.DataCols = "名称,数量"
f6.Fill()
‘对”另表”中数据进行分组统计
Dim b As New GroupTableBuilder("统计数据",DataTables("另表"))
b.Groups.AddDef("名称")
b.Totals.AddDef("数量")
b.VerticalTotal = True
b.Build
Maintable = Tables("统计数据")