使用VS2008和Office2007将Excel转换为PDF [英] Converting Excel to PDF with VS2008 and Office2007
问题描述
我正在尝试使用Interop.Excell将Excel工作簿另存为PDF文件.我正在使用VS2008和Office2007,并且已经从Microsoft下载并安装了SaveAsPDFandXPS.exe.这使我可以使用以下代码将Word文档另存为pdf:对象frmt = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatPDF;wrd.ActiveDocument.SaveAs(ref dest,ref frmt,ref unknown,ref unknown,...对于整个Interop来说,这是很酷的事情.
无论如何,我一直没有成功在Word.WdSaveFormat.wdFormatPDF的Interop.Excell中找到一个并行项.Workbook.SaveAs采用Interop.Excel.XlFileFormat,但没有pdf格式的选项.有没有人做过这件事或在这方面有经验?
此问题已在此处回答:
Workbook.ExportAsFixedFormat
方法:
ActiveWorkbook.ExportAsFixedFormat类型:= xlTypePDFFileName:="sales.pdf"质量:= xlQualityStandardDisplayFileAfterPublish:=真
与使用 SaveAs
相比,此方法应该是首选方法,因为它还允许指定所有PDF/XPS选项.
注意:此方法已添加到Excel 2007的Excel对象模型中,并且需要 解决方案
This question has been answered here:
You need to call the Workbook.ExportAsFixedFormat
method:
ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF
FileName:="sales.pdf"
Quality:=xlQualityStandard
DisplayFileAfterPublish:=True
This method should be preferred over using SaveAs
because it also allows specifying all PDF / XPS options.
Note: This method has been added to the Excel object model with Excel 2007 and requires the Save as PDF or XPS Add-in for 2007 Microsoft Office programs (or SP2) to be installed.
这篇关于使用VS2008和Office2007将Excel转换为PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!