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 = "报名登记汇总" Then
Dim dlg As New SaveFileDialog '定义一个新的SaveFileDialog
dlg.Filter= "excel|*.xls" '设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
MessageBox.Show("你要保存为:" & dlg.FileName,"提示") '提示用户选择的文件
Dim Book As New XLS.Book(ProjectPath & "Attachments\报名登记汇总.xls")
Book.Build() '生成细节区
Book.Save(dlg.FileName) '保存工作簿
MessageBox.Show("保存成功" )
End If
ElseIf tb.SelectedPage.Text = "中高级工资审" Then
Dim dlg As New SaveFileDialog '定义一个新的SaveFileDialog
dlg.Filter= "excel|*.xls" '设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
MessageBox.Show("你要保存为:" & dlg.FileName,"提示") '提示用户选择的文件
Dim Book As New XLS.Book(ProjectPath & "Attachments\报名资格验审.xls")
Book.Build() '生成细节区
Book.Save(dlg.FileName) '保存工作簿
MessageBox.Show("保存成功" )
End If
ElseIf tb.SelectedPage.Text = "中高级工考核" Then
Dim dlg As New SaveFileDialog '定义一个新的SaveFileDialog
dlg.Filter= "excel|*.xls" '设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
MessageBox.Show("你要保存为:" & dlg.FileName,"提示") '提示用户选择的文件
Dim Book As New XLS.Book(ProjectPath & "Attachments\中高级工考核.xls")
Book.Build() '生成细节区
Book.Save(dlg.FileName) '保存工作簿
MessageBox.Show("保存成功" )
End If
ElseIf tb.SelectedPage.Text = "技师高技资审" Then
Dim dlg As New SaveFileDialog '定义一个新的SaveFileDialog
dlg.Filter= "excel|*.xls" '设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
MessageBox.Show("你要保存为:" & dlg.FileName,"提示") '提示用户选择的文件
Dim Book As New XLS.Book(ProjectPath & "Attachments\报名资格验审.xls")
Book.Build() '生成细节区
Book.Save(dlg.FileName) '保存工作簿
MessageBox.Show("保存成功" )
End If
ElseIf tb.SelectedPage.Text = "技师高技理论" Then
Dim dlg As New SaveFileDialog '定义一个新的SaveFileDialog
dlg.Filter= "excel|*.xls" '设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
MessageBox.Show("你要保存为:" & dlg.FileName,"提示") '提示用户选择的文件
Dim Book As New XLS.Book(ProjectPath & "Attachments\技师高技理论.xls")
Book.Build() '生成细节区
Book.Save(dlg.FileName) '保存工作簿
MessageBox.Show("保存成功" )
End If
ElseIf tb.SelectedPage.Text = "技师高技实潜" Then
Dim dlg As New SaveFileDialog '定义一个新的SaveFileDialog
dlg.Filter= "excel|*.xls" '设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
MessageBox.Show("你要保存为:" & dlg.FileName,"提示") '提示用户选择的文件
Dim Book As New XLS.Book(ProjectPath & "Attachments\技师高技实潜.xls")
Book.Build() '生成细节区
Book.Save(dlg.FileName) '保存工作簿
MessageBox.Show("保存成功" )
End If
ElseIf tb.SelectedPage.Text = "上会评审汇总" Then
Dim dlg As New SaveFileDialog '定义一个新的SaveFileDialog
dlg.Filter= "excel|*.xls" '设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
MessageBox.Show("你要保存为:" & dlg.FileName,"提示") '提示用户选择的文件
Dim Book As New XLS.Book(ProjectPath & "Attachments\参评汇总.xls")
Book.Build() '生成细节区
Book.Save(dlg.FileName) '保存工作簿
MessageBox.Show("保存成功" )
End If
ElseIf tb.SelectedPage.Text = "证书编号汇总" Then
Dim dlg As New SaveFileDialog '定义一个新的SaveFileDialog
dlg.Filter= "excel|*.xls" '设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
MessageBox.Show("你要保存为:" & dlg.FileName,"提示") '提示用户选择的文件
Dim Book As New XLS.Book(ProjectPath & "Attachments\证书编号汇总.xls")
Book.Build() '生成细节区
Book.Save(dlg.FileName) '保存工作簿
MessageBox.Show("保存成功" )
End If
ElseIf tb.SelectedPage.Text = "地市公司统计" Then
Dim dlg As New SaveFileDialog '定义一个新的SaveFileDialog
dlg.Filter= "excel|*.xls" '设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
MessageBox.Show("你要保存为:" & dlg.FileName,"提示") '提示用户选择的文件
Dim Book As New XLS.Book(ProjectPath & "Attachments\地市公司统计.xls")
Book.Build() '生成细节区
Book.Save(dlg.FileName) '保存工作簿
MessageBox.Show("保存成功" )
End If
ElseIf tb.SelectedPage.Text = "鉴定统计报表" Then
Dim dlg As New SaveFileDialog '定义一个新的SaveFileDialog
dlg.Filter= "excel|*.xls" '设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
MessageBox.Show("你要保存为:" & dlg.FileName,"提示") '提示用户选择的文件
Dim Book As New XLS.Book(ProjectPath & "Attachments\鉴定统计报表.xls")
Book.Build() '生成细节区
Book.Save(dlg.FileName) '保存工作簿
MessageBox.Show("保存成功" )
End If
End If
1、上述是“导出”按钮代码,负责2个表的导出(在页面集合中,有几个页面是绑定其中1个表的副表),先前没什么数据的时候,貌似还正常,现在导入了数据,大概有10万来行,问题来了,点击没反应,最后强退,这是为什么?代码问题?
2、另外1个按钮也差不多的情况,只不过对应的是1个页面中的副表产生3个不同的EXCEL表,现在只能生成1个EXCEL表,还只能预览而不能存盘,代码如下:
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 = "上会评审汇总" Then
Dim Book As New XLS.Book(ProjectPath & "Attachments\参评汇总.xls")
Dim fl As String = ProjectPath & "Reports\上会评审.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)
ShowAppWindow("上会评审汇总",2)
App.Visible = True
Ws.PrintPreview
App.Quit
ElseIf tb.SelectedPage.Text = "上会评审汇总" Then
Dim Book As New XLS.Book(ProjectPath & "Attachments\评审投piao.xls")
Dim fl As String = ProjectPath & "Reports\上会评审.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(2)
ShowAppWindow("上会评审汇总",2)
App.Visible = True
Ws.PrintPreview
App.Quit
ElseIf tb.SelectedPage.Text = "上会评审汇总" Then
Dim Book As New XLS.Book(ProjectPath & "Attachments\投piao汇总.xls")
Dim fl As String = ProjectPath & "Reports\上会评审.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(3)
ShowAppWindow("上会评审汇总",2)
App.Visible = True
Ws.PrintPreview
App.Quit
End If
请求版主指教!