Load Spreadsheet document with options

GroupDocs.Conversion provides SpreadsheetLoadOptions to give you control over how source spreadsheet document will be processed. The following options could be set:

  • setFormat - the document type is auto detected during loading, however you can specify explicitly the type of the source spreadsheet document. Available options are: Xls, Xlsx, Xlsm, Xlsb, Ods, Ots, Xltx, Xlt, Xltm, Tsv, Xlam, Csv
  • setDefaultFont - default font. The following font will be used if a spreadsheet font is missing.
  • setFontSubstitutes - substitute specific fonts from the source spreadsheet document
  • setShowGridLines - specifies that grid lines should be visible
  • setShowHiddenSheets - specifies that hidden sheet should be included in converted document
  • setOnePagePerSheet - specifies that one sheet from the spreadsheet must be converted to single page
  • setConvertRange - specifies that specific range must be converted. Example: “D1:F8”
  • setSkipEmptyRowsAndColumns - specifies that empty rows and columns must be ignored.
  • setPassword -  password to unlock protected document
  • setHideComments - specifies that comments from source spreadsheet must be hidden during conversion

Hide comments

The following code sample shows how to convert Spreadsheet document and hide comments:

SpreadsheetLoadOptions loadOptions = new SpreadsheetLoadOptions();
loadOptions.setHideComments(true);
loadOptions.setOnePagePerSheet(true);

Converter converter = new Converter("sample.xlsx", loadOptions);
PdfConvertOptions options = new PdfConvertOptions();
converter.convert("converted.pdf", options);

Show grid lines

The following code sample shows how to convert Spreadsheet document and show grid lines:

SpreadsheetLoadOptions loadOptions = new SpreadsheetLoadOptions();
loadOptions.setShowGridLines(true);
loadOptions.setOnePagePerSheet(true);

Converter converter = new Converter("sample.xlsx", loadOptions);
PdfConvertOptions options = new PdfConvertOptions();
converter.convert("converted.pdf", options);

Skip empty rows and columns

The following code sample shows how to convert Spreadsheet document and skip empty rows and columns:

SpreadsheetLoadOptions loadOptions = new SpreadsheetLoadOptions();
loadOptions.setSkipEmptyRowsAndColumns(true);
loadOptions.setOnePagePerSheet(true);

Converter converter = new Converter("sample.xlsx", loadOptions);
PdfConvertOptions options = new PdfConvertOptions();
converter.convert("converted.pdf", options);

Specify font substitution

The following code sample shows how to convert Spreadsheet document and specify font substitution for missing fonts:

SpreadsheetLoadOptions loadOptions = new SpreadsheetLoadOptions();
List<FontSubstitute> fontSubstitutes = new ArrayList<FontSubstitute>();
fontSubstitutes.add(FontSubstitute.create("Tahoma", "Arial"));
fontSubstitutes.add(FontSubstitute.create("Times New Roman", "Arial"));
loadOptions.setDefaultFont("Helvetica");
loadOptions.setOnePagePerSheet(true);
loadOptions.setFontSubstitutes(fontSubstitutes);

Converter converter = new Converter("sample.xlsx", loadOptions);
PdfConvertOptions options = new PdfConvertOptions();
converter.convert("converted.pdf", options);

Specify range

The following code sample shows how to convert Spreadsheet document and specify exact range of rows and columns to be converted

SpreadsheetLoadOptions loadOptions = new SpreadsheetLoadOptions();
loadOptions.setConvertRange("10:30");
loadOptions.setOnePagePerSheet(true);

Converter converter = new Converter("sample.xlsx", loadOptions);
PdfConvertOptions options = new PdfConvertOptions();
converter.convert("converted.pdf", options);

Include hidden sheets

The following code sample shows how to convert Spreadsheet document including the hidden sheets

SpreadsheetLoadOptions loadOptions = new SpreadsheetLoadOptions();
loadOptions.setShowHiddenSheets(true);
loadOptions.setOnePagePerSheet(true);

Converter converter = new Converter("sample.xlsx", loadOptions);
PdfConvertOptions options = new PdfConvertOptions();
converter.convert("converted.pdf", options);

More resources

GitHub Examples

You may easily run the code above and see the feature in action in our GitHub examples:

Free Online Document Converter Apps

Along with full-featured Java library we provide free Apps and free services for document conversion. In order to see a full potential of GroupDocs.Conversion, you are welcome to convert DOC to PDF, DOC to XLSX, PDF to DOC, PDF to XLSX, PPT to DOC and more with Free Online Document Converter App or get a full advantage of Free Online Document Converter Suite with advanced conversion settings and many more enterprise built-in features. Please note that more premium features, advanced options and enhanced document management experience is available for signed-in users at conholdate.app for FREE.
If you don’t own an account yet, register it now for free! No credit card is required!