Rss & SiteMap
Foxtable(狐表) http://www.foxtable.com
师傅你好:请帮我加代码
1、在开始日期和结束日期之间统计不同品种的数量;
2、现在有底行合计,请帮我加一列合计代码;
Dim khs As List(of String) = DataTables("出口处理").GetUniqueValues("用盘单位 > ''", "用盘单位")
Dim pds As List(of String) = DataTables("出口处理").GetUniqueValues("品种1 > ''", "品种1")
Dim dt AS New DataTableBuilder("处理数量")
dt.AddDef("客户", Gettype(String), 32)
For i As Integer = 2 To 8
Dim lst As List(of String) = DataTables("出口处理").GetUniqueValues("品种" & i & " > ''", "品种" & i)
For Each nm AS String In Lst
If pds.Contains(nm) = False
pds.Add(nm)
End If
Next
Next
For Each pd As String In pds
dt.AddDef(pd, Gettype(Integer))
Next
dt.Build
Dim tb AS Table = Tables("处理数量")
Dim Sum AS Integer
For Each kh As String In khs
Dim r As Row = tb.AddNew()
r("客户") = kh
For Each pd As String In pds
sum = 0
For i As Integer = 1 To 8
sum = sum + DataTables("出口处理").Compute("Sum(数量" & i & ")", "品种" & i & " = '" & pd & "' And 用盘单位 = '" & kh & "'")
Next
r(pd) = sum
Next
Next
Dim sr As Row = tb.AddNew()
sr("客户") = "合计"
For Each pd As String In pds
sum = 0
For Each r AS Row In tb.Rows
sum = sum + r(pd)
Next
sr(pd) = sum
Next
谢谢!
最后面加上:
dt.DataCols.Add("合计",Gettype(Double))
Dim sum As Double
For Each dr As DataRow In dt.DataRows
sum = 0
For Each dc As DataCol In dt.DataCols
If dc.IsNumeric Then
sum = dr(dc.name) + sum
End If
Next
dr("合计") = sum
Next
加的代码出现错误:
编译错误:“datacols”不是"datatablebuildqr"
错误代码:dt.DataCols.Add("合计",Gettype(Double))
Dim tbl As DataTable = DataTables("处理数量")
tbl.DataCols.Add("合计",Gettype(Double))
Dim sum As Double
For Each dr As DataRow In tbl.DataRows
sum = 0
For Each dc As DataCol In tbl.DataCols
If dc.IsNumeric Then
sum = dr(dc.name) + sum
End If
Next
dr("合计") = sum
Next
又出现了错误
当前块中已局部变量:“SUM”
错误代码:Dim sum As Double
既然前面定义了,那就不要定义变量sum,或者换个名字都行。
Dim tbl As DataTable = DataTables("处理数量")
tbl.DataCols.Add("合计",Gettype(Double))
For Each dr As DataRow In tbl.DataRows
sum = 0
For Each dc As DataCol In tbl.DataCols
If dc.IsNumeric Then
sum = dr(dc.name) + sum
End If
Next
dr("合计") = sum
Next
就是顶部代码