此主题相关图片如下:1.png
foxtable的垂直分组同一个字段选了2次,生成统计表时不会报错,但是我自己实现的简易交叉统计就有这样的问题,
''定义数据三个统计1\2\3的数据字典,便于引用显示值
Dim dmp1 = Tables("统计1").cols("分组列").DataMap
Dim dmp2 = Tables("统计2").cols("分组列").DataMap
Dim b As New SQLCrossTableBuilder("统计表1","person")
''数据库指定
b.C
''设置水平分组
Dim count1 As Integer = 0
For Each r As Row In Tables("统计1").Rows
If r.IsNull("分组列")=False Then
If r.IsNull("日期分组")=False Then
b.HGroups.AddDef(r("分组列"), DateGroupEnum.Year, r("标题") )
Else
b.HGroups.AddDef(r("分组列"),r("标题") )'添加列用于水平分组
End If
Else
count1 = count1 +1
Continue For
End If
Next
''判断是否没有选择水平分组列
If count1= 0 OrElse count1 = Tables("统计1").Rows.Count Then
MessageBox.Show("请选择水平分组列", "提示", MessageBoxButtons.ok, MessageBoxIcon.Information)
Return
End If
''设置垂直分组 count判断的是为空的列
Dim count As Integer = 0
For Each r As Row In Tables("统计2").Rows
If r.IsNull("分组列")=False Then
count=count+1
End If
Next
''判断是否没有选择垂直分组列
If count = 0 OrElse count = Tables("统计2").Rows.Count Then
MessageBox.Show("请选择垂直分组列", "提示", MessageBoxButtons.ok, MessageBoxIcon.Information)
Return
End If
''如果只有一组垂直分组列,就给加模式
If count=1 Then
For Each r As Row In Tables("统计2").Rows
If r.IsNull("分组列") =False AndAlso r.IsNull("日期分组") Then
r("模式") =dmp2( r("分组列")) & "_{0}"
b.VGroups.AddDef(r("分组列"), r("模式"))
Exit For
End If
Next
Else
For Each r As Row In Tables("统计2").Rows
If r.IsNull("分组列")=False Then
If r.IsNull("模式")=False Then
b.VGroups.AddDef( r("分组列"), r("模式"))
Else
b.VGroups.AddDef(r("分组列")) '添加列用于垂直分组
End If
End If
Next
End If
'
''设置统计
''避免用户跳过几行开始输入的问题
For Each r As Row In Tables("统计2").Rows
If r.IsNull("分组列") =False Then
b.Totals.AddDef(r("分组列"), AggregateEnum.Count) '添加列用于统计
Exit For
End If
Next
''设置统计选项
If e.Form.Controls("CheckBox1").Checked = True Then '水平方向生成汇总
b.HorizontalTotal = True
End If
If e.Form.Controls("CheckBox2").Checked = True Then '垂直方向生成汇总
b.VerticalTotal = True
End If
这是为啥呀,上面是我的代码