GroupDocs.Conversion provides SpreadsheetLoadOptions to give you control over how the source spreadsheet document will be processed. The following options could be set:
setFormat allows you to 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 sets a default font. The following font will be used if a spreadsheet font is missing.
setFontSubstitutes sets substitute specific fonts from the source spreadsheet document.
The following code snippet shows how to convert a spreadsheet and specify font substitution for missing fonts:
constjava=require('java');constoutputPath="ConvertSpreadsheetBySpecifyingFontsubstitution.pdf";constfontSubstitutes=java.newInstanceSync("java.util.ArrayList");fontSubstitutes.add(groupdocs.conversion.FontSubstitute.create("Tahoma","Arial"));fontSubstitutes.add(groupdocs.conversion.FontSubstitute.create("Times New Roman","Arial"));constloadOptions=newgroupdocs.conversion.SpreadsheetLoadOptions();loadOptions.setDefaultFont("Helvetica.ttf");loadOptions.setOnePagePerSheet(true);loadOptions.setFontSubstitutes(fontSubstitutes);constconverter=newgroupdocs.conversion.Converter("sample.xlsx",loadOptions);constconvertOptions=newgroupdocs.conversion.PdfConvertOptions();console.log(`Spreadsheet document converted successfully to ${outputPath} (by specifying font subs)`);converter.convert(outputPath,convertOptions);
Specify range
The following code snippet shows how to convert a spreadsheet and specify the exact range of rows and columns to be converted:
constloadOptions=newgroupdocs.conversion.SpreadsheetLoadOptions();loadOptions.setConvertRange('10:30');loadOptions.setOnePagePerSheet(true);constoutputPath="ConvertSpreadsheetBySpecifyingRange.pdf";constconverter=newgroupdocs.conversion.Converter("sample.xlsx",loadOptions);constconvertOptions=newgroupdocs.conversion.PdfConvertOptions();console.log(`Spreadsheet document converted successfully to ${outputPath} (by specifying range)`);converter.convert(outputPath,convertOptions);
Include hidden sheets
The following code snippet shows how to convert a spreadsheet including the hidden sheets:
constloadOptions=newgroupdocs.conversion.SpreadsheetLoadOptions();loadOptions.setShowHiddenSheets(true);loadOptions.setOnePagePerSheet(true);constoutputPath="ConvertSpreadsheetWithHiddenSheetsIncluded.pdf";constconverter=newgroupdocs.conversion.Converter("sample.xlsx",loadOptions);constconvertOptions=newgroupdocs.conversion.PdfConvertOptions();console.log(`Spreadsheet document converted successfully to ${outputPath} (with hidden sheets included)`);converter.convert(outputPath,convertOptions);
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.