Skip to content

Commit 4db909c

Browse files
committed
Parameter Name Change Xlsx Writer Workbook
See issue PHPOffice#4108. Parameter recalcRequired is a complete misnomer. While we can get along without changing it, I think we should strive for accuracy. Execution logic is unchanged, and existing tests are adequate. This isn't really intended as a public interface, and, even if is being used by someone out there, it will be a problem only for people calling the parameter by name. So the chances of a problem are very low, and the workaround is very easy (call positionally).
1 parent b406367 commit 4db909c

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/PhpSpreadsheet/Writer/Xlsx/Workbook.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ class Workbook extends WriterPart
1414
/**
1515
* Write workbook to XML format.
1616
*
17-
* @param bool $recalcRequired Indicate whether formulas should be recalculated before writing
17+
* @param bool $preCalculateFormulas If true, formulas will be calculated before writing
1818
*
1919
* @return string XML Output
2020
*/
21-
public function writeWorkbook(Spreadsheet $spreadsheet, bool $recalcRequired = false): string
21+
public function writeWorkbook(Spreadsheet $spreadsheet, bool $preCalculateFormulas = false): string
2222
{
2323
// Create XML writer
2424
if ($this->getParentWriter()->getUseDiskCaching()) {
@@ -57,7 +57,7 @@ public function writeWorkbook(Spreadsheet $spreadsheet, bool $recalcRequired = f
5757
(new DefinedNamesWriter($objWriter, $spreadsheet))->write();
5858

5959
// calcPr
60-
$this->writeCalcPr($objWriter, $recalcRequired);
60+
$this->writeCalcPr($objWriter, $preCalculateFormulas);
6161

6262
$objWriter->endElement();
6363

@@ -146,9 +146,9 @@ private function writeWorkbookProtection(XMLWriter $objWriter, Spreadsheet $spre
146146
/**
147147
* Write calcPr.
148148
*
149-
* @param bool $recalcRequired Indicate whether formulas should be recalculated before writing
149+
* @param bool $preCalculateFormulas If true, formulas will be calculated before writing
150150
*/
151-
private function writeCalcPr(XMLWriter $objWriter, bool $recalcRequired = true): void
151+
private function writeCalcPr(XMLWriter $objWriter, bool $preCalculateFormulas = true): void
152152
{
153153
$objWriter->startElement('calcPr');
154154

@@ -157,10 +157,10 @@ private function writeCalcPr(XMLWriter $objWriter, bool $recalcRequired = true):
157157
// because the file has changed
158158
$objWriter->writeAttribute('calcId', '999999');
159159
$objWriter->writeAttribute('calcMode', 'auto');
160-
// fullCalcOnLoad isn't needed if we've recalculating for the save
161-
$objWriter->writeAttribute('calcCompleted', ($recalcRequired) ? '1' : '0');
162-
$objWriter->writeAttribute('fullCalcOnLoad', ($recalcRequired) ? '0' : '1');
163-
$objWriter->writeAttribute('forceFullCalc', ($recalcRequired) ? '0' : '1');
160+
// fullCalcOnLoad isn't needed if we arve calculating for the save
161+
$objWriter->writeAttribute('calcCompleted', ($preCalculateFormulas) ? '1' : '0');
162+
$objWriter->writeAttribute('fullCalcOnLoad', ($preCalculateFormulas) ? '0' : '1');
163+
$objWriter->writeAttribute('forceFullCalc', ($preCalculateFormulas) ? '0' : '1');
164164

165165
$objWriter->endElement();
166166
}

0 commit comments

Comments
 (0)