【问题标题】:Export Different Sheets in one excel file to different pdf files?将一个excel文件中的不同工作表导出到不同的pdf文件?
【发布时间】:2014-08-25 12:05:33
【问题描述】:

我有一个 10 张的 excel 文件。我们可以使用下面将整个excel文件导出为一个pdf文件。

ExportAsFixedFormat(Microsoft.Office.Interop.Excel.XlFixedFormatType.xlTypePDF, outputPath, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);

是否可以将每张工作表导出为 pdf 文件?我总共有 10 个 pdf 文件?

WorkSheet.SaveAs 可以保存工作表,但不能导出为 pdf。

谢谢

【问题讨论】:

标签: c# .net vb.net excel pdf


【解决方案1】:

我认为您可能需要迭代工作表(电子表格和图表表)/工作表(仅限电子表格)并单独导出每个工作表。

// add using Microsoft.Office.Interop.Excel;
// wb - workbook reference
foreach (Worksheet workSht in wb.Sheets)
{
    if (workSht.UsedRange.Cells.Count > 0)
    {
        workSht.ExportAsFixedFormat(XlFixedFormatType.xlTypePDF, 
                                                      outputPath + workSht.Name);
     }
 }

【讨论】:

  • 谢谢。有用。我不知道它是 WorkSheet 而不是 Sheet。这就是为什么我找不到工作表的 ExportAsFixedFormat。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-03-28
  • 2014-08-06
  • 2015-10-16
  • 1970-01-01
  • 1970-01-01
  • 2023-03-11
  • 1970-01-01
相关资源
最近更新 更多