Interface ILayerExporter

All Superinterfaces:
IExporter
All Known Implementing Classes:
CsvExporter, ExcelExporter, HSSFExcelExporter, PoiExcelExporter

public interface ILayerExporter extends IExporter
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 Details

    • exportBegin

      void exportBegin(OutputStream outputStream) throws IOException
      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

      void exportEnd(OutputStream outputStream) throws IOException
      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

      void exportLayerBegin(OutputStream outputStream, String layerName) throws IOException
      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

      void exportLayerEnd(OutputStream outputStream, String layerName) throws IOException
      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

      void exportRowBegin(OutputStream outputStream, int rowPosition) throws IOException
      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

      void exportRowEnd(OutputStream outputStream, int rowPosition) throws IOException
      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 - true if multiple NatTable instances should be exported on the same sheet, false if every instance should be exported on separate sheets. Default is false.
      Since:
      2.0