protected void initFooter(Sheet sheet, Date exportDateTime) { Footer footer = sheet.getFooter(); // add a fixed export date and time (not a dynamic HeaderFooter.date() ) SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss"); footer.setLeft(dateFormat.format(exportDateTime)); footer.setRight("Page " + HeaderFooter.page() + " of " + HeaderFooter.numPages()); }
private HSSFSheet createSheet ( final List<Event> events, final HSSFWorkbook workbook, final List<Field> columns ) { final HSSFSheet sheet = workbook.createSheet ( Messages.ExportImpl_ExcelSheet_Name ); final HSSFHeader header = sheet.getHeader (); header.setLeft ( Messages.ExportImpl_ExcelSheet_Header ); header.setRight ( HeaderFooter.date () + " " + HeaderFooter.time () );//$NON-NLS-1$ final HSSFFooter footer = sheet.getFooter (); footer.setLeft ( String.format ( Messages.ExportImpl_ExcelSheet_Footer_1, events.size () ) ); footer.setRight ( Messages.ExportImpl_ExcelSheet_Footer_2 + HeaderFooter.page () + Messages.ExportImpl_ExcelSheet_Footer_3 + HeaderFooter.numPages () ); makeHeader ( columns, sheet ); final HSSFPrintSetup printSetup = sheet.getPrintSetup (); printSetup.setLandscape ( true ); printSetup.setFitWidth ( (short)1 ); printSetup.setFitHeight ( (short)0 ); printSetup.setPaperSize ( PrintSetup.A4_PAPERSIZE ); sheet.setAutoFilter ( new CellRangeAddress ( 0, 0, 0, columns.size () - 1 ) ); sheet.createFreezePane ( 0, 1 ); sheet.setFitToPage ( true ); sheet.setAutobreaks ( true ); printSetup.setFooterMargin ( 0.25 ); sheet.setMargin ( Sheet.LeftMargin, 0.25 ); sheet.setMargin ( Sheet.RightMargin, 0.25 ); sheet.setMargin ( Sheet.TopMargin, 0.25 ); sheet.setMargin ( Sheet.BottomMargin, 0.5 ); return sheet; }