I have a table that I want to display. Is there a transformer that I can use to give it out as an excel sheet?
You could write it out as a '|'(pipe) delimited file which can then be opened as an Excel spreadsheet.
I don't know of a transformer like XSLT or something that is available now.
However, the Jakarta POI project has an open source Excel manipulation API. http://jakarta.apache.org/poi/.
POI is currently being integrated into Cocoon. At that time, there should be a way to transform your XML into Excel. Until then, you could try getting the data out of each table cell and putting it into a spreadsheet manually.
There are also commercial Java Excel APIs available. Try a google search.
Hope this helps.
One solution for this would be to create your own excel XSL page that can be merged with an XML doc to render
1. Create a sample template of what your Excel sheet will look like (with dummy data for placeholder) and convert it to .slk format (Symbolic Link). In excel, save as -> .slk
2. Then open the .slk doc with wordpad or notepad and once you figure it out which part of the slk doc is the actual data, pull it out and stick in your XSL tags.
You can then transform an xml doc into a slk doc. If your sending the slk doc down to the client via the response, set the content type to application/excel and Excel will open up your slk doc automtically.
I used the same solution and it works great.
If you set your content-type as application/vnd.ms-excel and format the data in an HTML table, this will be opened as excel in the browser (assuming you are using IE, I haven't tried it with netscape or others).
The main things to remember are that a) the html page should contain only a table (no html, head, body tags etc.)
and b) if you want formulae in your page you can do this by simply typing the formula as the content of the td (e.g. <td>=SUM(A1:A3)</td>
Hope this helps