jXLS allows direct access to key POI objects in XLS template. They are available under special bean keys in the bean context map.

  • workbook - gives an access to current org.apache.poi.ss.usermodel.Workbook instance
  • sheet - provides an access to current org.apache.poi.ss.usermodel.Sheet object being processed
  • hssfRow - provides an access to current org.apache.poi.ss.usermodel.Row object being processed

Having access to these objects you can invoke different methods to manipulate current template transformation. Next sections show some examples of tasks that can be performed using this approach.

Note: You can change default keys by which POI objects are available in the bean context map using Configuration class

Setting Header and Footer Messages

Setting of header and footer messages is easy because org.apache.poi.ss.usermodel.Sheet provides an access to header and footer with getHeader() and getFooter() methods. So the next code

                ${sheet.getHeader().setLeft('Left Header')}

sets left header of the sheet to 'Left Header' string. Dynamic bean properties also can be used as parameters


This sample sets center footer message to the value of footer property of msgBean bean.

Renaming Sheet

Sheet name can be set using setSheetName method of org.apache.poi.ss.usermodel.Workbook class.

                ${workbook.setSheetName(0, department.name)}

Above sample sets the name of the first sheet to the value of name property of department bean