Java Excel API - A Java API to read, write and modify Excel spreadsheets
This is the home page of Java Excel API - open source Java API which
allows Java developers to read Excel spreadsheets and to generate Excel
spreadsheets dynamically. In addition, it contains a mechanism which
allows java applications to read in a spreadsheet, modify some cells and
write out the new spreadsheet.
This API allows non Windows operating systems to run pure
Java applications which can both process and deliver Excel spreadsheets.
Because it is Java, this API may be
invoked from within a servlet, thus giving access to Excel functionality
over internet and intranet web applications.
Features
Limitations
Getting started
The distribution comes with a number of demo programs which illustrate how the API may be used.
Reading Spreadsheets
When reading a spreadsheet, the demo programs
may be used "as is" to convert Excel files to CSV and XML formats in
a reasonable manner.
java -jar jxl.jar -csv myspreadsheet.xls
To view the spreadsheet as XML, invoke the demo as follows
java -jar jxl.jar -xml myspreadsheet.xls
In order to present the data the demo uses the classes xlrd/CSV.java and
xlrd/XML.java respectively. For more sophisticated processing, these
classes may be used as a starting point. Click
here for a tutorial.
Generating Spreadsheets
The write demo illustrates the functionality accessible
within JExcelApi to generate spreadsheets. The spreadsheet
generated by the demo includes
different fonts, number formatting, date formatting, colours and borders.
To generate the demo spreadsheet, invoke JExcelApi as follows:
java -jar jxl.jar -write myspreadsheet.xls
This will generate the sample spreadsheet called myspreadsheet.xls
in the current working directory. The class used to generate this
spreadheet is jxl/Write.java. This may be used as a starting point
for bespoke processing.
Copying Spreadsheets
JExcelApi may be used to copy and modify a spreadsheet. Included with
the JExcelApi is a spreadsheet called jxlrwtest.xls, which is hardcoded
into the demo program. If this spreadsheet is passed as a command line
argument to the demo, then a copy of this spreadsheet will be
generated, with the second sheet containing modified values.
DO NOT MODIFY THE DEMO SPREADSHEET otherwise the modification demo will
not work.
To run this demo, from the directory containing jxlrwtest.xls type
java -jar jxl.jar -rw jxlrwtest.xls myoutput.xls
This will generate an output spreadsheet called myoutput.xls. The
first sheet (called "original") is unchanged, but the second sheet
(called "modified" has had its cell contents changed, as indicated
by the labels.
The class for the modification demo is jxl/ReadWrite.java.
Requirements
JExcelApi requires Java 2 JDK to run.
When dealing with large spreadsheets, particularly when using the
copy functionality, it is recommended that users allocate sufficient
memory to the JVM using the -Xms and -Xmx options on the java command
line.
Installation
JExcelApi comes packaged as a zipped tar file, called something like
jexcelapi_2_0.tar.gz. To unpack on UNIX systems, at the command
line type
gunzip jexcelapi_2_0.tar.gz
followed by
tar xf jexcelapi_2_0.tar
On Linux systems this can be accomplished within the single command
tar zxf jexcelapi_2_0.tar.gz
On Windows/NT systems, the archive may be unpacked visually using a
utility such as Winzip.
Whatever the unpacking process, the application will be placed in a
subdirectory called jexcelapi. The top level directory contains this
html page and the
pre-built jar file, jxl.jar.
The docs directory contains the javadoc documentation for the public
classes, the build directory contains the buildfile (requires
ant
) and the src directory
contains the source code for the java classes.
Excel Versions
JExcelApi will read workbooks created in Excel 95, 97 and 2000, and will generate workbooks that can be read by Excel 97 and later.
Licensing
JExcelApi is issued on under the GNU Lesser General Public License. For further information click here.
Further Notes
A tutorial is available for those who wish guidance on how to use the API for reading, writing and copying spreadsheets.
When writing out spreadsheets, JExcelApi has limited support for graphs charts and macros during the copy process, but they cannot be created via the API.
For further technical information, including how JExcelApi handles dates and unicode characters, read the technical notes
Download JExcelApiMake a Donation
JExcelApi is free software and will remain so. If JExcelApi has been of benefit to you or your company, perhaps you might like to make a voluntary donation to JExcelApi using PayPalThis site last updated 10th April, 2005