Save Specified Worksheets to PDF

By default, Aspose.Cells saves all visible worksheets in a workbook to a PDF file. With the PdfSaveOptions.SheetSet option, you can save specified worksheets to a PDF file. For example, you can save the active worksheet to PDF, save all worksheets (both visible and hidden worksheets) to PDF, or save custom multiple worksheets to PDF.

Save Active Worksheet to PDF

If you want to only export the active sheet to PDF, you can achieve this by passing SheetSet.Active to PdfSaveOptions.SheetSet option.

The sheet Sheet2 is the active sheet of the source file sheetset-example.xlsx.

Save All Worksheets to PDF

SheetSet.Visible indicates visible sheets in a workbook, and SheetSet.All indicates all sheets, including both visible sheets and hidden/invisible sheets in a workbook. If you want to export all sheets to PDF, you can just pass SheetSet.All to PdfSaveOptions.SheetSet option.

The source file sheetset-example.xlsx contains all four sheets with hidden sheet Sheet3.

Save Specified Worksheets to PDF

If you want to export desired, custom multiple sheets to PDF, you can achieve this by passing multiple sheet indices to PdfSaveOptions.SheetSet option.

Reorder Worksheets to PDF

If you want to reorder sheets (e.g., in reverse order) to PDF without modifying the source file, you can achieve this by passing reordered sheet indices to PdfSaveOptions.SheetSet option.