From 7f07ab29145f5068360ac98f135228e033262f5b Mon Sep 17 00:00:00 2001 From: Xavier Noguer Gallego Date: Mon, 10 Nov 2003 13:09:41 +0000 Subject: [PATCH] BIFF8 now working on Excel git-svn-id: https://svn.php.net/repository/pear/packages/Spreadsheet_Excel_Writer/trunk@144068 c90b9560-bf6c-de11-be94-00142212c4b1 --- Writer/Workbook.php | 16 ++++++++++++---- Writer/Worksheet.php | 25 +++++++++++++------------ 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/Writer/Workbook.php b/Writer/Workbook.php index 396815a..d63f9b4 100644 --- a/Writer/Workbook.php +++ b/Writer/Workbook.php @@ -555,14 +555,21 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri */ function _calcSheetOffsets() { - $BOF = 11; - $EOF = 4; - $offset = $this->_datasize; + $boundsheet_length = 12; // fixed length for a BOUNDSHEET record + $EOF = 4; + $offset = $this->_datasize; + + // add the length of the SST + $offset += 12; // FIXME: update when updating _storeSharedStringsTable() + // add the lenght of SUPBOOK, EXTERNSHEET and NAME records + $offset += 0; // FIXME: calculate real value when storing the records $total_worksheets = count($this->_worksheets); + // add the length of the BOUNDSHEET records for ($i=0; $i < $total_worksheets; $i++) { - $offset += $BOF + strlen($this->_worksheets[$i]->name); + $offset += $boundsheet_length + strlen($this->_worksheets[$i]->name); } $offset += $EOF; + for ($i=0; $i < $total_worksheets; $i++) { $this->_worksheets[$i]->offset = $offset; $offset += $this->_worksheets[$i]->_datasize; @@ -1213,6 +1220,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * * @access private */ + /* FIXME: update _calcSheetOffsets() when updating this method */ function _storeSharedStringsTable() { $record = 0x00fc; // Record identifier diff --git a/Writer/Worksheet.php b/Writer/Worksheet.php index 40a8e76..f23fb3a 100644 --- a/Writer/Worksheet.php +++ b/Writer/Worksheet.php @@ -102,28 +102,28 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr /** * First row for the DIMENSIONS record * @var integer - * @see storeDimensions() + * @see _storeDimensions() */ var $_dim_rowmin; /** * Last row for the DIMENSIONS record * @var integer - * @see storeDimensions() + * @see _storeDimensions() */ var $_dim_rowmax; /** * First column for the DIMENSIONS record * @var integer - * @see storeDimensions() + * @see _storeDimensions() */ var $_dim_colmin; /** * Last column for the DIMENSIONS record * @var integer - * @see storeDimensions() + * @see _storeDimensions() */ var $_dim_colmax; @@ -470,7 +470,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr */ // Prepend the sheet dimensions - $this->storeDimensions(); + $this->_storeDimensions(); // Prepend the sheet password $this->_storePassword(); @@ -481,6 +481,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr // Prepend the page setup $this->_storeSetup(); + /* FIXME: margins are actually appended */ // Prepend the bottom margin $this->_storeMarginBottom(); @@ -2053,14 +2054,14 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access private */ - function storeDimensions() + function _storeDimensions() { - $record = 0x0200; // Record identifier - $row_min = $this->_dim_rowmin; // First row - $row_max = $this->_dim_rowmax; // Last row plus 1 - $col_min = $this->_dim_colmin; // First column - $col_max = $this->_dim_colmax; // Last column plus 1 - $reserved = 0x0000; // Reserved by Excel + $record = 0x0200; // Record identifier + $row_min = $this->_dim_rowmin; // First row + $row_max = $this->_dim_rowmax + 1; // Last row plus 1 + $col_min = $this->_dim_colmin; // First column + $col_max = $this->_dim_colmax + 1; // Last column plus 1 + $reserved = 0x0000; // Reserved by Excel if ($this->_BIFF_version == 0x0500) { $length = 0x000A; // Number of bytes to follow