“值不在预期范围内."将Excel导出到pdf时出错

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

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

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 my windows 7 PC. Here is the stacktrace

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()函数:

Here is my converttopdf() function:

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也无济于事.我已经花费了一整天的时间来解决此错误,但是找不到解决方法.现在,我期待着让我摆脱困境...

Even changing paramFromPage and paramToPage to 1 and 1 respectively does not help. I have already spent a whole day troubleshooting this error but could not find a way. Now I look upon SO to get me out of this...

推荐答案

刚刚意识到这是一个非常老的问题.顺便说一句,问题在于OP没有安装"2007 Microsoft Office加载项:Microsoft另存为PDF"加载项.

Just realized that this was a really old question. By the way, the problem was that the OP hadn't the "2007 Microsoft Office Add-in: Microsoft Save as PDF" Add-In installed.

您可以在此处

更多推荐

“值不在预期范围内."将Excel导出到pdf时出错

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

发布评论

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

>www.elefans.com

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