sabato 26 gennaio 2008

Leggere o scrivere foglie di Excel

There are many solutions to read or write Excel spreadsheets from Java. This HowTo is only about OpenSource (and free) solutions.

JDBC-ODBC Excel driver

This solution lets you access your Excel worksheet with SQL SELECT statement. The required ODBC driver is included in a regular Windows installation and the JDBC-ODBC bridge is used to access the Excel DSN.

See this HowTo for an example.

JExcel

Java Excel API is a java API enabling developers to read, write, and modify Excel spreadsheets dynamically. Any operating system which can run a Java virtual machine can both process and deliver Excel spreadsheets. One nice thing about JExcelApi is that it has no dependencies on any third party libraries.

See http://jexcelapi.sourceforge.net/

POI

The POI project consists of APIs for manipulating various file formats based upon Microsoft's OLE 2 Compound Document format using pure Java. POI is your Java Excel solution as well as your Java Word solution.

HSSF is the POI Project's pure Java implementation of the Excel '97(-2002) file format and it provides a way to read spreadsheets create, modify, read and write XLS spreadsheets.

Since it's Jakarta project, POI has a dependencies with other JARs (commons,log4j,etc...).



The name was originally an acronym for "Poor Obfuscation Implementation" (ref: Wikipedia).

See http://jakarta.apache.org/poi/

JXLS

jXLS is a project that allows creation of extremely complex Excel reports just in several lines of code. It is based on Jakarta POI.

With jXLS, all you need is to create XLS template file with all required formatting, formulas etc using specific notation to indicate placement of data and then write a couple lines of code to invoke jXLS engine passing XLS template and the exported data as parameters.

See http://jxls.sourceforge.net/

xlSQL

xlSQL is a JDBC Driver for Excel and CSV data sources. Documents can be read and written with SQL as if they were tables in a database.

You can export XLS to XML or SQL INSERT statements. xlSQL includes its own "zero-admin" mySQL database. The documentation is minimal at this time.

See http://xlsql.sourceforge.net/

JCOM

JCOM is a Java to COM bridge library. With JCOM you can call a COM object from Java as if it were a Java object without having to deal with the internals of JNI. The documentation is minimal (in Japanese!).

See http://sourceforge.net/projects/jcom

See also this HowTo for an alternative package to access a COM package from Java.

OpenXLS Java Spreadsheet SDK

OpenXLS claims that it has the best compatibility with complex Excel files and able to handle any kind of Excel file out there without corrupting it. This open source effort is the result of over 6 years of development into it.

See http://www.extentech.com/estore/product_detail.jsp?product_group_id=228

See also this HowTo for a way to create a simple XLS without any additional library.

Nessun commento: