“值不在预期范围内。”将excel导出为pdf时出错

编程入门 行业动态 更新时间:2024-10-20 15:52:47
本文介绍了“值不在预期范围内。”将excel导出为pdf时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

尝试将excel 2007(xlsx)格式工作簿导出为pdf时出现上述错误。该工作簿只包含一个工作表,我在Windows 2003 sp2服务器上安装了Ms Office 2007。 这是我的converttopdf()函数:

I am getting the above error while trying to export the excel 2007(xlsx) format workbook to pdf. The workbook contains only one sheet and I have Ms Office 2007 installed on windows 2003 sp2 server. Here is my converttopdf() function:

Dim excelApplication As Microsoft.Office.Interop.Excel.ApplicationClass = New Microsoft.Office.Interop.Excel.ApplicationClass() Dim excelWorkbook As Microsoft.Office.Interop.Excel.Workbook = Nothing Dim paramSourceBookPath As String = Server.MapPath(".") & "\" & "TempFile1" & "\" & "TotalRPT1.xlsx" Dim paramExportFilePath As String = Server.MapPath(".") & "\" & "TempFile1" & "\" & "TotalRPT1.pdf" Dim paramExportFormat As Microsoft.Office.Interop.Excel.XlFixedFormatType = _ Microsoft.Office.Interop.Excel.XlFixedFormatType.xlTypePDF Dim paramExportQuality As Microsoft.Office.Interop.Excel.XlFixedFormatQuality = Microsoft.Office.Interop.Excel.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 Try ' Open the source workbook. Dim wkbs As Workbooks = excelApplication.Workbooks excelWorkbook = wkbs.Open(paramSourceBookPath, False, True) Dim file As FileInfo = New FileInfo(paramExportFilePath) If (file.Exists) Then Try file.Delete() Catch ex As Exception End Try End If ' Save it in the target format. If Not excelWorkbook Is Nothing Then excelWorkbook.ExportAsFixedFormat(paramExportFormat, _ paramExportFilePath, paramExportQuality, _ paramIncludeDocProps, paramIgnorePrintAreas, _ paramFromPage, paramToPage, paramOpenAfterPublish) End If Catch ex As Exception ' Respond to the error. Finally ' Close the workbook object. If Not excelWorkbook Is Nothing Then excelWorkbook.Close(False) excelWorkbook = Nothing End If ' Quit Excel and release the ApplicationClass object. If Not excelApplication Is Nothing Then excelApplication.Quit() excelApplication = Nothing End If GC.Collect() GC.WaitForPendingFinalizers() GC.Collect() GC.WaitForPendingFinalizers() End Try

推荐答案

默认情况下,MS Office 2007不支持导出为pdf选项。您需要为此下载加载项。 以下链接将解决您的问题。 2007 Microsoft Office Add -in:Microsoft另存为PDF或XPS MS Office 2007 does not support 'export' to pdf option by default. You need to download Add-Ins for that. Following link will solve your problem. 2007 Microsoft Office Add-in: Microsoft Save as PDF or XPS

更多推荐

“值不在预期范围内。”将excel导出为pdf时出错

本文发布于:2023-11-13 02:02:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1583108.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:范围内   excel   pdf

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!