先遍历选定的行,获得每一行的主键值,合成一个条件: 主键 in (值1,值2,值3) 在Build之前,修改模板的条件:
Dim Book As New XLS.Book(ProjectPath & "Attachments\出库单.xls") '打开模板 Dim Sheet As XLS.Sheet = Book.Sheets(0) Sheet(x,y).Value = 合成的条件 Book.Build() '生成细节区 Book.Save("c:\reports\test.xls") '保存工作簿 Dim Proc As New Process '打开工作簿 Proc.File = "c:\reports\test.xls" Proc.Start()