实例太复杂了。要从系统里面剥离很多东西。我把代码分为2段,1段给25个var赋值。耗时0.017秒
第二段代码在下面,第二段代码耗时3.35秒。
Dim st22 As Date = Date.Now
If filterstring1="findpo1" Then
Dim Book As New XLS.Book(ProjectPath & "Attachments\ApprovalPR.xlsx")
Dim fls As String = SpecialFolder.DesktopDirectory & "\PR文件夹\" & Vars("customername") & "-" & Vars("POname") & "(PR).pdf"
If FileSys.DirectoryExists( SpecialFolder.DesktopDirectory & "\PR文件夹")=False Then
FileSys.CreateDirectory( SpecialFolder.DesktopDirectory & "\PR文件夹")
End If
Dim newfname As String
newfname=Vars("customername") & "-" & Vars("POname") & "(PR).pdf"
ShowAppWindow(newfname,5)
Dim Sheet As XLS.Sheet = Book.Sheets(0) '引用工作簿的第一个工作表
With Sheet.PrintSetting
.PaperKind = 9 '设为A4纸
.LandScape = True '横向打印
.MarginTop=12
.MarginBottom=16
.AutoScale = True '自动缩放
.FitPagesAcross = 1 '垂直方向缩为1页
.FitPagesDown=1
End With
Book.Build() '生成细节区
Book.SaveToPDF(fls) '保存为PDF文件
If podr IsNot Nothing And podr.Isnull("fileinfo")=False Then
Dim ex As String
ex=podr("fileinfo")
fl = SpecialFolder.DesktopDirectory & "\PR文件夹\" & Vars("customername") & "-" & Vars("POname") & "(手工PO).zip"
podr.SQLLoadFile("poattachment",fl)
End If
MessageBox.Show("耗时: " & (Date.Now - st22).TotalSeconds & "秒")