Dim b As New GroupTableBuilder("统计表",DataTables("查询表1"))
Dim dt
As fxDataSource
b.Groups.AddDef("部门名称")
b.Groups.AddDef(HZ1)
b.Totals.AddDef("金额","本年销售")
b.Filter = "年份 = "
& N1 & " and (科目编号
Like '600101%' or 科目编号 like '600102%')
And (" & filter1 & ") and 金额<>0"
dt = b.BuildDataSource()
Dim b1 As New GroupTableBuilder("统计表1",DataTables("查询表1"))
Dim dt1
As fxDataSource
b1.Groups.AddDef("部门名称")
b1.Groups.AddDef(HZ1)
b1.Totals.AddDef("金额","上年销售")
b1.Filter = "年份 = "
& N2 & " and (科目编号
Like '600101%' or 科目编号 like '600102%')
And (" & filter1 & ") and 金额<>0"
dt1 = b1.BuildDataSource()
Dim b2 As New GroupTableBuilder("统计表2",DataTables("查询表1"))
Dim dt2
As fxDataSource
b2.Groups.AddDef("开店日期",DateGroupEnum.None)
b2.Groups.AddDef("关店日期",DateGroupEnum.None)
b2.Groups.AddDef("部门名称")
b2.Groups.AddDef(HZ1)
b2.Groups.AddDef(HZ3)
b2.Totals.AddDef("金额","本年费用")
b2.Filter = "年份 = " & N1 & " and 科目编号 Like '6601%' And
(" & filter1 & ") And (" &
filter2 &
") and 金额<>0"
dt2 = b2.BuildDataSource()
Dim b3 As New GroupTableBuilder("统计表3",DataTables("查询表1"))
Dim dt3 As fxDataSource
b3.Groups.AddDef("开店日期",DateGroupEnum.None)
b3.Groups.AddDef("关店日期",DateGroupEnum.None)
b3.Groups.AddDef("部门名称")
b3.Groups.AddDef(HZ1)
b3.Groups.AddDef(HZ3)
b3.Totals.AddDef("金额","上年费用")
b3.Filter = "年份 = " & N2 & " and 科目编号 Like '6601%' And
(" & filter1 & ") And (" &
filter2 &
") and 金额<>0"
dt3 = b3.BuildDataSource()
Dim nms As String()
Dim nms1 As String()
nms =new String() {"部门名称",HZ1} '指定连接列
nms1 =new String() {"部门名称",HZ1,HZ3,"开店日期","关店日期"} '指定连接列
dt2.Combine(nms1,dt3,nms1) '将销售统计数据组合到进货统计数据
dt2.Combine(nms,dt,nms) '将销售统计数据组合到进货统计数据
dt2.Combine(nms,dt1,nms) '将销售统计数据组合到进货统计数据
Tables("店铺指标同期分析_Table1").DataSource = dt2 '将统计结果绑定到Table
Dim t2 As Table = Tables("店铺指标同期分析_Table1")
Dim n11,m11 As Double
Dim bm As String = ""
For Each r As Row In t2.Rows
If bm = r("部门名称")
Then
If r.IsNull("本年销售")
= False Then
n11 = r("本年销售")
Else
r("本年销售")
= n11
End If
If r.IsNull("上年销售")
= False Then
m11 = r("上年销售")
Else
r("上年销售")
= m11
End If
Else
bm = r("部门名称")
n11 = r("本年销售")
m11 = r("上年销售")
End If
Next
结果如下图所示
此主题相关图片如下:e8034ce2-33c2-427a-834d-c7497516ed29.png
发现只要“本年费用”列前面部分有数据,后面部分为空,那空的部分对应的“本年销售”和“上年销售”列的数据就填充不下来
希望实现“本年销售”和“上年销售”同列里每个单元格的数据都有且都是相同的,要怎么调整