diff --git a/src/PhpSpreadsheet/Writer/Xls.php b/src/PhpSpreadsheet/Writer/Xls.php index c17feedce..f9a0a3d8c 100644 --- a/src/PhpSpreadsheet/Writer/Xls.php +++ b/src/PhpSpreadsheet/Writer/Xls.php @@ -190,7 +190,7 @@ class Xls extends BaseWriter $worksheetSizes = []; for ($i = 0; $i < $countSheets; ++$i) { $this->writerWorksheets[$i]->close(); - $worksheetSizes[] = $this->writerWorksheets[$i]->_datasize; + $worksheetSizes[] = $this->writerWorksheets[$i]->getBiffDataSize(); } // add binary data for global workbook stream diff --git a/src/PhpSpreadsheet/Writer/Xls/BIFFwriter.php b/src/PhpSpreadsheet/Writer/Xls/BIFFwriter.php index a9097835c..ae8fa6bb9 100644 --- a/src/PhpSpreadsheet/Writer/Xls/BIFFwriter.php +++ b/src/PhpSpreadsheet/Writer/Xls/BIFFwriter.php @@ -19,12 +19,12 @@ class BIFFwriter /** * The string containing the data of the BIFF stream. */ - public ?string $_data; + protected ?string $biffData; /** - * The size of the data in bytes. Should be the same as strlen($this->_data). + * The size of the data in bytes. Should be the same as strlen($this->biffData). */ - public int $_datasize; + protected int $biffDataSize; /** * The maximum length for a BIFF record (excluding record header and length field). See addContinue(). @@ -38,8 +38,8 @@ class BIFFwriter */ public function __construct() { - $this->_data = ''; - $this->_datasize = 0; + $this->biffData = ''; + $this->biffDataSize = 0; } /** @@ -76,12 +76,12 @@ class BIFFwriter if (strlen($data) - 4 > $this->limit) { $data = $this->addContinue($data); } - $this->_data .= $data; - $this->_datasize += strlen($data); + $this->biffData .= $data; + $this->biffDataSize += strlen($data); } /** - * General storage function like append, but returns string instead of modifying $this->_data. + * General storage function like append, but returns string instead of modifying $this->biffData. * * @param string $data binary data to write */ @@ -90,7 +90,7 @@ class BIFFwriter if (strlen($data) - 4 > $this->limit) { $data = $this->addContinue($data); } - $this->_datasize += strlen($data); + $this->biffDataSize += strlen($data); return $data; } @@ -181,4 +181,9 @@ class BIFFwriter return $tmp; } + + public function getBiffDataSize(): int + { + return $this->biffDataSize; + } } diff --git a/src/PhpSpreadsheet/Writer/Xls/Workbook.php b/src/PhpSpreadsheet/Writer/Xls/Workbook.php index d159cab9c..6c4c6bce7 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Workbook.php +++ b/src/PhpSpreadsheet/Writer/Xls/Workbook.php @@ -427,9 +427,9 @@ class Workbook extends BIFFwriter } // Add part 3 of the Workbook globals - $this->_data .= $part3; + $this->biffData .= $part3; - return $this->_data; + return $this->biffData; } /** @@ -440,7 +440,7 @@ class Workbook extends BIFFwriter $boundsheet_length = 10; // fixed length for a BOUNDSHEET record // size of Workbook globals part 1 + 3 - $offset = $this->_datasize; + $offset = $this->biffDataSize; // add size of Workbook globals part 2, the length of the SHEET records $total_worksheets = count($this->spreadsheet->getAllSheets()); diff --git a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php index 6da5a81ee..022d98721 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php @@ -605,9 +605,9 @@ class Worksheet extends BIFFwriter public function getData(): string { // Return data stored in memory - if (isset($this->_data)) { - $tmp = $this->_data; - $this->_data = null; + if (isset($this->biffData)) { + $tmp = $this->biffData; + $this->biffData = null; return $tmp; }