以示例文件统计演示文件为例,在成绩分布表增加一列缺考
DataColChanged事件代码
Dim dr As DataRow = e.DataRow
Dim dt As DataTable =DataTables("学生成绩")
If e.DataCol.Name = "科目" And dr.IsNull("科目") = False Then
dr("最高分") = dt.Compute("Max(" & dr("科目") & ")")
dr("最低分") = dt.Compute("Min(" & dr("科目") & ")")
dr("平均分") = dt.Compute("Avg(" & dr("科目") & ")")
dr("缺考") = dt.Compute("Count(姓名)", dr("科目") & " Is Null")
dr("分布_60分以下") = dt.Compute("Count(姓名)", dr("科目") & " < 60")
dr("分布_60分以上") = dt.Compute("Count(姓名)", dr("科目") & " >= 60 And " & dr("科目") & " < 70" )
dr("分布_70分以上") = dt.Compute("Count(姓名)", dr("科目") & " >= 70 And " & dr("科目") & " < 80" )
dr("分布_80分以上") = dt.Compute("Count(姓名)", dr("科目") & " >= 80 And " & dr("科目") & " < 90" )
dr("分布_90分以上") = dt.Compute("Count(姓名)", dr("科目") & " >= 90 And " & dr("科目") & " < 100" )
dr("分布_100分以上") = dt.Compute("Count(姓名)", dr("科目") & " >= 100 And " & dr("科目") & " < 110" )
dr("分布_110分以上") = dt.Compute("Count(姓名)", dr("科目") & " >= 110 And " & dr("科目") & " < 120" )
dr("分布_120分以上") = dt.Compute("Count(姓名)", dr("科目") & " >= 120 And " & dr("科目") & " < 130" )
dr("分布_130分以上") = dt.Compute("Count(姓名)", dr("科目") & " >= 130" )
End If