With wb.AddTable("","Table1")
Dim nms() As String
Dim qty As Double
Dim amt As Double
.Head.AddRow("No.","年","月份","岗位工资","岗位系数","应发工资","实发工资")
For i As Integer = 0 To dt.DataRows.count - 1
Dim r As DataRow = dt.DataRows(i)
If i > 0 Then
Dim lr As DataRow = dt.DataRows(i-1)
If r("年") <> lr("年") Then
qty = dt.compute("sum(应发工资)","年= '" & lr("年") & "'")
amt = dt.compute("sum(实发工资)","年= '" & lr("年") & "'")
With .Body.AddRow()
.Attribute = "style='background-color:#F0FFFF'"
.AddCell(lr("年") & "小计 " ,"colspan='3'")
.AddCells("","",qty,amt)
End With
End If
End If
.Body.AddRow(r("NO."),r("年"),r("月份"),r("岗位工资"),r("岗位系数"),r("应发工资"),r("实发工资"))
Next
Dim r1 As DataRow = dt.DataRows(dt.DataRows.count - 1)
qty = dt.compute("sum(应发工资)","年= '" & r1("年") & "'")
amt = dt.compute("sum(实发工资)","年= '" & r1("年") & "'")
With .Body.AddRow()
.Attribute = "style='background-color:#F0FFFF'"
.AddCell(r1("年") & "小计 " ,"colspan='3'")
.AddCells("","",qty,amt)
End With
qty = dt.compute("sum(应发工资)")
amt = dt.compute("sum(实发工资)")
.Body.AddRow("总计","","","","",qty,amt).Attribute = "style='background-color:#98FB98'"
End With
……