Skip to content

Footers and subfooters

firegloves edited this page Jul 20, 2022 · 1 revision

Footers and subfooters

MemPOI supports standard .xlsx footers and sub footers. Whereas footers are a simple wrapper of the Excel ones, subfooters are a MemPOI extension that allows you add some nice features to your report. For example, you could choose to add the NumberSumSubFooter to your MemPOI report. It will result in an additional line at the end of the sheet containing the sum of the numeric columns. This is an example:

MemPOI memPOI = MempoiBuilder.aMemPOI()
                    .withWorkbook(workbook)
                    .withFile(fileDest)
                    .addMempoiSheet(new MempoiSheet(prepStmt))
                    .withMempoiSubFooter(new NumberSumSubFooter())
                    .build();

List of available subfooters:

  • NumberSumSubFooter: places a cell containing the sum of the column (works only on numeric comlumns)
  • NumberMaxSubFooter: places a cell containing the maximum value of the column (works only on numeric comlumns)
  • NumberMinSubFooter: places a cell containing the minimum value of the column (works only on numeric comlumns)
  • NumberAverageSubFooter: places a cell containing the average value of the column (works only on numeric comlumns)

By default no footer and no subfooter are appended to the report.

Subfooters are already supported by the MemPOI bundled templates.

IMPORTANT: If you want to use a custom subfooter with cell formulas it needs to extend FormulaSubFooter

Accordingly with MS docs: "Headers and footers are not displayed on the worksheet in Normal view — they are displayed only in Page Layout view and on the printed pages"