PHPOffice/PhpSpreadsheet

Incorrect Attribute Value for forceFullCalc in writeCalcPr Method

heikyomuraichi opened this issue · 2 comments

$objWriter->writeAttribute('forceFullCalc', ($recalcRequired) ? '0' : '1');

Issue Summary
The writeCalcPr method in the class contains an incorrect attribute value for forceFullCalc. The current implementation sets forceFullCalc to 0 when $recalcRequired is true, and to 1 when $recalcRequired is false. This seems to be the opposite of the intended behavior.

Suggested Fix
The attribute forceFullCalc should be set to 1 when $recalcRequired is true, and to 0 when $recalcRequired is false. This would correctly reflect the need for a full recalculation when recalcRequired is true.

$objWriter->writeAttribute('forceFullCalc', ($recalcRequired) ? '1' : '0'); 

I believe PhpSpreadsheet is producing the desired result, but the parameter is, unfortunately, misnamed. When preCalculateFormulas (and therefore recalcRequired) is false, I see the following in the output:

<calcPr calcId="999999" calcMode="auto" calcCompleted="0" fullCalcOnLoad="1" forceFullCalc="1"/>

When it's true, I see the following:

<calcPr calcId="999999" calcMode="auto" calcCompleted="1" fullCalcOnLoad="0" forceFullCalc="0"/>

I think that both are as they should be. Do you have an example where you feel otherwise?

Thank you for the clarification. I understand now that the actual behavior of the writeCalcPr method is correct and that the naming of the parameter might be a bit misleading. I don't have an example where the current implementation produces incorrect results. It was a misunderstanding on my part.

Thank you for your assistance and explanation.