Xssfcell. Cell_Type_Numeric Changes Value 0 to 25
Integrityrecords. Get(I). Get(2)="0"; Fieldsheet. getRow(1). getCell(3). setCellValue(integrityrecords. Get(I). Get(2)); System. Out. Println("Coulmn 1:" +...
integrityrecords.get(i).get(2)="0";
fieldsheet.getRow(1).getCell(3)
.setCellValue(integrityrecords.get(i).get(2));
System.out.println("coulmn 1 :" + integrityrecords.get(i).get(2));
I am trying get data from Database as an ArrayList of Strings and then writing it to excel using poi-3.14 XSSF. When i do so, I get the warning in excel cells where i am entering a number value in cell asking "Convert to Number". To overcome this, i use the additional code of setCellType().
fieldsheet.getRow(integrityStartRow).getCell(3).setCellType(XSSFCell.CELL_TYPE_NUMERIC);
When i do this, the cell value is changed to 25. This is happening for other decimal values that i enter into cell.
How to overcome this change?
1 Answer
setCellValue() should be called with the intended datatype. It seems you call it with a string-type, it should work better if you convert the string to a number before passing it in, then setCellType() should also not be necessary any more.
See also