views:

6499

answers:

11

I need to read a Excel 2007 xlsx file in a java application. Does anyone know of a good api to accomplish this task?

Thanks in advance for any advice given.

-MrPortico

+1  A: 

I had to do this in .NET and I couldn't find any API's out there. My solution was to unzip the .xlsx, and dive right into manipulating the XML. It's not so bad once you create your helper classes and such.

There are some "gotchas" like the nodes all have to be sorted according to the way excel expects them, that I didn't find in the official docs. Excel has its own date timestamping, so you'll need to make a conversion formula.

hova
A: 

Have you looked at the poorly obfuscated API?

Nevermind:

HSSF is the POI Project's pure Java implementation of the Excel '97(-2007) file format. It does not support the new Excel 2007 .xlsx OOXML file format, which is not OLE2 based.

You might consider using a JDBC-ODBC bridge instead.

Josh
A: 

I don't know if it is up to date for Excel 2007, but for earlier versions I use the JExcelAPI

NR
A: 

AFAIK there are no xlsx-libraries available yet. But there are some for old xls:

One library is jxls which internally uses the already mentioned POI.

2 other links: Handle Excel files, Java libraries to read and write Excel XLS document files.

Tobias Schulte
A: 

This one maybe work for you, it can read/write Excel 2007 xlsx file. SmartXLS

+1  A: 

I'm not very happy with any of the options so I ended up requesting the file in Excel 97 formate. The POI works great for that. Thanks everyone for the help.

MrPortico
+1  A: 

Might be a little late, but the beta POI now supports xlsx.

Galbrezu
+3  A: 

Apache POI 3.5 have added support to all the OOXML (docx, xlsx, etc.)

See the XSSF sub project

David Rabinowitz
A: 

i have one query I have used jdbc-odbc bridge but it uses sql query to fetch the data So it depends on name of sheet whatever we have given in workbook But i want to make it independent of sheet name Can anybody help me?

thanks in advance

Aditi

aditi
You're more likely to get a response if you post that as a new question from http://stackoverflow.com/questions/ask
Simon Lieschke
A: 

http://poi.apache.org/spreadsheet/quick-guide.html
this link should help. XLSX and DOCX

Boaz
A: 

docx4j now covers xlsx as well.

"Why would you use docx4j to do this", I hear you ask, "rather than POI, which focuses on xlsx and binary xls?"

Probably because you like JAXB (as opposed to XML Beans), or you are already using docx4j for docx or pptx, and need to be able to do some stuff with xlsx as well.

Another possible reason is that the jar XML Beans generates from the OpenXML schemas is too big for your purposes. (To get around this, POI offers a 'lite' subset: the 'big' ooxml-schemas-1.0.jar is 14.5 MB! But if you need to support arbitrary spreadsheets, you'll probably need the complete jar). In contrast, the whole of docx4j/pptx4j/xlsx4j weighs in at about the same as POI's lite subset.

If you are processing spreadsheets only (ie not docx or pptx), and preceding paragraph is not a concern for you, then you would probably be best off using POI.

plutext