Dim f As New Filler '先填充订单统计
f.SourceTable = DataTables("订单明细表") '指定数据来源
f.SourceCols = "客户名称,型号规格,数量,发货日期" '指定数据来源列
f.Distinct = False '允许出现重复值
f.Filter = "客户名称 = '张三'"
f.DataTable = DataTables("对账单") '指定数据接收表
f.DataCols = "客户名称,型号规格,数量,发货日期" '指定数据接收列
f.Fill() '填充数据
Tables("对账单").Sort = "发货日期"
Dim drs As List(Of DataRow) = DataTables("收款明细表").Select("客户名称 = '张三'", "收款日期")
Dim idx As Integer = drs.Count - Tables("对账单").Rows.Count
If idx > 0 Then Tables("对账单").AddNew(idx)
For i As Integer = 0 To drs.Count - 1
Tables("对账单").Rows(i)("收款金额") = drs(i)("收款金额")
Tables("对账单").Rows(i)("收款日期") = drs(i)("收款日期")
Next
Dim Book As New XLS.Book(ProjectPath & "Attachments\对账单.xls")
Dim fl As String = ProjectPath & "Reports\对账单.xls"
Book.Build() '生成细节区
Book.Save(fl) '保存工作簿
Dim Proc As New Process '打开工作簿
Proc.File = fl
Proc.Start()
DataTables("对账单").DataRows.Clear