Reputation:
Has anyone used a Java based library for generating excel documents? Preferably support for 2003?
Upvotes: 4
Views: 3223
Reputation: 101
You can generate an excel file with a VBS and then cal the script from java like this:
String script = "your_VBS_Name.vbs"
String cmd = "D:\\YourPath" + script;
Runtime.getRuntime().exec(cmd);
to create the script is really simple
open notepad and follow the next example:
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
Set objWorkbook = objExcel.Workbooks.Add()
objWorkbook.SaveAs("D:\yourExcel.xls")
objExcel.Quit
and then save it as your_VBS_Name.vbs
Thats it!
Upvotes: 0
Reputation: 7866
I do it with Jacob as a general java and COM solution. However in my reading Jacob does not handle pretty well multiple calls (say millions of calls) and I needed to patch it a bit. These patches were not accepted by Jacob maintainer.
Anyway Jacob is open source (LGPL) and after patching it I have a production environment running for years yet.
After connecting to Excel with COM, you use standard Excel api to process documents. First you try how it works with VBS (VBScript Language Reference), then implement in java.
Upvotes: 1
Reputation: 792
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
Upvotes: 1
Reputation: 26846
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.
Upvotes: 6
Reputation: 8387
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).
Upvotes: 1
Reputation: 1446
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.
Upvotes: 1
Reputation: 19863
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
Upvotes: 6