To export a workbook to an ODS (OpenDocument Spreadsheet) file, create an instance of the CalcExporter class and call the export method. The following example illustrates how to do this:
Java
![]() |
---|
CalcExporter calcExporter = new CalcExporter(); |
To export a workbook to an XLSX (Office Open XML) file, create an instance of the ExcelExporter class and call the exportXlsx method. The following example illustrates how to do this:
Java
![]() |
---|
ExcelExporter excelExporter = new ExcelExporter(); |
You can create a static image representing the worksheet of a workbook by using the ImageExporter class. To do this, create an instance of the ImageExporter class, set the desired properties and call the export method. To export a subset of cells in the worksheet, use the CellRange property of the exporter. The grid lines and interactive objects can be enabled or disabled through the EnableGridLines and EnableObjects properties respectively. The image format and the maximum size of the image can be specified through the ImageFormat and MaxImageSize properties. To get the cells that were actually exported by the most recent call to export, call the getExportedRange method. This can be useful when exporting big worksheets that cannot fit in a single image.
The following example illustrates how to export an existing worksheet:
Java
![]() |
---|
ImageExporter imageExporter = new ImageExporter(); |
To export a worksheet to an CSV (comma-separated values) file, create an instance of the CsvExporter class, set the appropriate properties and call the export method. The Quote and Separator properties can be used to specify the quote and separator characters respectively in the exported file. The CsvExportForm can be used to facilitate the export to CSV.
The following example illustrates how to export a worksheet to an CSV file:
Java
![]() |
---|
CsvExporter csvExporter = new CsvExporter(); |
To export a worksheet to a PDF file, create an instance of the PdfExporter class, set the appropriate properties and call the export method. The following example illustrates how to do this:
Java
![]() |
---|
PdfExporter pdfExporter = new PdfExporter(); |
To export a workbook to a XHTML or MHTML file, create an instance of the HtmlExporter or MhtmlExporter class respecively, set the appropriate properties and call the export method. The following example illustrates how to do this:
Java
![]() |
---|
HtmlExporter htmlExporter = new HtmlExporter(); |
The two exporter classes derive several properties from their common base class HtmlExporterBase, namely, Title, Encoding, EnablePictures, EnableCharts, and EnableGridLines. In addition to these, the HtmlExporter class provides a set of properties that specify how images are stored – EmbedImages, RootFolder, and ImageFolder.
The section highlights some of the limitations of the XHTML/MHTML exporters.