Reading from Microsoft Excel in Java

B

Brian J. Sayatovic

I have the need to read data from an Excel file. The data is really
simply homogenuous records, along with a header row that describes the
records in the rows beneath it. Naturally, I investigated my options,
but none have proven to do quite what I want yet. Here's the
requirements I have:

- Can be restricted to Windows only
- Shouldn't involve me writing JNI directly
- Shouldn't involve doing any pre-processing to the spreadsheet
- Must be able to read literal values from cells
- Must be able to read calculated values from cells.

Here's the solutions I've been investigating:

JCom (http://www.hcn.zaq.ne.jp/no-ji/jcom/index_eng.htm)
====
- Javadocs in Japanese
- Doesn't expose full Excel functionality (i.e. Range.Offset)

JACOB (http://danadler.com/jacob/)
=====
- Low-level COM, but I used Jacobgen
(http://www.bigatti.it/projects/jacobgen/) to overcome this
- Generated code resulted in C0000005 access violations

POI-HSSF (http://jakarta.apache.org/poi/hssf/index.html)
========
- Doesn't support calculated values (you get the literal formula)

This is a simple little project, and I don't want ot invest in any
expensive commercial ware. The next thing I'm going to investigate is
the ODBC driver for Excel accessed via the JDBC-ODBC bridge, but I
won't be able to set up a DSN for each spreadsheet I want to read.

Anyone else have any experience with this?
 
S

Shripathi Kamath

Brian J. Sayatovic said:
I have the need to read data from an Excel file. The data is really
simply homogenuous records, along with a header row that describes the
records in the rows beneath it. Naturally, I investigated my options,
but none have proven to do quite what I want yet. Here's the
requirements I have:

- Can be restricted to Windows only
- Shouldn't involve me writing JNI directly
- Shouldn't involve doing any pre-processing to the spreadsheet
- Must be able to read literal values from cells
- Must be able to read calculated values from cells.


If you have to just read from an Excel file, you can simply read the text in
using FileInputStream and family, and do with it as you please. You may
choose to save the file in a .csv format.

I suspect that you need to read from Excel itself. Depending upon the
version of MS Excel, you can do using automation, and JActiveX. With your
restrictions, you would likely be restricted to using the MS VM. If you
have a Visual J++ v 6.0, you should be able to do this.


HTH,


--
Shripathi Kamath
NETAPHOR SOFTWARE INC.
http://www.netaphor.com


<snip>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top