你的代码只统计数字列数据,如果想如exce那样如果是字符列或字符与数字列并存,只统计选择区域单元格内有效个数,我这样写一样不能统计,应如何写呢?这是一个很方便实用的功能,希望你们的软件同样有,如果软件自带此功能,我们就不用费劲自己编代码了。
'以下代码用于在状态栏显示自动计算结果:
With e.Table
If .TopRow = .BottomRow AndAlso .LeftCol = .RightCol Then
Return
End If
Dim bb As Boolean = True
For c As Integer = .LeftCol To .RightCol
If .Cols(c).IsNumeric = False Then
bb = False
Exit For
End If
Next
If bb = False Then
RibbonMenu.StatusBar.Message3 = "个数:" & .Aggregate(AggregateEnum.Count, .TopRow,.LeftCol,.BottomRow,.RightCol) & " 累计:" & 0 & " 平均:" & 0 & " 最大值:" & 0 & " 最小值:" & 0
Else
RibbonMenu.StatusBar.Message3 = "个数:" & .Aggregate(AggregateEnum.Count, .TopRow,.LeftCol,.BottomRow,.RightCol) & " 累计:" & .Aggregate(AggregateEnum.Sum,.TopRow,.LeftCol,.BottomRow,.RightCol) & " 平均:" & .Aggregate(AggregateEnum.Average,.TopRow,.LeftCol,.BottomRow,.RightCol) & " 最大值:" & .Aggregate(AggregateEnum.Max,.TopRow,.LeftCol,.BottomRow,.RightCol) & " 最小值:" & .Aggregate(AggregateEnum.Min,.TopRow,.LeftCol,.BottomRow,.RightCol)
End If
End With
RibbonMenu.StatusBar.Refresh
[此贴子已经被作者于2023/10/19 17:53:49编辑过]