easy spreadsheet processing with JExcel

Jul 14 2009

On a recent project we had the need to process Microsoft Excel spreadsheets. We chose to use an API, called JExcel, to read, write, and process Excel files. This post will focus on reading and processing an Excel spreadsheet.

To start you'll need to create a Workbook, which can be done by reading from a File or InputStream. Next, get each Sheet to process by calling .getSheets(). Need to be sure to close the workbook to free up resources by calling .close() once processing is complete.

Once you have a Sheet you can get each Row, which will be an Array of Cells and then get the contents of each Cell as a String. The API also gives you the ability to get a cell's value of a particular type (i.e. Number, Date, etc.). See the API documentation for examples.


*** Note - One downfall of the current version (2.6.10) is that it cannot read Microsoft 2007 Excel file version (.xlsx). Hopefully the next release will address this issue.

Tagged: captech, Java, JExcel

About the Author

Patrick Cox's picture

I am a Sun Certified Java Programmer in SE 6.0 and Web Component Developer in JavaEE 5.0 with over 6 years of software development experience. I currently work as an IT Consultant for CapTech Ventures in Richmond Virginia.

 

Disclaimer

The words and opinions expressed here are those of each article's respective author, and do not necessarily represent the views of CapTech Ventures.