views:

311

answers:

2

Currently I am using Apache POI for java to set formulas for cells, but the problem is after I run the program, and open the excel file that i created and processed with my java program, the cells with the formula included the formula as a string, rather than the value the formula should have returned.

+1  A: 

The HSSFCell object has methods .setCellType and .setCellFormula which you need to call like this:

// "cell" object previously created or looked up
String StrFormula = "SUM(\"A1:A10\")";
cell.setCellType(HSSFCell.CELL_TYPE_FORMULA);
cell.setCellFormula(strFormula);
Ninefingers
let me try that real quick.
vamsi
Nope that didn't work. Basically im using a custom formula that is not by default supported by excel. Would there be any problems with user defined formulas?
vamsi
I wouldn't have thought so, but then I've never tried it. I see no reason why not; it should just fill the cell with =strFormula but perhaps it does something else.
Ninefingers
A: 

I am also unable to put my custom formulas. Can any one have the solution for this?

Vikas