【发布时间】:2018-05-16 09:58:26
【问题描述】:
我正在尝试将 Excel 工作簿中的每张工作表打印为单独的 PDF。但我不断收到System.ArgumentException: 'Value does not fall within the expected range.' 在线w.ExportAsFixedFormat(...);
实现此目的的正确语法是什么?
我使用的代码:
foreach (Worksheet w in ws.Worksheets)
{
var wname = Path.Combine(
AppDomain.CurrentDomain.BaseDirectory,
"Export\\" + w.Name + ".pdf"
);
w.ExportAsFixedFormat(
XlFixedFormatType.xlTypePDF,
wname,
XlFixedFormatQuality.xlQualityStandard,
true,
false,
1,
w.PageSetup.Pages.Count,
false,
false
);
}
更新: 我应该提一下,我将它与 Office 2013、Microsoft Excel 15.0 对象库一起使用
【问题讨论】:
-
我相信不是重复的。另一篇文章提到了 Office 2007,其中 Export-to-PDF 是一个插件,而在 Office 2013 中,该功能是内置的。
-
是的,抱歉,我后来意识到,但你已经关闭了问题,所以无法删除标志。
-
是的,我在那里太仓促了。对此深表歉意!
标签: c# excel office-interop export-to-pdf