On Mon, 4 Feb 2013, zephod wrote:
I using Apache POI for Java to set formulas in Excel cells. I'm using the following code to make the formulas appear as formulas rather than as Strings:

 // "cell" object previously created or looked up
 String StrFormula = "SUM(\"A1:A10\")";
 cell.setCellType(HSSFCell.CELL_TYPE_FORMULA);
 cell.setCellFormula(strFormula);

You shouldn't need to set the cell type, the setCellFormula call will do that for you

There are some functions (introduced in Excel 2007) like SUMIFS, COUNTIFS. IFERROR, AVERAGEIFS that cause the cell to contain a String. It is necessary to click+enter every such cell in Excel for the formula to get recognized.

Are you triggering a formula recalculation at the end of the processing of the file? Excel caches formula values, so you'll need to update those when you're done making changes

Nick

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to