Category projectName[1] projectName[2] ... total<br/>
cat[1] 0 1 ??<br/>
cat[2] 2 3 ??<br/>
.. .... ..... .....<br/>
total ?? ?? ??<br/>
这是我的代码,用于显示我的projectName
和猫行类别。问题是我不知道如何在数据表中获得总和的总和值。
ExportDT.Columns.Add("Category")
For Each ProjectRow As Data.DataRow In TempProjectDT.Rows
ExportDT.Columns.Add(ProjectRow.Item("NameOfProject").ToString.Trim)
Next
Dim NewRow As Data.DataRow
Dim ComplaintDV As New Data.DataView(TempComplaintDT)
For Each CategoryRow As Data.DataRow In TempComplaintCatDT.Rows
NewRow = ExportDT.NewRow
NewRow.Item("Category") = CategoryRow.Item("Category").ToString
For nLoop As Integer = 1 To ExportDT.Columns.Count - 1
ComplaintDV.RowFilter = "ComplaintCategory='" & CategoryRow.Item("Category").ToString & "' AND NameOfProject='" & ExportDT.Columns(nLoop).ColumnName & "'"
If ComplaintDV.Count > 0 Then
NewRow.Item(ExportDT.Columns(nLoop).ColumnName) = ComplaintDV.Count
Else
NewRow.Item(ExportDT.Columns(nLoop).ColumnName) = "0"
End If
Next
ExportDT.Rows.Add(NewRow)
Next
答案 0 :(得分:1)
让我们对这个做出假设:
For i As Integer = 0 To 2
yourTable.Rows(i).Cells(2).Value = yourTable.Rows(i).Cells(0).Value + yourTable.Rows(i).Cells(1).Value
Next
它允许您计算Column3的列。 Column3将显示总和。