File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other Open Source Projects and the fly likes Read a range of cells in MS Excel using POI API Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Read a range of cells in MS Excel using POI API" Watch "Read a range of cells in MS Excel using POI API" New topic
Author

Read a range of cells in MS Excel using POI API

Gunjan Rathii
Greenhorn

Joined: Mar 02, 2011
Posts: 8
I need to read a range of cells in MS Excel using POI API (as I have already created stuffs using it in my current project).
The inputs to my application are:
1. FileName
2. SheetName
3. Cell Range i.e D10 to D20

I am trying to find a way out to read and iterate over these range of cells and get the values.
Please suggest.
Gunjan Rathii
Greenhorn

Joined: Mar 02, 2011
Posts: 8
I would be really thankful if someone can guide me towards the solution.
Gunjan Rathii
Greenhorn

Joined: Mar 02, 2011
Posts: 8
Please suggest.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39537
    
  27
The POI web site has extensive code examples. Iterating over rows and columns to read cells from a spreadsheet is covered there. If that's not enough, tell us what you have so far, and where you're stuck making progress.


Ping & DNS - updated with new look and Ping home screen widget
Gunjan Rathii
Greenhorn

Joined: Mar 02, 2011
Posts: 8
Iterating through rows and columns is okay with me. I am looking for a solution something like :


The method will take inputs as:
1. xls file
2. sheet name
3. A10:A20

So here the catch is the 3rd argument where I am passing a cell range as a String.
What I am looking for is a method in POI API which will take this String as an input and process the cell data accordingly.

Or else I will have to create my own method which would interpret the cellRange into rows and columns and iterate over it for the values.
I am unable to find a direct method in POI API as of now.
Maybe I am missing/overlooking something. Since my application is using POI, I do not want to look for any other API for now. Please help.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39537
    
  27
You will likely have to write your own method for this.
Gunjan Rathii
Greenhorn

Joined: Mar 02, 2011
Posts: 8
Thanks for your reply.
Below is a small piece of code which fulfills my requirement but unfortunately it is not an open source API (JExcel 1.5)



The requirement has been taken care as of now by creating a method which will take the cellRange as an input string and will iterate over the rows and columns accordingly.
Though, I tried to search a lot and was expecting a method in the POI API itself which would have solved the purpose.

Anyways, Thanks for your response.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Read a range of cells in MS Excel using POI API
 
Similar Threads
$ symbol not displayed properly in excel
saving excel file into an image
inserting image in excel using POI api
How to read Microsoft Excel (97, 2003, 2007) through OpenOffice API
Generate Filter Cells For Excel Sheets Using POI HSSF