多表excel 报表 出错-表单属于其他工作簿Dim CPMS As List(OF String) = DataTables("订单").GetValues("产品","[产品] is not null")
Dim F1 As String = ProjectPath & "Reports\订单打印.xls"
For Each CPM As String In CPMS
Dim k As Integer = 1
Dim Book1 As New XLS.Book(ProjectPath & "Attachments\订单.xls")
Dim Book2 As New XLS.Book(ProjectPath & "Attachments\订单模板.xls")
Dim Sheet = Book1.Sheets(0)
sheet.name = CPM
Book2.Sheets.Add(Sheet)
'Book2.Sheets.insert(k,Sheet)
Book2.Save(ProjectPath & "Attachments\订单模板.xls")
Dim Book3 As New XLS.Book(ProjectPath & "Attachments\订单模板.xls") '打开模板
Dim sh2 As XLS.Sheet = Book3.Sheets(k)
sh2(3,9).Value =" < [产品] = '" & cpm & "' > " '修改模板,加入筛选条件
k=k+1
Next
Dim Book4 As New XLS.Book(ProjectPath & "Attachments\订单模板.xls") '打开模板
Book4.Build() '生成细节区
Book4.Save(F1) '保存工作簿
Dim Proc As New Process '打开工作簿
Proc.File = F1
Proc.Start()
[此贴子已经被作者于2019/3/1 12:16:32编辑过]