I am using 3.5 beta 5 ss usermodel.
When I attempt to set a cell containing a formula to another value, it seems to
corrupt the workbook. Setting it to a String will cause excel to do a rapair
on the workbook when opening it, resulting in the formula still as the cell
value. Changing it to a number will cause the value showing to be the number.
However, in the formula bar, the formula still shows as the cell value. It is
like the cell somehow has both the number and formula value at the same time.
Did I find a bug or do I just not understand what I am doing?
Example code:
String xlsxFilePath = "Path to a new .xlsx file";
FileInputStream in = new FileInputStream(xlsxFilePath);
Workbook wb = WorkbookFactory.create(in);
Sheet sh = wb.getSheet("Sheet1");
Row row = sh.createRow(1);
Cell cell = row.createCell(1);
cell.setCellFormula("NA()");
//comment out 1 of the 2 following lines when testing
cell.setCellValue("Help, I will not change!"); //corrupts workbook
cell.setCellValue(200); //shows 200 but real value is NA()
in.close();
FileOutputStream out = new FileOutputStream(xlsxFilePath);
wb.write(out);
out.close();
Any suggestions are greatly appreciated.
Paul Dobson
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]