Related blog post: How to Convert Excel Spreadsheets to PDF in Java
Last active
November 21, 2021 07:41
-
-
Save GroupDocsGists/98212012f8ebdca9891092e613998f76 to your computer and use it in GitHub Desktop.
Convert Excel Spreadsheet to PDF in 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
/* | |
* Convert the specified Cell Range of specified Excel sheets to PDF format in Java | |
*/ | |
// Prepare Load options and Range for the source XLSX file | |
SpreadsheetLoadOptions loadOptions = new SpreadsheetLoadOptions(); | |
loadOptions.setConvertRange("A1:C20"); | |
Converter converter = new Converter("path/spreadsheet.xlsx", loadOptions); | |
PdfConvertOptions convertOptions = new PdfConvertOptions(); | |
convertOptions.setPageNumber(1); | |
convertOptions.setPagesCount(1); | |
converter.convert("path/convert-cell-range.pdf", convertOptions); |
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
/* | |
* Convert all the Excel sheets to PDF format in Java | |
*/ | |
Converter converter = new Converter("path/spreadsheet.xlsx"); | |
converter.convert("path/all-sheets-converted.pdf", new PdfConvertOptions()); |
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
/* | |
* Convert sequence of Excel sheets to PDF format in Java | |
*/ | |
Converter converter = new Converter("path/spreadsheet.xlsx"); | |
PdfConvertOptions convertOptions = new PdfConvertOptions(); | |
convertOptions.setPageNumber(1); | |
convertOptions.setPagesCount(2); | |
converter.convert("path/sequential-conversion.pdf", convertOptions); |
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
/* | |
* Convert the specified list of Excel sheets to PDF format in Java | |
*/ | |
Converter converter = new Converter("path/spreadsheet.xlsx"); | |
PdfConvertOptions convertOptions = new PdfConvertOptions(); | |
convertOptions.setPages(Arrays.asList(1,3)); | |
converter.convert("path/specific-sheets-conversion.pdf", convertOptions); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment