[]
        
(Showing Draft Content)

Export to PDF

DsExcel enables you to export workbooks and worksheets to PDF files. You can save all visible worksheets in a workbook to a PDF document, with each worksheet exported to a separate PDF page. To export only the active worksheet, you can save the worksheet directly to PDF.

DsExcel also provides options for controlling PDF pagination and print output. You can configure the appearance and layout of the exported document, customize fonts and styles, export worksheet content such as charts, shapes, slicers, barcodes, signature lines, cell checkboxes, and form controls, and adjust column widths and row heights for the PDF output.

In addition, you can use PdfSaveOptions to configure PDF-specific settings, including border styles, text fitting, document properties, security options, background images, cell background transparency, and export progress. For advanced print-output requirements, the PrintManager class allows you to paginate worksheet content, modify page information, select or remove pages, combine content from multiple worksheets or workbooks, and save customized page collections to PDF.

Export a Workbook

The following example saves all visible worksheets in a workbook to a PDF file. Each worksheet is exported to a separate page in the PDF document.

//create workbook and add two sheets.
Workbook workbook = new Workbook();
IWorksheet sheet1 = workbook.Worksheets[0];
IWorksheet sheet2 = workbook.Worksheets.Add();

//export workbook to pdf file, the exported file has two pages.
workbook.Save(@"D:\workbook.pdf", SaveFileFormat.Pdf);

Export a Worksheet

To export only a specific worksheet, use the Save method of the IWorksheet interface.

sheet1.Save(@"D:\sheet1.pdf", SaveFileFormat.Pdf);

Limitations

  • DsExcel doesn't support exporting picture settings (such as Brightness, Contrast, Watermark Color Type and black and white pictures in emf format) to PDF files.

  • DiagonalCross, Cross, DashedUpwardDiagonal, and DashedDownwardDiagonal of PatternType enumeration have rendering limitations in DsExcel.