Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Does anyone have any suggestions as to why the first formula does not calculate the value, but the second formula does? Both formulas are in the same script using Spreadsheet::WriteExcel.
First formula:
my $statusCaseNumFormula = '=COUNTIF($I$3:$I$1000,$A$'; my $caseNumFormulaEnder = ')'; my $caseNumFormulaCounter = 4; my $formula = ''; my $row = 4; $caseNumFormulaCounter = $row + 1; $formula = $statusCaseNumFormula . $caseNumFormulaCounter . $caseN +umFormulaEnder; $gray25percentFormat->set_align('right'); $worksheet->write_formula($row,$col, $formula, $gray25percentForma +t);

Second formula:
my $formulaCounter = $row + 1; $formula = '=TODAY() - ROUNDDOWN($D$' . $formulaCounter . ',0)'; $worksheet->write_formula($row, $col, $formula, $dateFormatNormal) +;

The first formula is actually written in the spreadsheet, but it does not calculate the value. After I open the spreadsheet, I can click on the cell, click on the formula icon (fx) next to the formula bar, hit enter and it calculates the value then, but it does not automatically calculate the value. The second formula is written and calculates just fine.

Replies are listed 'Best First'.
Re: Spreadsheet::WriteExcel formula confusion
by jmcnamara (Monsignor) on Jun 29, 2007 at 22:21 UTC

    There are some formulas with mixed internal classes that Spreadsheet::WriteExcel doesn't parse correctly. The effect is as you describe; Excel doesn't calculate the formula correctly until it is forced to. This is a known issue.

    If you post a small working example to the Spreadsheet::WriteExcel Google Group I can suggest a workaround.

    --
    John.