有窗口1,表1(A-L列)有100行,页面合集1(其中page1中的表控件是表1的A-J列,page2中的表控件是表1的A-G列,都设成了副表),预览按钮1,模板A和B,想实现当在page1(50行)时,点击按钮用模板A,在page2时(20行),点击按钮用模板B。现在是在page1时正常,但在page2时模板到是用上了,但行数却是100行,这个问题出在哪?请版主指点!Dim tb As WinForm.TabControl = e.Form.Controls("TabControl1")
Dim pg As WinForm.TabPage = tb.SelectedPage
Dim doc As PrintDoc = e.Form.GernatePrintDoc(pg)
If tb.SelectedPage.Text = "page1" Then
Dim Book As New XLS.Book(ProjectPath & "Attachments\A.xls")
Dim fl As String = ProjectPath & "Reports\A.xls"
Book.Build()
Book.Save(fl)
Dim App As New MSExcel.Application
Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open(fl)
Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1)
App.Visible = True
ShowAppWindow("A",2)
Ws.PrintPreview
App.Quit
ElseIf tb.SelectedPage.Text = "page2" Then
Dim Book As New XLS.Book(ProjectPath & "Attachments\B.xls")
Dim fl As String = ProjectPath & "Reports\B.xls"
Book.Build()
Book.Save(fl)
Dim App As New MSExcel.Application
Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open(fl)
Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1)
App.Visible = True
ShowAppWindow("B",2)
Ws.PrintPreview
App.Quit
End If