Class AbstractExcelDataExporter

    • Constructor Detail

      • AbstractExcelDataExporter

        public AbstractExcelDataExporter​(IModel<String> dataFormatNameModel,
                                         String contentType,
                                         String fileNameExtension)
        Creates a new instance.
        Parameters:
        dataFormatNameModel - An IModel of the data format name.
        contentType - The MIME content type to use when serving up the exported data.
        fileNameExtension - The file name extensions to use for the exported file. This should exclude the ".".
    • Method Detail

      • createWorkbook

        protected abstract org.apache.poi.ss.usermodel.Workbook createWorkbook()
        Creates a new Workbook to which the exported data will be added. This should be either a HSSFWorkbook or a XSSFWorkbook.
        Returns:
        a new Workbook to which the exported data will be added.
      • populateHeaderCell

        protected void populateHeaderCell​(org.apache.poi.ss.usermodel.Cell cell,
                                          String value,
                                          int columnIndex,
                                          IExportableColumn<?,​?> column,
                                          org.apache.poi.ss.usermodel.Workbook workbook)
        Populates a header cell. This can be overridden to decorate header cells, or to add some custom header cell populating code.
        Parameters:
        cell - The Cell to be populated.
        value - The header description, as returned from IExportableColumn.getDisplayModel(). This can be null.
        columnIndex - The index of the column being populated. This is zero based.
        column - The IExportableColumn for which the cell is being exported.
        workbook - The Workbook in which the cell is created. This is included to than it may be used to create formatting objects etc.
      • populateCell

        protected <T> void populateCell​(org.apache.poi.ss.usermodel.Cell cell,
                                        IModel<T> rowModel,
                                        IExportableColumn<T,​?> column,
                                        int rowIndex,
                                        int columnIndex,
                                        org.apache.poi.ss.usermodel.Workbook workbook)
        Populates a cell of exported data. This can be overridden to provide custom cell population behavior, or to decorate the cell.
        Type Parameters:
        T - The type of each exported row.
        Parameters:
        cell - The Cell to be populated.
        rowModel - The IModel of the row.
        column - The IExportableColumn for which this cell if being populated.
        rowIndex - The zero based index of this row in the data set. If headers are exported. then the row index in the spreadsheet will be one more than this, because the first row of the spreadsheet contains headers.
        columnIndex - The zero based index of the column.
        workbook - The Workbook in which the cell is created. This is included to than it may be used to create formatting objects etc.