Results 1 to 2 of 2
  1. #1
    vector_ever is offline Senior Member
    Join Date
    Jul 2013
    Posts
    187
    Rep Power
    2

    Default java.lang.IllegalStateException: Cannot get a text value from a numeric cell

    Hello,
    I am trying to read from Excel file, ans as know when the cell is complete text then it is String type and if numeric then Double.
    The Problem i tried to read a cell (Street column) which have mixed value type (string and numeric) for example :Johann-Wax-Str. 6

    I used to read the cell if String
    Java Code:
    row.getCell(5).getStringCellValue()
    and if Numeric
    Java Code:
    Double.toString(row.getCell(6).getNumericCellValue()
    I supposed that the column Street (which is String & numeric) can be readed correctly with:
    Java Code:
    Double.toString(row.getCell(6).getNumericCellValue()
    but that doesn't work, i get error
    XML Code:
    java.lang.IllegalStateException: Cannot get a text value from a numeric cell
    I looked up for proper Instruction in Poi documentation but i do'nt find solution to read cell which have String and numeric
    So what the wrong and how to fix it?

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,036
    Rep Power
    20

    Default Re: java.lang.IllegalStateException: Cannot get a text value from a numeric cell

    If the contents of the cell are "Johann-Wax-Str. 6", then that's a String.
    So read it using getStringCellValue().

    If that still causes a problem then port the full exception text, including the stack trace.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Replies: 7
    Last Post: 09-26-2012, 01:32 PM
  2. Replies: 12
    Last Post: 09-17-2010, 12:40 AM
  3. GUI with java.lang.IllegalStateException
    By eckt in forum AWT / Swing
    Replies: 4
    Last Post: 06-14-2010, 10:32 AM
  4. Replies: 2
    Last Post: 12-14-2009, 01:46 AM
  5. Replies: 13
    Last Post: 09-07-2009, 04:32 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
  •