Interface ILayerExporter
- All Superinterfaces:
IExporter
- All Known Implementing Classes:
CsvExporter,ExcelExporter,HSSFExcelExporter,PoiExcelExporter
An ILayerExporter is used to export a NatTable to an external format. Usually
such an external format is some kind of Excel format. But it is also possible
to implement an exporter that exports to another format.
The ILayerExporter is registered to the IConfigRegistry via
ExportConfigAttributes.EXPORTER configuration attribute and used by
the NatExporter to perform the export.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidexportBegin(OutputStream outputStream) Need to be called only once at the beginning of an export operation.voidexportCell(OutputStream outputStream, Object exportDisplayValue, ILayerCell cell, IConfigRegistry configRegistry) Exports one cell.voidexportEnd(OutputStream outputStream) Need to be called only once at the end of an export operation.voidexportLayerBegin(OutputStream outputStream, String layerName) Starts the export operation of one ILayer.voidexportLayerEnd(OutputStream outputStream, String layerName) Ends the export operation of one ILayer.voidexportRowBegin(OutputStream outputStream, int rowPosition) Starts the export operation of one row.voidexportRowEnd(OutputStream outputStream, int rowPosition) Ends the export operation of one row.default voidsetExportOnSameSheet(boolean sameSheet) Configure whether multiple table instances should be exported on the same sheet.Methods inherited from interface org.eclipse.nebula.widgets.nattable.export.IExporter
getOutputStream, getResult
-
Method Details
-
exportBegin
Need to be called only once at the beginning of an export operation. It is used to initialize the export operation like e.g. letting a user specify the export location via file selection dialog or creating a workbook.Note: Also on exporting multiple NatTable instances as part of a single export operation, this method should only be called once before any layers are exported.
- Parameters:
outputStream- The OutputStream to write the export to.- Throws:
IOException- If the beginning of an export already performs I/O operations that fail.
-
exportEnd
Need to be called only once at the end of an export operation. It is used to cleanup resources after the export operation, like e.g. closing opened streams.Note: Also on exporting multiple NatTable instances as part of a single export operation, this method should only be called once after all layers are exported.
- Parameters:
outputStream- The OutputStream to write the export to.- Throws:
IOException- If finishing the export operation fails on an I/O operation.
-
exportLayerBegin
Starts the export operation of one ILayer. Is used for example to initialize a sheet in a workbook or open the root tags in a XML format.On exporting multiple NatTable instances, this method needs to be called once for every instance.
- Parameters:
outputStream- The OutputStream to write the export to.layerName- The name that should be used as sheet name.- Throws:
IOException- If an error occurred during writing the export.
-
exportLayerEnd
Ends the export operation of one ILayer. Is used for example to finish the export, like closing tags in a XML format.On exporting multiple NatTable instances, this method needs to be called once for every instance.
- Parameters:
outputStream- The OutputStream to write the export to.layerName- The name that is used as sheet name. Usually not necessary, but in case there is caching involved in a custom ILayerExporter implementation, this can be used to retrieve the ILayer instance again.- Throws:
IOException- If an error occurred during writing the export.
-
exportRowBegin
Starts the export operation of one row. Is used for example to initialize a row in a sheet or open some tags in a XML format.- Parameters:
outputStream- The OutputStream to write the export to.rowPosition- The position of the row to export.- Throws:
IOException- If an error occurred during writing the export.
-
exportRowEnd
Ends the export operation of one row.- Parameters:
outputStream- The OutputStream to write the export to.rowPosition- The position of the row that was exported. Usually not necessary, but in case there is caching involved in a custom ILayerExporter implementation, this can be used to retrieve the row again.- Throws:
IOException- If an error occurred during writing the export.
-
exportCell
void exportCell(OutputStream outputStream, Object exportDisplayValue, ILayerCell cell, IConfigRegistry configRegistry) throws IOException Exports one cell.- Parameters:
outputStream- The OutputStream to write the export to.exportDisplayValue- The value that will be written to the export file. This value is determined by using the data value of the ILayerCell and the registered IExportFormatter within the NatExporter.cell- The ILayerCell that is currently exported.configRegistry- The ConfigRegistry to retrieve the registered style information of the cell that is currently exported.- Throws:
IOException- If an error occurred during writing the export.
-
setExportOnSameSheet
default void setExportOnSameSheet(boolean sameSheet) Configure whether multiple table instances should be exported on the same sheet. Only relevant for export formats that support multiple sheets like Excel.- Parameters:
sameSheet-trueif multiple NatTable instances should be exported on the same sheet,falseif every instance should be exported on separate sheets. Default isfalse.- Since:
- 2.0
-