Results 1 to 6 of 6
- 09-12-2010, 07:52 AM #1
Member
- Join Date
- Mar 2009
- Posts
- 52
- Rep Power
- 0
Strange behavior of getrow(n) method of Sheet interface in jxl api
I am processing an excel sheet having 20 rows and 20 columns.
I am reading excel sheet row by row. Using sheet.getrow(n) method.
The excel sheet does not contain data for all columns.
I am able to read rows who have data only for 19 columns.
There is one row (rownumber=18) in sheet which has data till 12 columns.
So in my code when i call sheet.getrow(18) , it returns me array of length 12 and not 20. (though column count is 20)
But although some other rows have data till 19th column it returns me array of size 20 and not 19.
Quiet strange behavior..!
Does anyone know solution to this ?
- 09-13-2010, 10:10 AM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
There's no solution.
That's Excel, which seems to only hold data for cells that have data in...but sometimes also notes empty cells. So the "extra" cell in the rows with 19 data cells is one of those exceptions.
Of course this does beg the question of what problem this is causing you, since you are asking for a solution.
- 09-13-2010, 10:16 AM #3
Member
- Join Date
- Mar 2009
- Posts
- 52
- Rep Power
- 0
But for the row in which 20th cell is empty... the method returns me an empty string
Then for the row having 13 data cells and remaining 7 empty the method should return me 13 data cells and 7 empty strings... but its not doing that... it only returns me 13 data cells
- 09-13-2010, 10:23 AM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
No.
Excel does not guarantee that there is something in its file for every empty cell.
Consequently, as you are seeing, you will simply not have a Cell at all.
In POI, for example, (method names not necessarily accurate) row.getCell(1) might return null, even if row.getCell(2) returns something.
JExcel has a similar thing.
- 09-13-2010, 10:25 AM #5
Member
- Join Date
- Mar 2009
- Posts
- 52
- Rep Power
- 0
oh ok... i was confused for that reason..
So i changed my code and now I am not reading data row-wise..
Thanks
- 09-13-2010, 11:02 AM #6
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Similar Threads
-
Strange tab key focus traversal behavior in JTable
By javaexplorer in forum AWT / SwingReplies: 0Last Post: 05-19-2010, 12:59 PM -
Strange behavior with java from command line
By ocean in forum New To JavaReplies: 1Last Post: 12-07-2009, 12:26 AM -
Strange JFILECHOOSER behavior on Macs with ZIP files
By TimHuey in forum New To JavaReplies: 6Last Post: 09-04-2009, 02:48 AM -
Strange behavior with Thread.sleep()
By Steve11235 in forum Advanced JavaReplies: 16Last Post: 05-04-2009, 05:24 AM -
strange refreshing behavior
By diggitydoggz in forum New To JavaReplies: 4Last Post: 12-27-2008, 04:51 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks