Built with Seam

You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.

Using Apache POI to generate Excel documents

There have been some people suggesting we should use POI to generate Excel documents in Seam. I don't know POI that well, so instead I'd like to show how you can do it yourself.

First, we add our implementation to components.xml

   <property name="implementations">

Now we have bound poi to my.POIExcelWorkbook. To use this implementation in an Excel workbook we simply need to define type in our jsf workbook page.

<e:workbook type="poi"
      <e:worksheet name="Developers">
         <e:cell column="0" row="0" value="Daniel Roth" />
	 <e:cell column="0" row="1" value="Nicklas Karlsson" />

Finally we need to implement the ExcelWorkbook interface (yes, this you have to do yourself)

package  my;
public class POIExcelWorkbook implements ExcelWorkbook {}

The ExcelWorkbook interface is very well documented regarding what's going to be done on each call. You may also want to look in and for implementation hints.

What about the exporter? Using your own implementation will work fine, since you may add implementation type to use when calling it:

<h:commandButton action="#{excelExporter.export(dataTableId,'poi')}"/>