Class ExcelExport

java.lang.Object
com.jbstrap.core.data.DataExporter
com.jbstrap.core.data.export.ExcelExport

public class ExcelExport extends DataExporter
Class for exporting data into Excel format (xls, xlsx)
Since:
4.0
Author:
JBStrap
  • Constructor Details

    • ExcelExport

      public ExcelExport(Parameters params)
      Creates an ExcelExport instance with the specified export settings (parameters). Parameters are described in the Exportable interface.
      Parameters:
      params - Additional ExcelExport parameters
      Parameter name Parameter value Default parameter value Parameter description
      sheetName String export.defaultSheetName message source, by default: Exported data Excel worksheet name
  • Method Details

    • start

      public boolean start()
      Starts an Excel export. The HSSFWorkbook or SXSSFWorkbook instances are created, depending on whether ExportTypes.XLS or ExportTypes.XLSX is included in the params. Headers and cell formatting are all specified here.
      Specified by:
      start in class DataExporter
      Returns:
      Successful creation of HSSFWorkbook or SXSSFWorkbook
    • process

      public boolean process(List<Record> data)
      Writes records into a Workbook object. Cells are formatted according to the data stored in them.
      Specified by:
      process in class DataExporter
      Parameters:
      data - Records retrieved using lazy fetch
      Returns:
      Successful processing of records or no more rows can be written into the Excel file. If HSSFWorkbook applies, a maximum of 65,535 rows can be written into the file. If this maximum number has been reached, the method returns false and the end() method comes next.
    • end

      public byte[] end() throws IOException
      Export completed, no more records to be processed. Closes the created sources and returns them in a byte array.
      Specified by:
      end in class DataExporter
      Returns:
      Export successful
      Throws:
      IOException - An exception is thrown while handling a source