将Excel文件的PrintPreview(不显示)保存为C#中的image / pdf文件

时间:2016-11-05 12:02:52

标签: c# excel

我想在打印预览中打开Excel文件而不显示它,并将其另存为PDF或图像文件。

有可能吗?我怎么能意识到它?

1 个答案:

答案 0 :(得分:0)

可以使用Worksheet对象的ExportAsFixedFormat方法完成:

using Excel = Microsoft.Office.Interop.Excel;

Excel.Worksheet ws;  // you need to assign this somehow

ws.ExportAsFixedFormat(Excel.XlFixedFormatType.xlTypePDF,
    @"c:\YourFile.pdf", Excel.XlFixedFormatQuality.xlQualityStandard);