• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Read a range of cells in MS Excel using POI API

 
Gunjan Rathii
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would be really thankful if someone can guide me towards the solution.
 
Gunjan Rathii
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please suggest.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Gunjan Rathii
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will likely have to write your own method for this.
 
Gunjan Rathii
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic