title: Apache POI: Getting wrong number/string values reading from xlsx while xls is workfing fine
body: <p>i have two excel-sheets (one .xls, one .xlsx) with content "1234567891234.56" in cell A1. </p>
  
  <p>Now im trying to get this content into my java-app, using Apache POI like this:</p>
  
  <pre><code>    private String getValue(Cell myCell, int myCelltype)
          throws CellAccessException {
      try {
  
          switch (myCelltype) {
  
          case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_STRING:
  
              return myCell.getStringCellValue();
  </code></pre>
  
  <p>...</p>
  
  <p>First thing is, CellType (myCell.getCellType()) is always 1 (String), no matter how i format the cell itself. </p>
  
  <p>Second, when i am reading from xlsx, i got "1234567891234.5601" while reading from xls, i got "1234567891234.56" which is the result i expect.</p>
  
  <p>Another example is "12345678912345.6" in the files and "12345678912345.602" as result reading from xlsx. </p>
  
  <p>I have no idea, what's causing my problems and nobody else seems to have similar ones.</p>
  
  <p>I would appreciate any help you can give.</p>
  
  <p>Thanks in advance and greetings from germany.
  Ausric</p>
  
  <p>Edit:
  Thanks for comments and answer. Sadly, formatting the return value doesn't help since the problem is getting the right value from the excel sheet.
  While researching the unchanging CELL_TYPE i made a strange observation:
  As i read from the xls(!) file i got the right value as String (in this case 1.23456789123456E+20 ). Next, this String is converted into Double.</p>
  
  <pre><code>String content = myCell.getStringCellValue();
  System.out.println(result + "#" +result.length());
  Double dresult = Double.valueOf(result);
  System.out.println(dresult);
  </code></pre>
  
  <p>And the output looks like this:</p>
  
  <p>1.23456789123456E+20#20</p>
  
  <p>1.2345678912345601E20</p>
  
  <p>So i startet thinking, i've got this error by reading from cells in xlsx which are numbers but marked as celltype STRING and by converting String into Double. Is there something wrong with Double ? Maybe we got some old Java Version here and Double was broken. I don't think it's poi's fault since it's 3.10 FINAL and should be working fine. Or is Double doing something while converting this String i just don't understand ? I am new to Java and to this job...just struggling through.</p>