gpt4 book ai didi

.net - "Value does not fall within the expected range."将 excel 导出为 pdf 时出错

转载 作者:行者123 更新时间:2023-12-03 17:49:56 24 4
gpt4 key购买 nike

我在尝试将 excel 2007(xlsx) 格式工作簿导出为 pdf 时遇到上述错误。该工作簿仅包含一张纸,我的 Windows 7 PC 上安装了 Ms Office 2007。
这是堆栈跟踪

   at Microsoft.Office.Interop.Excel.WorkbookClass.ExportAsFixedFormat(XlFixedFormatType Type, Object Filename, Object Quality, Object IncludeDocProperties, Object IgnorePrintAreas, Object From, Object To, Object OpenAfterPublish, Object FixedFormatExtClassPtr)

at schoolwisereportprint.converttopdf() in
C:\Users\username\Desktop\Dpp2012New\schoolwisereportprint.aspx.vb:line 33

at schoolwisereportprint.Button1_Click(Object sender, EventArgs e) in C:\Users\username\Desktop\Dpp2012New\schoolwisereportprint.aspx.vb:line 158

这是我的 converttopdf() 函数:
Public Sub converttopdf()
Dim fileName As String = Server.MapPath("rahulserver/pdfreprt.xlsx")
Dim xlsApp = New Microsoft.Office.Interop.Excel.Application
xlsApp.ScreenUpdating = False
Dim xlsBook As Microsoft.Office.Interop.Excel.Workbook
Dim paramExportFormat As XlFixedFormatType = XlFixedFormatType.xlTypePDF
Dim paramExportQuality As XlFixedFormatQuality = XlFixedFormatQuality.xlQualityStandard
Dim paramOpenAfterPublish As Boolean = False
Dim paramIncludeDocProps As Boolean = True
Dim paramIgnorePrintAreas As Boolean = True
Dim paramFromPage As Object = Type.Missing
Dim paramToPage As Object = Type.Missing
xlsBook = xlsApp.Workbooks.Open(fileName, UpdateLinks:=False, ReadOnly:=False)
xlsBook.ExportAsFixedFormat(paramExportFormat, "rahulserver/pdfreprt" & ".pdf", paramExportQuality, paramIncludeDocProps, paramIgnorePrintAreas,paramFromPage, paramToPage, paramOpenAfterPublish)
xlsBook.Close(SaveChanges:=False)
xlsApp.Quit()
MsgBox("successfully converted to pdf!")
End Sub

即使将 paramFromPage 和 paramToPage 分别更改为 1 和 1 也无济于事。我已经花了一整天的时间来解决这个错误,但找不到办法。现在我看着SO让我摆脱这个......

最佳答案

刚刚意识到这是一个非常古老的问题。顺便说一下,问题是 OP 没有安装“2007 Microsoft Office 插件:Microsoft 另存为 PDF”插件。

你可以找到here

关于.net - "Value does not fall within the expected range."将 excel 导出为 pdf 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13061690/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com