tags:

views:

343

answers:

6

Has anyone used a Java based library for generating excel documents? Preferably support for 2003?

+4  A: 

Whenever I have to do this I ask myself if one big html table would be enough.

much of the time it is. You can simply write html tags and label it as a .xls file. Excel will open it correctly

Eric
+1 :-) WOW nice trick
Blauohr
+1  A: 

JExcelApi

I've used it personally for a report that is currently in production. It's a fairly decent library with sufficient docs, and it's open source.

It works very well, but has a few gotchas you should be aware of. None of them are deal breakers, just dictate how a few things should be done. Just be sure to read the FAQ. It will explain them and tell you how to avoid them.

Trampas Kirk
+1  A: 

A formatted HTML table will import correctly, but it would be better to use the Excel XML format from the Excel 2003 XML Toolbox for more advanced needs (multiple worksheets, formulas, etc).

devstuff
Just as a sidenote formulas within a simple HTML table saved as .xls work fine. Whenever something more complex is needed it possible to devise a "template" workbook in Excel, save as XML, then rename that XML into .xls (Excel handles the file just fine), then use the XML file as a template inserting missing info.http://poi.apache.org/ also works fine.
Totophil
As mentioned to another answer, the user is generating hundreds of reports daily and to import each one into excel is a huge waste of time. Need to generate the file directly for the user.
predhme
When I say report, i mean CSV, PDFs, etc. The requirement is to instead of the user having to import the CSV into excel, have the excel file already made for them.
predhme
+4  A: 

I'm currently working with Apache POI, ( http://poi.apache.org/index.html ) which is very comprehensive. The 2003 file format version is still in beta, but seems to work well enough. I'm not exercising it's power very much, just straightforward reads and writes of Excel, but it seems reliable.

DJClayworth
Apache seems to offer a library for everything. POI seems to offer exactly what we are looking for. Thanks alot!
predhme
Although, as I stated below, we are generating CSV files already. Can POI import those and generate an excel file. The users of the app are already generating hundreds of files daily, importing each one is becoming a huge waste of time.
predhme
pjp
+2  A: 

If you don't need fancy headings then just output CSV.

pjp
The application already generates CSV files. Several users generate hundreds of files a day that they later generate reports. One file to import into excel is fine, but hundreds daily becomes an unnessary time consuming step. Rather, they want that part taken care of... I.e generating the excel file for them.
predhme
Although, since we are already generating the CSV of data, can the "import" process be programmatically done through java?
predhme
How exactly are you importing hundreds of files into Excel? Do they appears on different sheets? are they aggregated together? Are you currently using VBA to do this?
pjp
Well no. The system generates the CSV files. The user then downloads all the CSV's and then opens each one by one with excel. Each time they are presented with a series of dialogs to get the file opened. I want to give the user the option of instead of generating CSV's to generate an EXCEL file.
predhme
+1  A: 

You can also try SmartXLS for java, it have more functions than poi and jexcelapi,and it is a commercial product.

http://www.smartxls.com/indexj.htm

liya