Results 1 to 6 of 6
  1. #1
    ron87 is offline Member
    Join Date
    Mar 2009
    Posts
    52
    Rep Power
    0

    Default 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 ?

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,755
    Rep Power
    19

    Default

    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.

  3. #3
    ron87 is offline Member
    Join Date
    Mar 2009
    Posts
    52
    Rep Power
    0

    Default

    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

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,755
    Rep Power
    19

    Default

    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.

  5. #5
    ron87 is offline Member
    Join Date
    Mar 2009
    Posts
    52
    Rep Power
    0

    Default

    oh ok... i was confused for that reason..
    So i changed my code and now I am not reading data row-wise..
    Thanks

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,755
    Rep Power
    19

    Default

    Yep, Excel is fun like that.
    It's not a CSV, that's for sure.

Similar Threads

  1. Strange tab key focus traversal behavior in JTable
    By javaexplorer in forum AWT / Swing
    Replies: 0
    Last Post: 05-19-2010, 12:59 PM
  2. Strange behavior with java from command line
    By ocean in forum New To Java
    Replies: 1
    Last Post: 12-07-2009, 12:26 AM
  3. Replies: 6
    Last Post: 09-04-2009, 02:48 AM
  4. Strange behavior with Thread.sleep()
    By Steve11235 in forum Advanced Java
    Replies: 16
    Last Post: 05-04-2009, 05:24 AM
  5. strange refreshing behavior
    By diggitydoggz in forum New To Java
    Replies: 4
    Last Post: 12-27-2008, 04:51 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •