Interface ExcelAdapter<T,​U extends org.apache.poi.ss.usermodel.Workbook>

  • All Known Implementing Classes:
    DatasetExcelAdapter, RMExcelWriterXlsx

    public interface ExcelAdapter<T,​U extends org.apache.poi.ss.usermodel.Workbook>
    An adapter interface that supports drawing Workbooks and Sheets based on the supplied objects.
    • Method Detail

      • drawWorkbook

        default U drawWorkbook​(boolean headerRow,
                               boolean nullsEmpty,
                               T[] object)
        Draws the supplied object(s) ExcelAdapter and returns ExcelAdapter
        Parameters:
        headerRow - if true, header rows are expected to be written, otherwise false. It is up to the implementation whether this is respected or not.
        nullsEmpty - if true, null values will not be written to cells in the excel document. It is up to the implementation whether this is respected or not.
        object - The object(s) that the Adapter is compatible with for writing.
        Returns:
        A Workbook of type U that can be closed or further manipulated.
      • drawWorkbook

        U drawWorkbook​(boolean headerRow,
                       boolean nullsEmpty,
                       T[] object,
                       @Nullable
                       java.lang.String[] sheetNames)
        Draws the supplied object(s) ExcelAdapter and returns ExcelAdapter
        Parameters:
        headerRow - if true, header rows are expected to be written, otherwise false. It is up to the implementation whether this is respected or not.
        nullsEmpty - if true, null values will not be written to cells in the excel document. It is up to the implementation whether this is respected or not.
        object - The object(s) that the Adapter is compatible with for writing.
        sheetNames - The names of the sheets to create. If null, will use a generic default.
        Returns:
        A Workbook of type U that can be closed or further manipulated.
      • drawSheet

        boolean drawSheet​(U workbook,
                          java.lang.String sheetName,
                          T object,
                          boolean headerRow,
                          boolean nullsEmpty)
        Draws a Sheet for the specific ExcelAdapter
        Parameters:
        workbook - the Workbook to add the new sheet to
        sheetName - the name of the sheet. This name should be checked via WorkbookUtil.createSafeSheetName(String)
        object - the object to write to the sheet
        headerRow - if true, header rows are expected to be written, otherwise false. It is up to the implementation whether this is respected or not.
        nullsEmpty - if true, null values will not be written to cells in the excel document. It is up to the implementation whether this is respected or not.
        Returns:
        true if the object was successfully written to the workbook as a new sheet, false if the object was not written successfully.