请教大师:
按下面的代码打印单据,仅单据数量与选择行相符,但是单据号都是第一张的单据号,全部单据内容相同,需要如何修正?
Dim tb As Table = Tables("存货账")
For nr As Integer = tb.TopRow To tb.BottomRow
Dim r As Row = tb.Current
Dim chk As WinForm.CheckBox = Forms("存货明细").Controls("CheckBox2")
Dim sq As String = "[出入类型] = '" & r("出入类型") & "' AND [单据号] = '" & r("单据号") & "'"
Dim Book As New XLS.Book(ProjectPath & "Attachments\采购入库单.xls")
Dim fl As String = ProjectPath & "Reports\采购单.xls"
book.AddDataTable("存货账","ERP","Sel ect * from {存货账} where " & sq)
Book.Build()
Book.Sheets(0).Rows.RemoveAt(0) '删除第一行,Excel报表的第一行通常是标记行
Book.Sheets(0).PrintSetting.CenterVertical = True
Book.Sheets(0).PrintSetting.CenterHorizontal = True
'Book.Sheets(0).PrintSetting.PrintHeaders = True
Book.Save(fl)
Dim Proc As New Process
Proc.File = fl
If chk.Checked Then
Proc.Verb = "Print" '指定动作
End If
Proc.Start()
Next
tb.Focus
Return "OK"