XML/HTML to Excel (.xls) Conversion
Hi,
Currently i'm working on a J2EE Project and in that project i generate some
HTML reports. Now I want to allow user to save this report as a Excel File.
Is that possible to convert HTML file in Excel file?
if yes, Which is better to use ? XML or some third party software?
Please Reply.
Thanks
[341 byte] By [
JChefa] at [2007-11-27 10:10:55]

# 1
Hi,
To generate Excel reports you need a third party library or framework.
See this web page: http://64.18.163.122/rgagnon/javadetails/java-0516.html
You'll find there the well-known tools to handle excel files.
The POI-HSSF project is the recommended tool. See http://poi.apache.org/hssf/index.html
It's used in some frameworks:
- JSF Comp: See http://www.jroller.com/page/mert?entry=jsfexcelcreator_is_now_in_jsf
- Spring: See http://www.springframework.org/docs/reference/view.html
Hope That Helps
# 2
POI-HSSF is an API to manipulate the Excel object model. You will therefore need to mechanisms to generate "screens"; one returns HTML - your current implementation and another to generate an Excel file. Good seperation of presentation from model would make this easy.
If you only want to export the "look" to Excel and not the "function" you could consider using XSTL to convert the HTML into Excel XML. This would not support "function" as macros are not supported in Excel XML.