Last active
April 22, 2021 03:04
-
-
Save aspose-com-gists/2396821770031adfbe82eee1d66854f0 to your computer and use it in GitHub Desktop.
Convert Excel to PDF Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create Workbook to load Excel file | |
Workbook workbook = new Workbook("Book1.xlsx"); | |
// Create PDF options | |
PdfSaveOptions options = new PdfSaveOptions(); | |
options.setOnePagePerSheet(true); | |
// Save the document in PDF format | |
workbook.save("Excel-to-PDF.pdf", options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create Workbook to load Excel file | |
Workbook workbook = new Workbook("Book1.xlsx"); | |
// Create PDF options | |
PdfSaveOptions options = new PdfSaveOptions(); | |
// To render sheet2 only | |
options.setPageIndex(1); | |
options.setPageCount(1); | |
// Save the document in PDF format | |
workbook.save("Excel-to-PDF.pdf", options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create Workbook to load Excel file | |
Workbook workbook = new Workbook("Book1.xlsx"); | |
// Save the document in PDF format | |
workbook.save("Excel-to-PDF.pdf", SaveFormat.PDF); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create Workbook to load Excel file | |
Workbook workbook = new Workbook("Book1.xlsx"); | |
// Create PDF options | |
PdfSaveOptions options = new PdfSaveOptions(); | |
options.setCompliance(PdfCompliance.PDF_A_1_A); | |
// Save the document in PDF format | |
workbook.save("Excel-to-PDF.pdf", options); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment