保存Excel文件的PrintPreview(不显示)作为C#中的图像/ pdf文件

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

可能吗? 我怎么能意识到这一点?

这可以通过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);