tags:

views:

42

answers:

2

Hi all,

I have an excel spreadsheet that contains service delivery information for a single client at a time. For example, Max Inc will be provided with health assessments at 3 of their corporate offices. An office may have deliveries of health assessments (service type) on multiple days and performed by different doctors. I've created what I believe to be JavaBeans to ultimately represent all this information and the relationship between entities such as client, delivery, service, and individual sessions in a delivery. My problem now is, what is the best way to read in and parse the data from the excel spreadsheet? I was thinking I could create a static util class (like a factory class) that reads the excel spreadsheet (using Apache POI HSSF) in one method and then uses a variety of other methods to parse the data from the spreadsheet and then ultimately return a client object which contains all the other objects and so on. During some point during this process I also need some data from a SQL Server DB which I thought I will just pull in using JDBC as needed.

Am I heading in the right direction with this approach? Or would recommend doing this another way?

Thanks!

Max

A: 

Try simplifying this a little. Save the spreadsheet as a CSV file which is really easy to import into Java and subsequently into a database.

You could use a BufferedReader to read in the strings and split them at each delimiter ",". With each split String you will get an Array which you can add to your database.

Definitely try and avoid interfacing with Excel.

Jonniie
A: 

Simply reading cells from an Excel sheet is easy with POI. See: http://poi.apache.org/spreadsheet/quick-guide.html#CellContents

This will avoid any manual steps like converting to another format.
All you really need is a factory method to read in the spreadsheet and return back a list of objects. Then you can do your thing.

Romain Hippeau