Dim Book As New XLS.Book(ProjectPath & "Attachments\年接单发货统计表.xls")
Dim fl As String = ProjectPath & "Reports\年接单发货统计表.xls"
Dim b As New SQLCrossTableBuilder("接单发货数量统计", "接单登记")
b.C
b.AddTable("接单登记", "接单单号", "接单明细", "接单单号")
b.HGroups.AddDef("产品名称") '添加客户列用于水平分组
b.HGroups.AddDef("规格型号") '添加客户列用于水平分组
'b.VGroups.AddDef("接单日期", DateGroupEnum.Year, "{0}年") '添加日期列用于垂直分组,按年分组
b.VGroups.AddDef("接单日期", "{0}月") '添加日期列用于垂直分组,按月分组
b.Totals.AddDef("销售数量", "销售数量")
b.Totals.AddExp("已发货数量", "发货数量")
b.Totals.AddExp("未发货数量", "销售数量 - 发货数量", "未发货数量")
b.HorizontalTotal = True
Dim dt As DataTable = b.Build(True)
Dim Sheet As XLS.Sheet = Book.Sheets(0)
For Each dc As DataCol In dt.DataCols
' If dc.Caption Like "*月" Then
Dim i As Integer = (Val(dc.Caption) - 1) * 3 + 3
If dc.Caption Like "*销售数量" Then
Sheet(5, i + 1).Value = "[" & dc.Name & "]"
ElseIf dc.Caption Like "*未发货数量" Then
Sheet(5, i + 3).Value = "[" & dc.Name & "]"
ElseIf dc.Caption Like "*已发货数量" Then
Sheet(5, i + 2).Value = "[" & dc.Name & "]"
End If
' End If
Next
book.AddDataTable("接单发货数量统计", dt) '添加临时表
Book.Build()
Book.Save(fl)
Dim Proc As New Process
Proc.File = fl
Proc.Start()
生成的报表
此主题相关图片如下:微信截图.png
报表模板
此主题相关图片如下:模板.png