mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-09-12 19:16:45 +00:00
Parameter Name Change Xlsx Writer Workbook
See issue #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).
This commit is contained in:
@@ -14,11 +14,11 @@ class Workbook extends WriterPart
|
||||
/**
|
||||
* Write workbook to XML format.
|
||||
*
|
||||
* @param bool $recalcRequired Indicate whether formulas should be recalculated before writing
|
||||
* @param bool $preCalculateFormulas If true, formulas will be calculated before writing
|
||||
*
|
||||
* @return string XML Output
|
||||
*/
|
||||
public function writeWorkbook(Spreadsheet $spreadsheet, bool $recalcRequired = false): string
|
||||
public function writeWorkbook(Spreadsheet $spreadsheet, bool $preCalculateFormulas = false): string
|
||||
{
|
||||
// Create XML writer
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
@@ -57,7 +57,7 @@ class Workbook extends WriterPart
|
||||
(new DefinedNamesWriter($objWriter, $spreadsheet))->write();
|
||||
|
||||
// calcPr
|
||||
$this->writeCalcPr($objWriter, $recalcRequired);
|
||||
$this->writeCalcPr($objWriter, $preCalculateFormulas);
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
@@ -146,9 +146,9 @@ class Workbook extends WriterPart
|
||||
/**
|
||||
* Write calcPr.
|
||||
*
|
||||
* @param bool $recalcRequired Indicate whether formulas should be recalculated before writing
|
||||
* @param bool $preCalculateFormulas If true, formulas will be calculated before writing
|
||||
*/
|
||||
private function writeCalcPr(XMLWriter $objWriter, bool $recalcRequired = true): void
|
||||
private function writeCalcPr(XMLWriter $objWriter, bool $preCalculateFormulas = true): void
|
||||
{
|
||||
$objWriter->startElement('calcPr');
|
||||
|
||||
@@ -157,10 +157,10 @@ class Workbook extends WriterPart
|
||||
// because the file has changed
|
||||
$objWriter->writeAttribute('calcId', '999999');
|
||||
$objWriter->writeAttribute('calcMode', 'auto');
|
||||
// fullCalcOnLoad isn't needed if we've recalculating for the save
|
||||
$objWriter->writeAttribute('calcCompleted', ($recalcRequired) ? '1' : '0');
|
||||
$objWriter->writeAttribute('fullCalcOnLoad', ($recalcRequired) ? '0' : '1');
|
||||
$objWriter->writeAttribute('forceFullCalc', ($recalcRequired) ? '0' : '1');
|
||||
// fullCalcOnLoad isn't needed if we arve calculating for the save
|
||||
$objWriter->writeAttribute('calcCompleted', ($preCalculateFormulas) ? '1' : '0');
|
||||
$objWriter->writeAttribute('fullCalcOnLoad', ($preCalculateFormulas) ? '0' : '1');
|
||||
$objWriter->writeAttribute('forceFullCalc', ($preCalculateFormulas) ? '0' : '1');
|
||||
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user