//&P == current page number
//&N == page numbers
footer.setRight("Page &P of &N");
Header firstHeader=((XSSFSheet)sheet).getFirstHeader();
//&F == workbook file name
firstHeader.setLeft("&F ......... first header");
for(int i=0;i<100;i=i+10){
sheet.createRow(i).createCell(0).setCellValue(123);
}
XSSFSheet sheet2 = (XSSFSheet)wb.createSheet("odd header-even footer");
Header oddHeader=sheet2.getOddHeader();
//&B == bold
//&E == double underline
//&D == date
oddHeader.setCenter("&B &E oddHeader &D ");
Footer evenFooter=sheet2.getEvenFooter();
evenFooter.setRight("even footer &P");
sheet2.createRow(10).createCell(0).setCellValue("Second sheet with an oddHeader and an evenFooter");
for(int i=0;i<200;i=i+10){
sheet2.createRow(i).createCell(0).setCellValue(123);
}
XSSFSheet sheet3 = (XSSFSheet)wb.createSheet("odd header- odd footer");
sheet3.createRow(10).createCell(0).setCellValue("Third sheet with oddHeader and oddFooter");
Header oddH=sheet3.getOddHeader();
//&C == centered
oddH.setCenter("centered oddHeader");
oddH.setLeft("left ");
oddH.setRight("right ");
Footer oddF=sheet3.getOddFooter();
oddF.setLeft("Page &P");
oddF.setRight("Pages &N ");