[]
        
(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 a new workbook and add worksheets
Workbook workbook = new Workbook();
IWorksheet worksheet = workbook.getWorksheets().get(0);
IWorksheet worksheet1 = workbook.getWorksheets().add();
        
// Set value and apply styles to the worksheet
worksheet1.getRange("A1").setValue("Sheet1");
worksheet1.getRange("A1").getFont().setName("Wide Latin");
worksheet1.getRange("A1").getFont().setColor(Color.GetRed());
worksheet1.getRange("A1").getInterior().setColor(Color.GetGreen());
        
// Export Workbook to pdf file, the exported file has two pages.
workbook.save("ConvertWorkbookToPDF.pdf", SaveFileFormat.Pdf);

Export a Worksheet

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

worksheet1.save("ExportWorksheetToPDF.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 documents.

  • The result of DiagonalCross of PatternType enumeration is different in DsExcel as compared to MS Excel.