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));

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

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like