Dim dlg As New SaveFileDialog '定义一个新的OpenFileDialog
dlg.Filter= "Excel文件|*.xls|Word文件|*.doc|Access文件|*.mdb|Excel2007|*.xlsx" '设置筛选器
dlg.FileName="OIGN - Documents.xls"
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
'导出OIGN模板
Dim Book As New XLS.Book(ProjectPath & "Attachments\OIGN - Documents.xls") '打开模板
Dim fl As String = dlg.FileName
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Sheet(2,0).Value = "22"
Dim day As Date
Dim a As String = day.Today.Year
Dim b As String =day.Today.Month
Dim c As String=day.Today.Day
Dim cd As String =len(trim(a))
If len(trim(b))<2 Then
b="0"+b
End If
If len(trim(c))<2 Then
c="0"+c
End If
Dim d As String = a+b+c
Sheet(2,1).Value = d
Sheet(2,2).Value = d
Book.Save(fl)
'完成导出GION模板
'开始导出IGN模板
Dim Book1 As New XLS.Book(ProjectPath & "Attachments\IGN - Document_Lines.xls") '打开模板
Dim fl1 As String = dlg.FileName
Dim Sheet1 As XLS.Sheet = Book1.Sheets(0)
Sheet1(2,0).Value = "<整合源>" '写入表名,这里的1和0表示从上到下和从左到右表名的位置都是从0开始数
Sheet1(2,1).Value = "22"
Sheet1(2,4).Value = "1"
Sheet1(2,5).Value = "202"
Book1.Build() '生成报表
Book1.Save(fl1)
'开始导出SRNT - SerialNumbers模板
Dim Book2 As New XLS.Book(ProjectPath & "Attachments\SRNT - SerialNumbers.xls") '打开模板
Dim fl2 As String = dlg.FileName
Dim Sheet2 As XLS.Sheet = Book2.Sheets(0)
Sheet2(2,0).Value = "<整合源>" '写入表名,这里的1和0表示从上到下和从左到右表名的位置都是从0开始数
Sheet2(2,1).Value = "22"
Book2.Build() '生成报表
Book2.Save(fl2)
End If
messagebox.show("导出完成!")
这样保存了3个文件,3个文件都要对应的指定名称,但是定义了dlg.FileName这一个3个文件都是一个名字,求老师指导
[此贴子已经被作者于2014-2-26 17:54:21编辑过]