Class CsvExporter
java.lang.Object
org.eclipse.nebula.widgets.nattable.export.csv.CsvExporter
- All Implemented Interfaces:
IExporter,ILayerExporter
Simple CSV-Exporter ignoring cell spans.
- Since:
- 1.5
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a CsvExporter using a defaultFileOutputStreamProviderto define the destination for the export.CsvExporter(String filePath) Creates a CsvExporter using aFilePathOutputStreamProvider.CsvExporter(IOutputStreamProvider outputStreamProvider) Creates a CsvExporter using the given stream provider which defines the destination for the export. -
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.getOutputStream(org.eclipse.swt.widgets.Shell shell) Get theOutputStreamto which the export should be written to.voidsetCharset(String charset) Defines the name of the charset which should be used as encoding for the export file.voidsetDelimiter(String delimiter) Defines the delimiter which should be used between columns.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.eclipse.nebula.widgets.nattable.export.ILayerExporter
setExportOnSameSheet
-
Constructor Details
-
CsvExporter
Creates a CsvExporter using the given stream provider which defines the destination for the export. If the stream provider ist set to null a defaultFileOutputStreamProviderwill be used.- Parameters:
outputStreamProvider- the used stream provider
-
CsvExporter
public CsvExporter()Creates a CsvExporter using a defaultFileOutputStreamProviderto define the destination for the export. -
CsvExporter
Creates a CsvExporter using aFilePathOutputStreamProvider. The destination fpr the export will be a file with the given path.- Parameters:
filePath- the path of the export file
-
-
Method Details
-
getOutputStream
Description copied from interface:IExporterGet theOutputStreamto which the export should be written to.- Specified by:
getOutputStreamin interfaceIExporter- Parameters:
shell- TheShellto which theILayerto export is connected to. Necessary to support user interactions via dialogs on configuring the output location.- Returns:
- The
OutputStreamto write the export to.
-
getResult
- Specified by:
getResultin interfaceIExporter- Returns:
- The result that is produced by this
ITableExporter. Usually the file that is created or written by this exporter.
-
exportBegin
Description copied from interface:ILayerExporterNeed 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.
- Specified by:
exportBeginin interfaceILayerExporter- 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
Description copied from interface:ILayerExporterNeed 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.
- Specified by:
exportEndin interfaceILayerExporter- Parameters:
outputStream- The OutputStream to write the export to.- Throws:
IOException- If finishing the export operation fails on an I/O operation.
-
exportLayerBegin
Description copied from interface:ILayerExporterStarts 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.
- Specified by:
exportLayerBeginin interfaceILayerExporter- 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
Description copied from interface:ILayerExporterEnds 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.
- Specified by:
exportLayerEndin interfaceILayerExporter- 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
Description copied from interface:ILayerExporterStarts 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.- Specified by:
exportRowBeginin interfaceILayerExporter- 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
Description copied from interface:ILayerExporterEnds the export operation of one row.- Specified by:
exportRowEndin interfaceILayerExporter- 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
public void exportCell(OutputStream outputStream, Object exportDisplayValue, ILayerCell cell, IConfigRegistry configRegistry) throws IOException Description copied from interface:ILayerExporterExports one cell.- Specified by:
exportCellin interfaceILayerExporter- 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.
-
setCharset
Defines the name of the charset which should be used as encoding for the export file. The default ist set to windows-1252.- Parameters:
charset- the name of the charset
-
setDelimiter
Defines the delimiter which should be used between columns. The default is the character ';'.- Parameters:
delimiter- the column delimiter
-