From 923008d2080cd9b7aab01e0cd82e9a8e322ec67e Mon Sep 17 00:00:00 2001 From: Alexey Kopytko Date: Wed, 15 Jun 2016 18:50:04 +0900 Subject: [PATCH 01/15] Added ability to test with fixtures - Now we can specify exact timestamp - Current fixture example.xls is readable --- Spreadsheet/Excel/Writer/Workbook.php | 7 ++- .../Test_Spreadsheet_Excel_WriterTestCase.php | 46 ++++++++++++++++-- ..._Spreadsheet_Excel_Writer_WorkbookTest.php | 24 ++++++++- test/fixture/example.xls | Bin 0 -> 3584 bytes 4 files changed, 71 insertions(+), 6 deletions(-) create mode 100644 test/fixture/example.xls diff --git a/Spreadsheet/Excel/Writer/Workbook.php b/Spreadsheet/Excel/Writer/Workbook.php index 6d1cb9c..ed9998b 100644 --- a/Spreadsheet/Excel/Writer/Workbook.php +++ b/Spreadsheet/Excel/Writer/Workbook.php @@ -178,6 +178,9 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri /** @var array */ public $blockSize; + /** @var int */ + public $timestamp; + /** * Class constructor * @@ -213,6 +216,8 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri $this->totalStringLength = 0; $this->uniqueString = 0; $this->tableOfStrings = array(); + $this->timestamp = time(); + $this->setPaletteXl97(); } @@ -636,7 +641,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri } } - $root = new OLE_PPS_Root(time(), time(), array($OLE)); + $root = new OLE_PPS_Root($this->timestamp, $this->timestamp, array($OLE)); if ($this->temporaryDirectory != '') { $root->setTempDir($this->temporaryDirectory); diff --git a/test/Test/Spreadsheet/Excel/Writer/Test_Spreadsheet_Excel_WriterTestCase.php b/test/Test/Spreadsheet/Excel/Writer/Test_Spreadsheet_Excel_WriterTestCase.php index 69d6623..00faa30 100644 --- a/test/Test/Spreadsheet/Excel/Writer/Test_Spreadsheet_Excel_WriterTestCase.php +++ b/test/Test/Spreadsheet/Excel/Writer/Test_Spreadsheet_Excel_WriterTestCase.php @@ -6,12 +6,50 @@ */ class Test_Spreadsheet_Excel_WriterTestCase extends PHPUnit_Framework_TestCase { + const FIXTURES_PATH = 'test/fixture/'; + /** - * @param string $fileName - * @return Spreadsheet_Excel_Writer_Workbook + * @param string $filename + * @return Spreadsheet_Excel_Writer */ - protected function getNewWorkbook($fileName = 'my_workbook') + protected function getNewWorkbook($filename = '') { - return new Spreadsheet_Excel_Writer_Workbook($fileName); + // we're writing to the standard output by defaulr + return new Spreadsheet_Excel_Writer($filename); + } + + protected function assertSameAsInFixture($filename, Spreadsheet_Excel_Writer $workbook) + { + $this->assertEmpty($workbook->fileName, "Testing with fixtures works only for standard output"); + + // we have to fix timestamp for fixtures to work + $workbook->timestamp = 1000000000; // somewhere in 2001 + + ob_start(); + $workbook->close(); + $data = ob_get_clean(); + + $fullPath = self::FIXTURES_PATH.$filename; + + if ($this->shouldUpdateFixtures()) { + file_put_contents($fullPath, $data); + } + + if (!is_file($fullPath)) { + $this->fail("Fixture $filename not found"); + } + + // TODO: should we save data for future analysis? + //file_put_contents("{$fullPath}.work", $data); + + $this->assertEquals(file_get_contents($fullPath), $data, "Output differs for $filename"); + } + + /** + * We should update golden files + */ + private function shouldUpdateFixtures() + { + return isset($_SERVER['GOLDEN']); } } \ No newline at end of file diff --git a/test/Test/Spreadsheet/Excel/Writer/Test_Spreadsheet_Excel_Writer_WorkbookTest.php b/test/Test/Spreadsheet/Excel/Writer/Test_Spreadsheet_Excel_Writer_WorkbookTest.php index e96a5df..beb9a0e 100644 --- a/test/Test/Spreadsheet/Excel/Writer/Test_Spreadsheet_Excel_Writer_WorkbookTest.php +++ b/test/Test/Spreadsheet/Excel/Writer/Test_Spreadsheet_Excel_Writer_WorkbookTest.php @@ -10,6 +10,28 @@ class Test_Spreadsheet_Excel_Writer_WorkbookTest extends Test_Spreadsheet_Excel_ { $workbook = $this->getNewWorkbook(); + $before = get_object_vars($workbook); + + $workbook->setVersion(1); + + $this->assertEquals($before, get_object_vars($workbook), "Version 1 should not change internal state"); + $workbook->setVersion(8); + + $this->assertNotEquals($before, get_object_vars($workbook), "Version 8 should change internal state"); + + return $workbook; } -} \ No newline at end of file + + /** + * @depends testSetVersion + */ + public function testWriteSingleCell(Spreadsheet_Excel_Writer $workbook) + { + $sheet = $workbook->addWorksheet("Example"); + $sheet->write(0, 0, "Example"); + + $this->assertSameAsInFixture('example.xls', $workbook); + } + +} diff --git a/test/fixture/example.xls b/test/fixture/example.xls new file mode 100644 index 0000000000000000000000000000000000000000..f7955b3a5f310dbdbd7dbf03b551b7889d7eb591 GIT binary patch literal 3584 zcmeHJO-~d-5PdVuvaE{21~{0QY)Je*nYoY{T`?{{fQx%wBa;{wAsY{Ha=?$X(PWc8 z@(<*~MGnJ_!zAiISUGX@;!S8@RnL&s?1jV_3DYyLy1J&js#8_nHD5lD_cpgKf5RW` zE{1SqD;VyRd*p+BJmwgY9a(E-R3gY0?G$-H;^z}Xgv3^2C^0V+BSeKbN1P`v5TnFJ z;u0Y#FiuGPi*`CaP#IwqhfDZ0nwDo7ONsqMX2i$f9;)PlovWS68Ra}Q{b|jXJD9{C zW%lJeNg%coW;@SX?SJ_pfEXA1neiSbbT2<_O?yX@S|Jxt{Cz(FHRocbPQR-cl*{Fz zEvbF*d9%c@@39Y;Njxjil93UqA1Wae%c_jT>|+^_Ns@$J3}Y-z7_ri%NI5^^V<|_( zaViRFN*-ZVpK4GYVug!zUCQ;=8W@hP;acjosX-W7glS4SXA2AwQGI04?RLQl2n_`x zU&1IT3%QnpH<-d(xlU2`8dyaOOISf03;4+sCFv^Q{n}VW{#%CD2|1`~Q$^8l)iSNi3((rd>~Kd4{t<8K`E-|IK~_)SdH_EX)DRDq`7lv2Rf ztLHuU>dSracJ1h)Rs>fAfct(G+Zy%PP~x=AX&2i^UuSkbWWCIb12^F@t#`19C%TVCCp-bIGH-MH f(hsyhK;Lp^f54|RC6a%){QpmQ!68w!v*CeX@3&$i literal 0 HcmV?d00001 From 85e4049be986d487f92be3c48fbcff877b405faa Mon Sep 17 00:00:00 2001 From: Alexey Kopytko Date: Thu, 16 Jun 2016 11:35:47 +0900 Subject: [PATCH 02/15] Reverted the bulk of recently itroduced breaking changes This reverts commits 631bbb5f72822f83dffd775b9d3aaf37d68ef178, 3d299d9938af3cd09d4411db5f02b7da836f3ae8, b3be543ba3cbc38c05c6db025aa9566ea059e6f2. --- .gitignore | 2 - Spreadsheet/Excel/Writer.php | 41 +- Spreadsheet/Excel/Writer/BIFFwriter.php | 112 ++- Spreadsheet/Excel/Writer/Format.php | 165 ++-- Spreadsheet/Excel/Writer/Parser.php | 137 ++- Spreadsheet/Excel/Writer/Validator.php | 78 +- Spreadsheet/Excel/Writer/Workbook.php | 1039 +++++++++++------------ Spreadsheet/Excel/Writer/Worksheet.php | 501 ++++++----- 8 files changed, 996 insertions(+), 1079 deletions(-) diff --git a/.gitignore b/.gitignore index 9768287..869f498 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,3 @@ -# ide related -.idea # composer related composer.lock composer.phar diff --git a/Spreadsheet/Excel/Writer.php b/Spreadsheet/Excel/Writer.php index 291b7c4..d62e9cf 100644 --- a/Spreadsheet/Excel/Writer.php +++ b/Spreadsheet/Excel/Writer.php @@ -31,7 +31,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -require_once __DIR__ . '/Writer/Workbook.php'; +require_once 'PEAR.php'; +require_once 'Spreadsheet/Excel/Writer/Workbook.php'; /** * Class for writing Excel Spreadsheets. This class should change COMPLETELY. @@ -46,12 +47,13 @@ class Spreadsheet_Excel_Writer extends Spreadsheet_Excel_Writer_Workbook /** * The constructor. It just creates a Workbook * - * @param string $fileName The optional filename for the Workbook. + * @param string $filename The optional filename for the Workbook. + * @return Spreadsheet_Excel_Writer_Workbook The Workbook created */ - public function __construct($fileName = '') + function Spreadsheet_Excel_Writer($filename = '') { - $this->fileName = $fileName; - parent::__construct($fileName); + $this->_filename = $filename; + $this->Spreadsheet_Excel_Writer_Workbook($filename); } /** @@ -60,13 +62,13 @@ class Spreadsheet_Excel_Writer extends Spreadsheet_Excel_Writer_Workbook * @param string $filename The filename to use for HTTP headers * @access public */ - public function send($filename) + function send($filename) { - header('Content-type: application/vnd.ms-excel'); - header('Content-Disposition: attachment; filename="' . $filename .'"'); - header('Expires: 0'); - header('Cache-Control: must-revalidate, post-check=0,pre-check=0'); - header('Pragma: public'); + header("Content-type: application/vnd.ms-excel"); + header("Content-Disposition: attachment; filename=\"$filename\""); + header("Expires: 0"); + header("Cache-Control: must-revalidate, post-check=0,pre-check=0"); + header("Pragma: public"); } /** @@ -76,26 +78,27 @@ class Spreadsheet_Excel_Writer extends Spreadsheet_Excel_Writer_Workbook * @access public * @static * @param integer $row Row for the cell to convert (0-indexed). - * @param integer $column Column for the cell to convert (0-indexed). + * @param integer $col Column for the cell to convert (0-indexed). * @return string The cell identifier in A1 format */ - public function rowcolToCell($row, $column) + function rowcolToCell($row, $col) { - if ($column > 255) { //maximum column value exceeded - return new PEAR_Error('Maximum column value exceeded: ' . $column); + if ($col > 255) { //maximum column value exceeded + return new PEAR_Error("Maximum column value exceeded: $col"); } - $int = (int)($column / 26); - $frac = $column % 26; - $chr1 = ''; + $int = (int)($col / 26); + $frac = $col % 26; + $chr1 = ''; if ($int > 0) { $chr1 = chr(ord('A') + $int - 1); } $chr2 = chr(ord('A') + $frac); - ++$row; + $row++; return $chr1 . $chr2 . $row; } } +?> diff --git a/Spreadsheet/Excel/Writer/BIFFwriter.php b/Spreadsheet/Excel/Writer/BIFFwriter.php index bf89344..c949b45 100644 --- a/Spreadsheet/Excel/Writer/BIFFwriter.php +++ b/Spreadsheet/Excel/Writer/BIFFwriter.php @@ -32,6 +32,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +require_once 'PEAR.php'; + /** * Class for writing Excel BIFF records. * @@ -55,59 +57,59 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR * The BIFF/Excel version (5). * @var integer */ - public $BIFF_version = 0x0500; + var $_BIFF_version = 0x0500; /** * The byte order of this architecture. 0 => little endian, 1 => big endian * @var integer */ - public $byteOrder; + var $_byte_order; /** * The string containing the data of the BIFF stream * @var string */ - public $data; + var $_data; /** - * 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->_data) * @var integer */ - public $dataSize; + var $_datasize; /** - * The maximun length for a BIFF record. See addContinue() + * The maximun length for a BIFF record. See _addContinue() * @var integer - * @see addContinue() + * @see _addContinue() */ - public $limit; + var $_limit; /** * The temporary dir for storing the OLE file * @var string */ - public $temporaryDirectory; + var $_tmp_dir; /** * The temporary file for storing the OLE file * @var string */ - public $temporaryFile; + var $_tmp_file; /** * Constructor * * @access public */ - public function __construct() + function Spreadsheet_Excel_Writer_BIFFwriter() { - $this->byteOrder = ''; - $this->data = ''; - $this->dataSize = 0; - $this->limit = 2080; - $this->temporaryDirectory = ''; + $this->_byte_order = ''; + $this->_data = ''; + $this->_datasize = 0; + $this->_limit = 2080; + $this->_tmp_dir = ''; // Set the byte order - $this->setByteOrder(); + $this->_setByteOrder(); } /** @@ -116,23 +118,21 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR * * @access private */ - protected function setByteOrder() + function _setByteOrder() { // Check if "pack" gives the required IEEE 64bit float - $testString = pack('d', 1.2345); - $number = pack('C8', 0x8D, 0x97, 0x6E, 0x12, 0x83, 0xC0, 0xF3, 0x3F); - - if ($number == $testString) { + $teststr = pack("d", 1.2345); + $number = pack("C8", 0x8D, 0x97, 0x6E, 0x12, 0x83, 0xC0, 0xF3, 0x3F); + if ($number == $teststr) { $byte_order = 0; // Little Endian - } elseif ($number == strrev($testString)){ + } elseif ($number == strrev($teststr)){ $byte_order = 1; // Big Endian } else { // Give up. I'll fix this in a later version. - return $this->raiseError('Required floating point format ' . - 'not supported on this platform.'); + return $this->raiseError("Required floating point format ". + "not supported on this platform."); } - - $this->byteOrder = $byte_order; + $this->_byte_order = $byte_order; } /** @@ -141,14 +141,13 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR * @param string $data binary data to prepend * @access private */ - protected function prepend($data) + function _prepend($data) { - if (strlen($data) > $this->limit) { - $data = $this->addContinue($data); + if (strlen($data) > $this->_limit) { + $data = $this->_addContinue($data); } - - $this->data = $data . $this->data; - $this->dataSize += strlen($data); + $this->_data = $data.$this->_data; + $this->_datasize += strlen($data); } /** @@ -157,14 +156,13 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR * @param string $data binary data to append * @access private */ - protected function append($data) + function _append($data) { - if (strlen($data) > $this->limit) { - $data = $this->addContinue($data); + if (strlen($data) > $this->_limit) { + $data = $this->_addContinue($data); } - - $this->data = $this->data . $data; - $this->dataSize += strlen($data); + $this->_data = $this->_data.$data; + $this->_datasize += strlen($data); } /** @@ -175,28 +173,28 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR * 0x0010 Worksheet. * @access private */ - protected function storeBof($type) + function _storeBof($type) { $record = 0x0809; // Record identifier // According to the SDK $build and $year should be set to zero. // However, this throws a warning in Excel 5. So, use magic numbers. - if ($this->BIFF_version == 0x0500) { + if ($this->_BIFF_version == 0x0500) { $length = 0x0008; $unknown = ''; $build = 0x096C; $year = 0x07C9; - } elseif ($this->BIFF_version == 0x0600) { + } elseif ($this->_BIFF_version == 0x0600) { $length = 0x0010; $unknown = pack("VV", 0x00000041, 0x00000006); //unknown last 8 bytes for BIFF8 $build = 0x0DBB; $year = 0x07CC; } - $version = $this->BIFF_version; + $version = $this->_BIFF_version; - $header = pack('vv', $record, $length); - $data = pack('vvvv', $version, $type, $build, $year); - $this->prepend($header . $data . $unknown); + $header = pack("vv", $record, $length); + $data = pack("vvvv", $version, $type, $build, $year); + $this->_prepend($header . $data . $unknown); } /** @@ -204,12 +202,12 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR * * @access private */ - protected function storeEof() + function _storeEof() { $record = 0x000A; // Record identifier $length = 0x0000; // Number of bytes to follow - $header = pack('vv', $record, $length); - $this->append($header); + $header = pack("vv", $record, $length); + $this->_append($header); } /** @@ -224,16 +222,16 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR * @return string A very convenient string of continue blocks * @access private */ - protected function addContinue($data) + function _addContinue($data) { - $limit = $this->limit; + $limit = $this->_limit; $record = 0x003C; // Record identifier // The first 2080/8224 bytes remain intact. However, we have to change // the length field of the record. - $tmp = substr($data, 0, 2).pack('v', $limit-4) . substr($data, 4, $limit - 4); + $tmp = substr($data, 0, 2).pack("v", $limit-4).substr($data, 4, $limit - 4); - $header = pack('vv', $record, $limit); // Headers for continue records + $header = pack("vv", $record, $limit); // Headers for continue records // Retrieve chunks of 2080/8224 bytes +4 for the header. $data_length = strlen($data); @@ -243,7 +241,7 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR } // Retrieve the last chunk of data - $header = pack('vv', $record, strlen($data) - $i); + $header = pack("vv", $record, strlen($data) - $i); $tmp .= $header; $tmp .= substr($data, $i, strlen($data) - $i); @@ -257,13 +255,13 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR * @param string $dir The dir to be used as temp dir * @return true if given dir is valid, false otherwise */ - protected function setTempDir($dir) + function setTempDir($dir) { if (is_dir($dir)) { - $this->temporaryDirectory = $dir; + $this->_tmp_dir = $dir; return true; } - return false; } } +?> diff --git a/Spreadsheet/Excel/Writer/Format.php b/Spreadsheet/Excel/Writer/Format.php index 7841471..8922360 100644 --- a/Spreadsheet/Excel/Writer/Format.php +++ b/Spreadsheet/Excel/Writer/Format.php @@ -32,6 +32,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +require_once 'PEAR.php'; + /** * Class for generating Excel XF records (formats) * @@ -42,219 +44,212 @@ class Spreadsheet_Excel_Writer_Format extends PEAR { - /** - * The BIFF version for the workbook - * @var integer - */ - public $_BIFF_version; - - /** - * Index to the FONT record. - * @var integer - */ - public $font_index; - /** * The index given by the workbook when creating a new format. * @var integer */ - public $_xf_index; + var $_xf_index; + + /** + * Index to the FONT record. + * @var integer + */ + var $font_index; /** * The font name (ASCII). * @var string */ - public $_font_name; + var $_font_name; /** * Height of font (1/20 of a point) * @var integer */ - public $_size; + var $_size; /** * Bold style * @var integer */ - public $_bold; + var $_bold; /** * Bit specifiying if the font is italic. * @var integer */ - public $_italic; + var $_italic; /** * Index to the cell's color * @var integer */ - public $_color; + var $_color; /** * The text underline property * @var integer */ - public $_underline; + var $_underline; /** * Bit specifiying if the font has strikeout. * @var integer */ - public $_font_strikeout; + var $_font_strikeout; /** * Bit specifiying if the font has outline. * @var integer */ - public $_font_outline; + var $_font_outline; /** * Bit specifiying if the font has shadow. * @var integer */ - public $_font_shadow; + var $_font_shadow; /** * 2 bytes specifiying the script type for the font. * @var integer */ - public $_font_script; + var $_font_script; /** * Byte specifiying the font family. * @var integer */ - public $_font_family; + var $_font_family; /** * Byte specifiying the font charset. * @var integer */ - public $_font_charset; + var $_font_charset; /** * An index (2 bytes) to a FORMAT record (number format). * @var integer */ - public $_num_format; + var $_num_format; /** * Bit specifying if formulas are hidden. * @var integer */ - public $_hidden; + var $_hidden; /** * Bit specifying if the cell is locked. * @var integer */ - public $_locked; + var $_locked; /** * The three bits specifying the text horizontal alignment. * @var integer */ - public $_text_h_align; + var $_text_h_align; /** * Bit specifying if the text is wrapped at the right border. * @var integer */ - public $_text_wrap; + var $_text_wrap; /** * The three bits specifying the text vertical alignment. * @var integer */ - public $_text_v_align; + var $_text_v_align; /** * 1 bit, apparently not used. * @var integer */ - public $_text_justlast; + var $_text_justlast; /** * The two bits specifying the text rotation. * @var integer */ - public $_rotation; + var $_rotation; /** * The cell's foreground color. * @var integer */ - public $_fg_color; + var $_fg_color; /** * The cell's background color. * @var integer */ - public $_bg_color; + var $_bg_color; /** * The cell's background fill pattern. * @var integer */ - public $_pattern; + var $_pattern; /** * Style of the bottom border of the cell * @var integer */ - public $_bottom; + var $_bottom; /** * Color of the bottom border of the cell. * @var integer */ - public $_bottom_color; + var $_bottom_color; /** * Style of the top border of the cell * @var integer */ - public $_top; + var $_top; /** * Color of the top border of the cell. * @var integer */ - public $_top_color; + var $_top_color; /** * Style of the left border of the cell * @var integer */ - public $_left; + var $_left; /** * Color of the left border of the cell. * @var integer */ - public $_left_color; + var $_left_color; /** * Style of the right border of the cell * @var integer */ - public $_right; + var $_right; /** * Color of the right border of the cell. * @var integer */ - public $_right_color; + var $_right_color; /** * Constructor * * @access private - * @param integer $BIFF_version * @param integer $index the XF index for the format. * @param array $properties array with properties to be set on initialization. */ - public function __construct($BIFF_version, $index = 0, $properties = array()) + function Spreadsheet_Excel_Writer_Format($BIFF_version, $index = 0, $properties = array()) { $this->_xf_index = $index; $this->_BIFF_version = $BIFF_version; @@ -317,7 +312,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @param string $style The type of the XF record ('style' or 'cell'). * @return string The XF record */ - public function getXf($style) + function getXf($style) { // Set the type of the XF record and some of the attributes. if ($style == 'style') { @@ -449,7 +444,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * * @return string The FONT record */ - public function getFont() + function getFont() { $dyHeight = $this->_size * 20; // Height of font (1/20 of a point) $icv = $this->_color; // Index to color palette @@ -497,7 +492,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR /** * Returns a unique hash key for a font. - * Used by Spreadsheet_Excel_Writer_Workbook::storeAllFonts() + * Used by Spreadsheet_Excel_Writer_Workbook::_storeAllFonts() * * The elements that form the key are arranged to increase the probability of * generating a unique key. Elements that hold a large range of numbers @@ -505,7 +500,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * * @return string A key for this font */ - public function getFontKey() + function getFontKey() { $key = "$this->_font_name$this->_size"; $key .= "$this->_font_script$this->_underline"; @@ -521,7 +516,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * * @return integer The index for the XF record */ - public function getXfIndex() + function getXfIndex() { return($this->_xf_index); } @@ -535,7 +530,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @param string $name_color name of the color (i.e.: 'blue', 'red', etc..). Optional. * @return integer The color index */ - protected function _getColor($name_color = '') + function _getColor($name_color = '') { $colors = array( 'aqua' => 0x07, @@ -588,7 +583,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @access public * @param string $location alignment for the cell ('left', 'right', etc...). */ - public function setAlign($location) + function setAlign($location) { if (preg_match("/\d/",$location)) { return; // Ignore numbers @@ -646,7 +641,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @access public * @param string $location alignment for the cell ('left', 'right', etc...). */ - public function setHAlign($location) + function setHAlign($location) { if (preg_match("/\d/",$location)) { return; // Ignore numbers @@ -686,7 +681,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @access public * @param string $location alignment for the cell ('top', 'vleft', 'vright', etc...). */ - public function setVAlign($location) + function setVAlign($location) { if (preg_match("/\d/",$location)) { return; // Ignore numbers @@ -719,7 +714,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * * @access public */ - public function setMerge() + function setMerge() { $this->setAlign('merge'); } @@ -734,7 +729,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR 1 maps to 700 (bold text). Valid range is: 100-1000. It's Optional, default is 1 (bold). */ - public function setBold($weight = 1) + function setBold($weight = 1) { if ($weight == 1) { $weight = 0x2BC; // Bold text @@ -762,7 +757,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @access public * @param integer $style style of the cell border. 1 => thin, 2 => thick. */ - public function setBottom($style) + function setBottom($style) { $this->_bottom = $style; } @@ -773,7 +768,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @access public * @param integer $style style of the cell top border. 1 => thin, 2 => thick. */ - public function setTop($style) + function setTop($style) { $this->_top = $style; } @@ -784,7 +779,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @access public * @param integer $style style of the cell left border. 1 => thin, 2 => thick. */ - public function setLeft($style) + function setLeft($style) { $this->_left = $style; } @@ -795,7 +790,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @access public * @param integer $style style of the cell right border. 1 => thin, 2 => thick. */ - public function setRight($style) + function setRight($style) { $this->_right = $style; } @@ -807,7 +802,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @access public * @param integer $style style to apply for all cell borders. 1 => thin, 2 => thick. */ - public function setBorder($style) + function setBorder($style) { $this->setBottom($style); $this->setTop($style); @@ -827,7 +822,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @param mixed $color The color we are setting. Either a string (like 'blue'), * or an integer (range is [8...63]). */ - public function setBorderColor($color) + function setBorderColor($color) { $this->setBottomColor($color); $this->setTopColor($color); @@ -841,7 +836,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @access public * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]). */ - public function setBottomColor($color) + function setBottomColor($color) { $value = $this->_getColor($color); $this->_bottom_color = $value; @@ -853,7 +848,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @access public * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]). */ - public function setTopColor($color) + function setTopColor($color) { $value = $this->_getColor($color); $this->_top_color = $value; @@ -865,7 +860,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @access public * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]). */ - public function setLeftColor($color) + function setLeftColor($color) { $value = $this->_getColor($color); $this->_left_color = $value; @@ -877,7 +872,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @access public * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]). */ - public function setRightColor($color) + function setRightColor($color) { $value = $this->_getColor($color); $this->_right_color = $value; @@ -890,7 +885,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @access public * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]). */ - public function setFgColor($color) + function setFgColor($color) { $value = $this->_getColor($color); $this->_fg_color = $value; @@ -905,7 +900,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @access public * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]). */ - public function setBgColor($color) + function setBgColor($color) { $value = $this->_getColor($color); $this->_bg_color = $value; @@ -920,7 +915,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @access public * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]). */ - public function setColor($color) + function setColor($color) { $value = $this->_getColor($color); $this->_color = $value; @@ -933,7 +928,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @param integer $arg Optional. Defaults to 1. Meaningful values are: 0-18, * 0 meaning no background. */ - public function setPattern($arg = 1) + function setPattern($arg = 1) { $this->_pattern = $arg; } @@ -945,7 +940,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @param integer $underline The value for underline. Possible values are: * 1 => underline, 2 => double underline. */ - public function setUnderline($underline) + function setUnderline($underline) { $this->_underline = $underline; } @@ -955,7 +950,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * * @access public */ - public function setItalic() + function setItalic() { $this->_italic = 1; } @@ -966,7 +961,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @access public * @param integer $size The font size (in pixels I think). */ - public function setSize($size) + function setSize($size) { $this->_size = $size; } @@ -976,7 +971,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * * @access public */ - public function setTextWrap() + function setTextWrap() { $this->_text_wrap = 1; } @@ -988,7 +983,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @param integer $angle The rotation angle for the text (clockwise). Possible values are: 0, 90, 270 and -1 for stacking top-to-bottom. */ - public function setTextRotation($angle) + function setTextRotation($angle) { switch ($angle) { @@ -1032,7 +1027,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @access public * @param integer $num_format The numeric format. */ - public function setNumFormat($num_format) + function setNumFormat($num_format) { $this->_num_format = $num_format; } @@ -1042,7 +1037,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * * @access public */ - public function setStrikeOut() + function setStrikeOut() { $this->_font_strikeout = 1; } @@ -1052,7 +1047,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * * @access public */ - public function setOutLine() + function setOutLine() { $this->_font_outline = 1; } @@ -1062,7 +1057,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * * @access public */ - public function setShadow() + function setShadow() { $this->_font_shadow = 1; } @@ -1074,7 +1069,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @param integer $script The value for script type. Possible values are: * 1 => superscript, 2 => subscript. */ - public function setScript($script) + function setScript($script) { $this->_font_script = $script; } @@ -1084,7 +1079,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * * @access public */ - public function setLocked() + function setLocked() { $this->_locked = 1; } @@ -1094,7 +1089,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * * @access public */ - public function setUnLocked() + function setUnLocked() { $this->_locked = 0; } @@ -1103,10 +1098,10 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * Sets the font family name. * * @access public - * @param string $font_family The font family name. Possible values are: + * @param string $fontfamily The font family name. Possible values are: * 'Times New Roman', 'Arial', 'Courier'. */ - public function setFontFamily($font_family) + function setFontFamily($font_family) { $this->_font_name = $font_family; } diff --git a/Spreadsheet/Excel/Writer/Parser.php b/Spreadsheet/Excel/Writer/Parser.php index 3b1eda1..bd93824 100644 --- a/Spreadsheet/Excel/Writer/Parser.php +++ b/Spreadsheet/Excel/Writer/Parser.php @@ -25,77 +25,79 @@ /** * @const SPREADSHEET_EXCEL_WRITER_ADD token identifier for character "+" */ -define('SPREADSHEET_EXCEL_WRITER_ADD', '+'); +define('SPREADSHEET_EXCEL_WRITER_ADD', "+"); /** * @const SPREADSHEET_EXCEL_WRITER_SUB token identifier for character "-" */ -define('SPREADSHEET_EXCEL_WRITER_SUB', '-'); +define('SPREADSHEET_EXCEL_WRITER_SUB', "-"); /** * @const SPREADSHEET_EXCEL_WRITER_MUL token identifier for character "*" */ -define('SPREADSHEET_EXCEL_WRITER_MUL', '*'); +define('SPREADSHEET_EXCEL_WRITER_MUL', "*"); /** * @const SPREADSHEET_EXCEL_WRITER_DIV token identifier for character "/" */ -define('SPREADSHEET_EXCEL_WRITER_DIV', '/'); +define('SPREADSHEET_EXCEL_WRITER_DIV', "/"); /** * @const SPREADSHEET_EXCEL_WRITER_OPEN token identifier for character "(" */ -define('SPREADSHEET_EXCEL_WRITER_OPEN', '('); +define('SPREADSHEET_EXCEL_WRITER_OPEN', "("); /** * @const SPREADSHEET_EXCEL_WRITER_CLOSE token identifier for character ")" */ -define('SPREADSHEET_EXCEL_WRITER_CLOSE', ')'); +define('SPREADSHEET_EXCEL_WRITER_CLOSE', ")"); /** * @const SPREADSHEET_EXCEL_WRITER_COMA token identifier for character "," */ -define('SPREADSHEET_EXCEL_WRITER_COMA', ','); +define('SPREADSHEET_EXCEL_WRITER_COMA', ","); /** * @const SPREADSHEET_EXCEL_WRITER_SEMICOLON token identifier for character ";" */ -define('SPREADSHEET_EXCEL_WRITER_SEMICOLON', ';'); +define('SPREADSHEET_EXCEL_WRITER_SEMICOLON', ";"); /** * @const SPREADSHEET_EXCEL_WRITER_GT token identifier for character ">" */ -define('SPREADSHEET_EXCEL_WRITER_GT', '>'); +define('SPREADSHEET_EXCEL_WRITER_GT', ">"); /** * @const SPREADSHEET_EXCEL_WRITER_LT token identifier for character "<" */ -define('SPREADSHEET_EXCEL_WRITER_LT', '<'); +define('SPREADSHEET_EXCEL_WRITER_LT', "<"); /** * @const SPREADSHEET_EXCEL_WRITER_LE token identifier for character "<=" */ -define('SPREADSHEET_EXCEL_WRITER_LE', '<='); +define('SPREADSHEET_EXCEL_WRITER_LE', "<="); /** * @const SPREADSHEET_EXCEL_WRITER_GE token identifier for character ">=" */ -define('SPREADSHEET_EXCEL_WRITER_GE', '>='); +define('SPREADSHEET_EXCEL_WRITER_GE', ">="); /** * @const SPREADSHEET_EXCEL_WRITER_EQ token identifier for character "=" */ -define('SPREADSHEET_EXCEL_WRITER_EQ', '='); +define('SPREADSHEET_EXCEL_WRITER_EQ', "="); /** * @const SPREADSHEET_EXCEL_WRITER_NE token identifier for character "<>" */ -define('SPREADSHEET_EXCEL_WRITER_NE', '<>'); +define('SPREADSHEET_EXCEL_WRITER_NE', "<>"); /** * * @const SPREADSHEET_EXCEL_WRITER_CONCAT token identifier for character "&" */ -define('SPREADSHEET_EXCEL_WRITER_CONCAT', '&'); +define('SPREADSHEET_EXCEL_WRITER_CONCAT', "&"); + +require_once 'PEAR.php'; /** * Class for parsing Excel formulas @@ -107,73 +109,67 @@ define('SPREADSHEET_EXCEL_WRITER_CONCAT', '&'); class Spreadsheet_Excel_Writer_Parser extends PEAR { - /** - * The BIFF version for the workbook - * @var integer - */ - public $_BIFF_version; - /** * The index of the character we are currently looking at * @var integer */ - public $_current_char; + var $_current_char; /** * The token we are working on. * @var string */ - public $_current_token; + var $_current_token; /** * The formula to parse * @var string */ - public $_formula; - - /** - * @var array - */ - public $_functions; + var $_formula; /** * The character ahead of the current char * @var string */ - public $_lookahead; + var $_lookahead; /** * The parse tree to be generated * @var string */ - public $_parse_tree; + var $_parse_tree; /** * The byte order. 1 => big endian, 0 => little endian. * @var integer */ - public $_byte_order; + var $_byte_order; /** * Array of external sheets * @var array */ - public $_ext_sheets; + var $_ext_sheets; /** * Array of sheet references in the form of REF structures * @var array */ - public $_references; + var $_references; + + /** + * The BIFF version for the workbook + * @var integer + */ + var $_BIFF_version; /** * The class constructor * * @param integer $byte_order The byte order (Little endian or Big endian) of the architecture - * (optional). 1 => big endian, 0 (default) little endian. - * @param integer $biff_version + (optional). 1 => big endian, 0 (default) little endian. */ - public function __construct($byte_order, $biff_version) + function Spreadsheet_Excel_Writer_Parser($byte_order, $biff_version) { $this->_current_char = 0; $this->_BIFF_version = $biff_version; @@ -192,7 +188,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * * @access private */ - protected function _initializeHashes() + function _initializeHashes() { // The Excel ptg indices $this->ptg = array( @@ -544,7 +540,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * @return mixed the converted token on success. PEAR_Error if the token * is not recognized */ - protected function _convert($token) + function _convert($token) { if (preg_match("/^\"[^\"]{0,255}\"$/", $token)) { return $this->_convertString($token); @@ -603,9 +599,8 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * * @access private * @param mixed $num an integer or double for conversion to its ptg value - * @return string */ - protected function _convertNumber($num) + function _convertNumber($num) { // Integer in the range 0..2**16-1 if ((preg_match("/^\d+$/", $num)) and ($num <= 65535)) { @@ -626,7 +621,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * @return mixed the converted token on success. PEAR_Error if the string * is longer than 255 characters. */ - protected function _convertString($string) + function _convertString($string) { // chop away beggining and ending quotes $string = substr($string, 1, strlen($string) - 2); @@ -651,7 +646,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * @param integer $num_args The number of arguments the function receives. * @return string The packed ptg for the function */ - protected function _convertFunction($token, $num_args) + function _convertFunction($token, $num_args) { $args = $this->_functions[$token][1]; $volatile = $this->_functions[$token][3]; @@ -667,14 +662,12 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR } /** - * Convert an Excel range such as A1:D4 to a ptgRefV. - * - * @access private - * @param string $range An Excel range in the A1:A2 or A1..A2 format. - * @param int $class - * @return array|string - */ - protected function _convertRange2d($range, $class=0) + * Convert an Excel range such as A1:D4 to a ptgRefV. + * + * @access private + * @param string $range An Excel range in the A1:A2 or A1..A2 format. + */ + function _convertRange2d($range, $class=0) { // TODO: possible class value 0,1,2 check Formula.pm @@ -723,7 +716,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * @param string $token An Excel range in the Sheet1!A1:A2 format. * @return mixed The packed ptgArea3d token on success, PEAR_Error on failure. */ - protected function _convertRange3d($token) + function _convertRange3d($token) { $class = 2; // as far as I know, this is magick. @@ -787,7 +780,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * @param string $cell An Excel cell reference * @return string The cell in packed() format with the corresponding ptg */ - protected function _convertRef2d($cell) + function _convertRef2d($cell) { $class = 2; // as far as I know, this is magick. @@ -820,7 +813,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * @param string $cell An Excel cell reference * @return mixed The packed ptgRef3d token on success, PEAR_Error on failure. */ - protected function _convertRef3d($cell) + function _convertRef3d($cell) { $class = 2; // as far as I know, this is magick. @@ -865,7 +858,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * @param string $ext_ref The name of the external reference * @return string The reference index in packed() format */ - protected function _packExtRef($ext_ref) + function _packExtRef($ext_ref) { $ext_ref = preg_replace("/^'/", '', $ext_ref); // Remove leading ' if any. $ext_ref = preg_replace("/'$/", '', $ext_ref); // Remove trailing ' if any. @@ -911,7 +904,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * @return mixed The reference index in packed() format on success, * PEAR_Error on failure */ - protected function _getRefIndex($ext_ref) + function _getRefIndex($ext_ref) { $ext_ref = preg_replace("/^'/", '', $ext_ref); // Remove leading ' if any. $ext_ref = preg_replace("/'$/", '', $ext_ref); // Remove trailing ' if any. @@ -969,7 +962,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * @access private * @return integer The sheet index, -1 if the sheet was not found */ - protected function _getSheetIndex($sheet_name) + function _getSheetIndex($sheet_name) { if (!isset($this->_ext_sheets[$sheet_name])) { return -1; @@ -988,7 +981,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * @param string $name The name of the worksheet being added * @param integer $index The index of the worksheet being added */ - public function setExtSheet($name, $index) + function setExtSheet($name, $index) { $this->_ext_sheets[$name] = $index; } @@ -1000,7 +993,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * @param string $cell The Excel cell reference to be packed * @return array Array containing the row and column in packed() format */ - protected function _cellToPackedRowcol($cell) + function _cellToPackedRowcol($cell) { $cell = strtoupper($cell); list($row, $col, $row_rel, $col_rel) = $this->_cellToRowcol($cell); @@ -1035,7 +1028,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * @param string $range The Excel range to be packed * @return array Array containing (row1,col1,row2,col2) in packed() format */ - protected function _rangeToPackedRange($range) + function _rangeToPackedRange($range) { preg_match('/(\$)?(\d+)\:(\$)?(\d+)/', $range, $match); // return absolute rows if there is a $ in the ref @@ -1082,7 +1075,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * @param string $cell The Excel cell reference in A1 format. * @return array */ - protected function _cellToRowcol($cell) + function _cellToRowcol($cell) { preg_match('/(\$)?([A-I]?[A-Z])(\$)?(\d+)/',$cell,$match); // return absolute column if there is a $ in the ref @@ -1112,7 +1105,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * * @access private */ - protected function _advance() + function _advance() { $i = $this->_current_char; $formula_length = strlen($this->_formula); @@ -1162,7 +1155,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * @param mixed $token The token to check. * @return mixed The checked token or false on failure */ - protected function _match($token) + function _match($token) { switch($token) { case SPREADSHEET_EXCEL_WRITER_ADD: @@ -1293,7 +1286,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * sign (=). * @return mixed true on success, PEAR_Error on failure */ - public function parse($formula) + function parse($formula) { $this->_current_char = 0; $this->_formula = $formula; @@ -1313,7 +1306,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * @access private * @return mixed The parsed ptg'd tree on success, PEAR_Error on failure */ - protected function _condition() + function _condition() { $result = $this->_expression(); if (PEAR::isError($result)) { @@ -1381,7 +1374,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * @access private * @return mixed The parsed ptg'd tree on success, PEAR_Error on failure */ - protected function _expression() + function _expression() { // If it's a string return a string node if (preg_match("/^\"[^\"]{0,255}\"$/", $this->_current_token)) { @@ -1429,7 +1422,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * @see _fact() * @return array The parsed ptg'd tree */ - protected function _parenthesizedExpression() + function _parenthesizedExpression() { $result = $this->_createTree('ptgParen', $this->_expression(), ''); return $result; @@ -1442,7 +1435,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * @access private * @return mixed The parsed ptg'd tree on success, PEAR_Error on failure */ - protected function _term() + function _term() { $result = $this->_fact(); if (PEAR::isError($result)) { @@ -1481,7 +1474,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * @access private * @return mixed The parsed ptg'd tree on success, PEAR_Error on failure */ - protected function _fact() + function _fact() { if ($this->_current_token == SPREADSHEET_EXCEL_WRITER_OPEN) { $this->_advance(); // eat the "(" @@ -1559,7 +1552,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * @access private * @return mixed The parsed ptg'd tree on success, PEAR_Error on failure */ - protected function _func() + function _func() { $num_args = 0; // number of arguments received $function = strtoupper($this->_current_token); @@ -1615,7 +1608,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * @param mixed $right The right array (sub-tree) or a final node. * @return array A tree */ - protected function _createTree($value, $left, $right) + function _createTree($value, $left, $right) { return array('value' => $value, 'left' => $left, 'right' => $right); } @@ -1647,7 +1640,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * @param array $tree The optional tree to convert. * @return string The tree in reverse polish notation */ - public function toReversePolish($tree = array()) + function toReversePolish($tree = array()) { $polish = ""; // the string we are going to return if (empty($tree)) { // If it's the first call use _parse_tree diff --git a/Spreadsheet/Excel/Writer/Validator.php b/Spreadsheet/Excel/Writer/Validator.php index 6f97368..0f091c6 100644 --- a/Spreadsheet/Excel/Writer/Validator.php +++ b/Spreadsheet/Excel/Writer/Validator.php @@ -22,19 +22,21 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +//require_once('PEAR.php'); + // Possible operator types /* FIXME: change prefixes */ -define('OP_BETWEEN', 0x00); -define('OP_NOTBETWEEN', 0x01); -define('OP_EQUAL', 0x02); -define('OP_NOTEQUAL', 0x03); -define('OP_GT', 0x04); -define('OP_LT', 0x05); -define('OP_GTE', 0x06); -define('OP_LTE', 0x07); +define("OP_BETWEEN", 0x00); +define("OP_NOTBETWEEN", 0x01); +define("OP_EQUAL", 0x02); +define("OP_NOTEQUAL", 0x03); +define("OP_GT", 0x04); +define("OP_LT", 0x05); +define("OP_GTE", 0x06); +define("OP_LTE", 0x07); /** * Baseclass for generating Excel DV records (validations) @@ -45,27 +47,27 @@ define('OP_LTE', 0x07); */ class Spreadsheet_Excel_Writer_Validator { - public $_type; - public $_style; - public $_fixedList; - public $_blank; - public $_incell; - public $_showprompt; - public $_showerror; - public $_title_prompt; - public $_descr_prompt; - public $_title_error; - public $_descr_error; - public $_operator; - public $_formula1; - public $_formula2; + var $_type; + var $_style; + var $_fixedList; + var $_blank; + var $_incell; + var $_showprompt; + var $_showerror; + var $_title_prompt; + var $_descr_prompt; + var $_title_error; + var $_descr_error; + var $_operator; + var $_formula1; + var $_formula2; /** * The parser from the workbook. Used to parse validation formulas also * @var Spreadsheet_Excel_Writer_Parser */ - public $_parser; + var $_parser; - public function __construct($parser) + function Spreadsheet_Excel_Writer_Validator(&$parser) { $this->_parser = $parser; $this->_type = 0x01; // FIXME: add method for setting datatype @@ -84,41 +86,41 @@ class Spreadsheet_Excel_Writer_Validator $this->_formula2 = ''; } - public function setPrompt($promptTitle = "\x00", $promptDescription = "\x00", $showPrompt = true) + function setPrompt($promptTitle = "\x00", $promptDescription = "\x00", $showPrompt = true) { $this->_showprompt = $showPrompt; $this->_title_prompt = $promptTitle; $this->_descr_prompt = $promptDescription; } - public function setError($errorTitle = "\x00", $errorDescription = "\x00", $showError = true) + function setError($errorTitle = "\x00", $errorDescription = "\x00", $showError = true) { $this->_showerror = $showError; $this->_title_error = $errorTitle; $this->_descr_error = $errorDescription; } - public function allowBlank() + function allowBlank() { $this->_blank = true; } - public function onInvalidStop() + function onInvalidStop() { $this->_style = 0x00; } - public function onInvalidWarn() + function onInvalidWarn() { $this->_style = 0x01; } - public function onInvalidInfo() + function onInvalidInfo() { $this->_style = 0x02; } - public function setFormula1($formula) + function setFormula1($formula) { // Parse the formula using the parser in Parser.php $error = $this->_parser->parse($formula); @@ -133,7 +135,7 @@ class Spreadsheet_Excel_Writer_Validator return true; } - public function setFormula2($formula) + function setFormula2($formula) { // Parse the formula using the parser in Parser.php $error = $this->_parser->parse($formula); @@ -148,7 +150,7 @@ class Spreadsheet_Excel_Writer_Validator return true; } - public function _getOptions() + function _getOptions() { $options = $this->_type; $options |= $this->_style << 3; @@ -172,7 +174,7 @@ class Spreadsheet_Excel_Writer_Validator return $options; } - public function _getData() + function _getData() { $title_prompt_len = strlen($this->_title_prompt); $descr_prompt_len = strlen($this->_descr_prompt); @@ -197,13 +199,13 @@ class Spreadsheet_Excel_Writer_Validator /*class Spreadsheet_Excel_Writer_Validation_List extends Spreadsheet_Excel_Writer_Validation { - public function Spreadsheet_Excel_Writer_Validation_list() + function Spreadsheet_Excel_Writer_Validation_list() { parent::Spreadsheet_Excel_Writer_Validation(); $this->_type = 0x03; } - public function setList($source, $incell = true) + function setList($source, $incell = true) { $this->_incell = $incell; $this->_fixedList = true; @@ -212,13 +214,13 @@ class Spreadsheet_Excel_Writer_Validator $this->_formula1 = pack("CCC", 0x17, strlen($source), 0x0c) . $source; } - public function setRow($row, $col1, $col2, $incell = true) + function setRow($row, $col1, $col2, $incell = true) { $this->_incell = $incell; //$this->_formula1 = ...; } - public function setCol($col, $row1, $row2, $incell = true) + function setCol($col, $row1, $row2, $incell = true) { $this->_incell = $incell; //$this->_formula1 = ...; diff --git a/Spreadsheet/Excel/Writer/Workbook.php b/Spreadsheet/Excel/Writer/Workbook.php index ed9998b..a1c97f3 100644 --- a/Spreadsheet/Excel/Writer/Workbook.php +++ b/Spreadsheet/Excel/Writer/Workbook.php @@ -32,10 +32,12 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -require_once __DIR__ . '/Format.php'; -require_once __DIR__ . '/BIFFwriter.php'; -require_once __DIR__ . '/Worksheet.php'; -require_once __DIR__ . '/Parser.php'; +require_once 'Spreadsheet/Excel/Writer/Format.php'; +require_once 'Spreadsheet/Excel/Writer/BIFFwriter.php'; +require_once 'Spreadsheet/Excel/Writer/Worksheet.php'; +require_once 'Spreadsheet/Excel/Writer/Parser.php'; +require_once 'OLE/PPS/Root.php'; +require_once 'OLE/PPS/File.php'; /** * Class for generating Excel Spreadsheets @@ -51,132 +53,117 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * Filename for the Workbook * @var string */ - public $fileName; + var $_filename; /** * Formula parser - * @var Spreadsheet_Excel_Writer_Parser + * @var object Parser */ - public $parser; + var $_parser; /** * Flag for 1904 date system (0 => base date is 1900, 1 => base date is 1904) * @var integer */ - public $flagFor1904; + var $_1904; /** * The active worksheet of the workbook (0 indexed) * @var integer */ - public $activeSheet; + var $_activesheet; /** * 1st displayed worksheet in the workbook (0 indexed) * @var integer */ - public $firstSheet; + var $_firstsheet; /** * Number of workbook tabs selected * @var integer */ - public $selectedWorkBook; + var $_selected; /** * Index for creating adding new formats to the workbook * @var integer */ - public $xf_index; + var $_xf_index; /** * Flag for preventing close from being called twice. * @var integer * @see close() */ - public $fileIsClosed; + var $_fileclosed; /** * The BIFF file size for the workbook. * @var integer - * @see calcSheetOffsets() + * @see _calcSheetOffsets() */ - public $biffSize; + var $_biffsize; /** * The default sheetname for all sheets created. * @var string */ - public $sheetName; + var $_sheetname; /** * The default XF format. - * @var Spreadsheet_Excel_Writer_Format + * @var object Format */ - public $temporaryFormat; + var $_tmp_format; /** * Array containing references to all of this workbook's worksheets * @var array */ - public $workSheet; + var $_worksheets; /** - * Array of sheet names for creating the EXTERNSHEET records + * Array of sheetnames for creating the EXTERNSHEET records * @var array */ - public $sheetNames; + var $_sheetnames; /** * Array containing references to all of this workbook's formats - * @var array|Spreadsheet_Excel_Writer_Format[] + * @var array */ - public $formats; + var $_formats; /** * Array containing the colour palette * @var array */ - public $palette; + var $_palette; /** * The default format for URLs. - * @var Spreadsheet_Excel_Writer_Format + * @var object Format */ - public $urlFormat; + var $_url_format; /** * The codepage indicates the text encoding used for strings * @var integer */ - public $codePage; + var $_codepage; /** * The country code used for localization * @var integer */ - public $countryCode; + var $_country_code; /** - * number of bytes for size info of strings + * number of bytes for sizeinfo of strings * @var integer */ - public $stringSizeInfoSize; - - /** @var int */ - public $totalStringLength; - - /** @var int */ - public $uniqueString; - - /** @var array */ - public $tableOfStrings; - - /** @var int */ - public $stringSizeInfo; - - /** @var array */ - public $blockSize; + var $_string_sizeinfo_size; /** @var int */ public $timestamp; @@ -184,41 +171,41 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri /** * Class constructor * - * @param string $fileName for storing the workbook. "-" for writing to stdout. + * @param string filename for storing the workbook. "-" for writing to stdout. * @access public */ - public function __construct($fileName) + function Spreadsheet_Excel_Writer_Workbook($filename) { // It needs to call its parent's constructor explicitly - parent::__construct(); + $this->Spreadsheet_Excel_Writer_BIFFwriter(); - $this->fileName = $fileName; - $this->parser = new Spreadsheet_Excel_Writer_Parser($this->byteOrder, $this->BIFF_version); - $this->flagFor1904 = 0; - $this->activeSheet = 0; - $this->firstSheet = 0; - $this->selectedWorkBook = 0; - $this->xf_index = 16; // 15 style XF's and 1 cell XF. - $this->fileIsClosed = 0; - $this->biffSize = 0; - $this->sheetName = 'Sheet'; - $this->temporaryFormat = new Spreadsheet_Excel_Writer_Format($this->BIFF_version); - $this->workSheet = array(); - $this->sheetNames = array(); - $this->formats = array(); - $this->palette = array(); - $this->codePage = 0x04E4; // FIXME: should change for BIFF8 - $this->countryCode = -1; - $this->stringSizeInfo = 3; + $this->_filename = $filename; + $this->_parser = new Spreadsheet_Excel_Writer_Parser($this->_byte_order, $this->_BIFF_version); + $this->_1904 = 0; + $this->_activesheet = 0; + $this->_firstsheet = 0; + $this->_selected = 0; + $this->_xf_index = 16; // 15 style XF's and 1 cell XF. + $this->_fileclosed = 0; + $this->_biffsize = 0; + $this->_sheetname = 'Sheet'; + $this->_tmp_format = new Spreadsheet_Excel_Writer_Format($this->_BIFF_version); + $this->_worksheets = array(); + $this->_sheetnames = array(); + $this->_formats = array(); + $this->_palette = array(); + $this->_codepage = 0x04E4; // FIXME: should change for BIFF8 + $this->_country_code = -1; + $this->_string_sizeinfo = 3; // Add the default format for hyperlinks - $this->urlFormat = $this->addFormat(array('color' => 'blue', 'underline' => 1)); - $this->totalStringLength = 0; - $this->uniqueString = 0; - $this->tableOfStrings = array(); + $this->_url_format =& $this->addFormat(array('color' => 'blue', 'underline' => 1)); + $this->_str_total = 0; + $this->_str_unique = 0; + $this->_str_table = array(); $this->timestamp = time(); - $this->setPaletteXl97(); + $this->_setPaletteXl97(); } /** @@ -228,25 +215,21 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * @access public * @return mixed true on success. PEAR_Error on failure */ - public function close() + function close() { - if ($this->fileIsClosed) { // Prevent close() from being called twice. + if ($this->_fileclosed) { // Prevent close() from being called twice. return true; } - - $resource = $this->storeWorkbook(); - - if ($this->isError($resource)) { - return $this->raiseError($resource->getMessage()); + $res = $this->_storeWorkbook(); + if ($this->isError($res)) { + return $this->raiseError($res->getMessage()); } - - $this->fileIsClosed = 1; - + $this->_fileclosed = 1; return true; } /** - * An accessor for the workSheet[] array + * An accessor for the _worksheets[] array * Returns an array of the worksheet objects in a workbook * It actually calls to worksheets() * @@ -254,21 +237,21 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * @see worksheets() * @return array */ - public function sheets() + function sheets() { return $this->worksheets(); } /** - * An accessor for the workSheet[] array. + * An accessor for the _worksheets[] array. * Returns an array of the worksheet objects in a workbook * * @access public * @return array */ - public function worksheets() + function worksheets() { - return $this->workSheet; + return $this->_worksheets; } /** @@ -281,28 +264,28 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * @access public * @param integer $version The BIFF version */ - public function setVersion($version) + function setVersion($version) { if ($version == 8) { // only accept version 8 $version = 0x0600; - $this->BIFF_version = $version; + $this->_BIFF_version = $version; // change BIFFwriter limit for CONTINUE records - $this->limit = 8228; - $this->temporaryFormat->_BIFF_version = $version; - $this->urlFormat->_BIFF_version = $version; - $this->parser->_BIFF_version = $version; - $this->codePage = 0x04B0; + $this->_limit = 8228; + $this->_tmp_format->_BIFF_version = $version; + $this->_url_format->_BIFF_version = $version; + $this->_parser->_BIFF_version = $version; + $this->_codepage = 0x04B0; - $total_worksheets = count($this->workSheet); + $total_worksheets = count($this->_worksheets); // change version for all worksheets too - for ($i = 0; $i < $total_worksheets; ++$i) { - $this->workSheet[$i]->_BIFF_version = $version; + for ($i = 0; $i < $total_worksheets; $i++) { + $this->_worksheets[$i]->_BIFF_version = $version; } - $total_formats = count($this->formats); + $total_formats = count($this->_formats); // change version for all formats too - for ($i = 0; $i < $total_formats; ++$i) { - $this->formats[$i]->_BIFF_version = $version; + for ($i = 0; $i < $total_formats; $i++) { + $this->_formats[$i]->_BIFF_version = $version; } } } @@ -314,9 +297,9 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * @param integer $code Is the international calling country code for the * chosen country. */ - public function setCountry($code) + function setCountry($code) { - $this->countryCode = $code; + $this->_country_code = $code; } /** @@ -329,75 +312,61 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * @return mixed reference to a worksheet object on success, PEAR_Error * on failure */ - public function addWorksheet($name = '') + function &addWorksheet($name = '') { - $index = count($this->workSheet); - $sheetName = $this->sheetName; + $index = count($this->_worksheets); + $sheetname = $this->_sheetname; if ($name == '') { - $name = $sheetName . ($index+1); + $name = $sheetname.($index+1); } // Check that sheetname is <= 31 chars (Excel limit before BIFF8). - if ($this->BIFF_version != 0x0600) { + if ($this->_BIFF_version != 0x0600) + { if (strlen($name) > 31) { - return $this->raiseError('Sheetname $name must be <= 31 chars'); + return $this->raiseError("Sheetname $name must be <= 31 chars"); } } else { - if (function_exists('iconv')) { + if(function_exists('iconv')) { $name = iconv('UTF-8','UTF-16LE',$name); } } // Check that the worksheet name doesn't already exist: a fatal Excel error. - $total_worksheets = count($this->workSheet); - - for ($i = 0; $i < $total_worksheets; ++$i) { - if ($this->workSheet[$i]->getName() == $name) { + $total_worksheets = count($this->_worksheets); + for ($i = 0; $i < $total_worksheets; $i++) { + if ($this->_worksheets[$i]->getName() == $name) { return $this->raiseError("Worksheet '$name' already exists"); } } - $worksheet = new Spreadsheet_Excel_Writer_Worksheet( - $this->BIFF_version, - $name, - $index, - $this->activeSheet, - $this->firstSheet, - $this->totalStringLength, - $this->uniqueString, - $this->tableOfStrings, - $this->urlFormat, - $this->parser, - $this->temporaryDirectory - ); - - $this->workSheet[$index] = $worksheet; // Store ref for iterator - $this->sheetNames[$index] = $name; // Store EXTERNSHEET names - $this->parser->setExtSheet($name, $index); // Register worksheet name with parser + $worksheet = new Spreadsheet_Excel_Writer_Worksheet($this->_BIFF_version, + $name, $index, + $this->_activesheet, $this->_firstsheet, + $this->_str_total, $this->_str_unique, + $this->_str_table, $this->_url_format, + $this->_parser, $this->_tmp_dir); + $this->_worksheets[$index] = &$worksheet; // Store ref for iterator + $this->_sheetnames[$index] = $name; // Store EXTERNSHEET names + $this->_parser->setExtSheet($name, $index); // Register worksheet name with parser return $worksheet; } /** - * Add a new format to the Excel workbook. - * Also, pass any properties to the Format constructor. - * - * @access public - * @param array $properties array with properties for initializing the format. - * @return Spreadsheet_Excel_Writer_Format Spreadsheet_Excel_Writer_Format reference to an Excel Format - */ - public function addFormat($properties = array()) + * Add a new format to the Excel workbook. + * Also, pass any properties to the Format constructor. + * + * @access public + * @param array $properties array with properties for initializing the format. + * @return &Spreadsheet_Excel_Writer_Format reference to an Excel Format + */ + function &addFormat($properties = array()) { - $format = new Spreadsheet_Excel_Writer_Format( - $this->BIFF_version, - $this->xf_index, - $properties - ); - - $this->xf_index += 1; - $this->formats[] = $format; - + $format = new Spreadsheet_Excel_Writer_Format($this->_BIFF_version, $this->_xf_index, $properties); + $this->_xf_index += 1; + $this->_formats[] = &$format; return $format; } @@ -405,13 +374,13 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * Create new validator. * * @access public - * @return Spreadsheet_Excel_Writer_Validator reference to a Validator + * @return &Spreadsheet_Excel_Writer_Validator reference to a Validator */ - public function addValidator() + function &addValidator() { + include_once 'Spreadsheet/Excel/Writer/Validator.php'; /* FIXME: check for successful inclusion*/ - $valid = new Spreadsheet_Excel_Writer_Validator($this->parser); - + $valid = new Spreadsheet_Excel_Writer_Validator($this->_parser); return $valid; } @@ -425,7 +394,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * @param integer $blue blue RGB value [0-255] * @return integer The palette index for the custom color */ - public function setCustomColor($index, $red, $green, $blue) + function setCustomColor($index, $red, $green, $blue) { // Match a HTML #xxyyzz style parameter /*if (defined $_[1] and $_[1] =~ /^#(\w\w)(\w\w)(\w\w)/ ) { @@ -435,7 +404,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri // Check that the colour index is the right range if ($index < 8 or $index > 64) { // TODO: assign real error codes - return $this->raiseError('Color index $index outside range: 8 <= index <= 64'); + return $this->raiseError("Color index $index outside range: 8 <= index <= 64"); } // Check that the colour components are in the right range @@ -443,15 +412,14 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri ($green < 0 or $green > 255) || ($blue < 0 or $blue > 255)) { - return $this->raiseError('Color component outside range: 0 <= color <= 255'); + return $this->raiseError("Color component outside range: 0 <= color <= 255"); } $index -= 8; // Adjust colour index (wingless dragonfly) // Set the RGB value - $this->palette[$index] = array($red, $green, $blue, 0); - - return ($index + 8); + $this->_palette[$index] = array($red, $green, $blue, 0); + return($index + 8); } /** @@ -459,66 +427,66 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * * @access private */ - protected function setPaletteXl97() + function _setPaletteXl97() { - $this->palette = array( - array(0x00, 0x00, 0x00, 0x00), // 8 - array(0xff, 0xff, 0xff, 0x00), // 9 - array(0xff, 0x00, 0x00, 0x00), // 10 - array(0x00, 0xff, 0x00, 0x00), // 11 - array(0x00, 0x00, 0xff, 0x00), // 12 - array(0xff, 0xff, 0x00, 0x00), // 13 - array(0xff, 0x00, 0xff, 0x00), // 14 - array(0x00, 0xff, 0xff, 0x00), // 15 - array(0x80, 0x00, 0x00, 0x00), // 16 - array(0x00, 0x80, 0x00, 0x00), // 17 - array(0x00, 0x00, 0x80, 0x00), // 18 - array(0x80, 0x80, 0x00, 0x00), // 19 - array(0x80, 0x00, 0x80, 0x00), // 20 - array(0x00, 0x80, 0x80, 0x00), // 21 - array(0xc0, 0xc0, 0xc0, 0x00), // 22 - array(0x80, 0x80, 0x80, 0x00), // 23 - array(0x99, 0x99, 0xff, 0x00), // 24 - array(0x99, 0x33, 0x66, 0x00), // 25 - array(0xff, 0xff, 0xcc, 0x00), // 26 - array(0xcc, 0xff, 0xff, 0x00), // 27 - array(0x66, 0x00, 0x66, 0x00), // 28 - array(0xff, 0x80, 0x80, 0x00), // 29 - array(0x00, 0x66, 0xcc, 0x00), // 30 - array(0xcc, 0xcc, 0xff, 0x00), // 31 - array(0x00, 0x00, 0x80, 0x00), // 32 - array(0xff, 0x00, 0xff, 0x00), // 33 - array(0xff, 0xff, 0x00, 0x00), // 34 - array(0x00, 0xff, 0xff, 0x00), // 35 - array(0x80, 0x00, 0x80, 0x00), // 36 - array(0x80, 0x00, 0x00, 0x00), // 37 - array(0x00, 0x80, 0x80, 0x00), // 38 - array(0x00, 0x00, 0xff, 0x00), // 39 - array(0x00, 0xcc, 0xff, 0x00), // 40 - array(0xcc, 0xff, 0xff, 0x00), // 41 - array(0xcc, 0xff, 0xcc, 0x00), // 42 - array(0xff, 0xff, 0x99, 0x00), // 43 - array(0x99, 0xcc, 0xff, 0x00), // 44 - array(0xff, 0x99, 0xcc, 0x00), // 45 - array(0xcc, 0x99, 0xff, 0x00), // 46 - array(0xff, 0xcc, 0x99, 0x00), // 47 - array(0x33, 0x66, 0xff, 0x00), // 48 - array(0x33, 0xcc, 0xcc, 0x00), // 49 - array(0x99, 0xcc, 0x00, 0x00), // 50 - array(0xff, 0xcc, 0x00, 0x00), // 51 - array(0xff, 0x99, 0x00, 0x00), // 52 - array(0xff, 0x66, 0x00, 0x00), // 53 - array(0x66, 0x66, 0x99, 0x00), // 54 - array(0x96, 0x96, 0x96, 0x00), // 55 - array(0x00, 0x33, 0x66, 0x00), // 56 - array(0x33, 0x99, 0x66, 0x00), // 57 - array(0x00, 0x33, 0x00, 0x00), // 58 - array(0x33, 0x33, 0x00, 0x00), // 59 - array(0x99, 0x33, 0x00, 0x00), // 60 - array(0x99, 0x33, 0x66, 0x00), // 61 - array(0x33, 0x33, 0x99, 0x00), // 62 - array(0x33, 0x33, 0x33, 0x00), // 63 - ); + $this->_palette = array( + array(0x00, 0x00, 0x00, 0x00), // 8 + array(0xff, 0xff, 0xff, 0x00), // 9 + array(0xff, 0x00, 0x00, 0x00), // 10 + array(0x00, 0xff, 0x00, 0x00), // 11 + array(0x00, 0x00, 0xff, 0x00), // 12 + array(0xff, 0xff, 0x00, 0x00), // 13 + array(0xff, 0x00, 0xff, 0x00), // 14 + array(0x00, 0xff, 0xff, 0x00), // 15 + array(0x80, 0x00, 0x00, 0x00), // 16 + array(0x00, 0x80, 0x00, 0x00), // 17 + array(0x00, 0x00, 0x80, 0x00), // 18 + array(0x80, 0x80, 0x00, 0x00), // 19 + array(0x80, 0x00, 0x80, 0x00), // 20 + array(0x00, 0x80, 0x80, 0x00), // 21 + array(0xc0, 0xc0, 0xc0, 0x00), // 22 + array(0x80, 0x80, 0x80, 0x00), // 23 + array(0x99, 0x99, 0xff, 0x00), // 24 + array(0x99, 0x33, 0x66, 0x00), // 25 + array(0xff, 0xff, 0xcc, 0x00), // 26 + array(0xcc, 0xff, 0xff, 0x00), // 27 + array(0x66, 0x00, 0x66, 0x00), // 28 + array(0xff, 0x80, 0x80, 0x00), // 29 + array(0x00, 0x66, 0xcc, 0x00), // 30 + array(0xcc, 0xcc, 0xff, 0x00), // 31 + array(0x00, 0x00, 0x80, 0x00), // 32 + array(0xff, 0x00, 0xff, 0x00), // 33 + array(0xff, 0xff, 0x00, 0x00), // 34 + array(0x00, 0xff, 0xff, 0x00), // 35 + array(0x80, 0x00, 0x80, 0x00), // 36 + array(0x80, 0x00, 0x00, 0x00), // 37 + array(0x00, 0x80, 0x80, 0x00), // 38 + array(0x00, 0x00, 0xff, 0x00), // 39 + array(0x00, 0xcc, 0xff, 0x00), // 40 + array(0xcc, 0xff, 0xff, 0x00), // 41 + array(0xcc, 0xff, 0xcc, 0x00), // 42 + array(0xff, 0xff, 0x99, 0x00), // 43 + array(0x99, 0xcc, 0xff, 0x00), // 44 + array(0xff, 0x99, 0xcc, 0x00), // 45 + array(0xcc, 0x99, 0xff, 0x00), // 46 + array(0xff, 0xcc, 0x99, 0x00), // 47 + array(0x33, 0x66, 0xff, 0x00), // 48 + array(0x33, 0xcc, 0xcc, 0x00), // 49 + array(0x99, 0xcc, 0x00, 0x00), // 50 + array(0xff, 0xcc, 0x00, 0x00), // 51 + array(0xff, 0x99, 0x00, 0x00), // 52 + array(0xff, 0x66, 0x00, 0x00), // 53 + array(0x66, 0x66, 0x99, 0x00), // 54 + array(0x96, 0x96, 0x96, 0x00), // 55 + array(0x00, 0x33, 0x66, 0x00), // 56 + array(0x33, 0x99, 0x66, 0x00), // 57 + array(0x00, 0x33, 0x00, 0x00), // 58 + array(0x33, 0x33, 0x00, 0x00), // 59 + array(0x99, 0x33, 0x00, 0x00), // 60 + array(0x99, 0x33, 0x66, 0x00), // 61 + array(0x33, 0x33, 0x99, 0x00), // 62 + array(0x33, 0x33, 0x33, 0x00), // 63 + ); } /** @@ -528,82 +496,73 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * @access private * @return mixed true on success. PEAR_Error on failure */ - protected function storeWorkbook() + function _storeWorkbook() { - if (count($this->workSheet) == 0) { + if (count($this->_worksheets) == 0) { return true; } // Ensure that at least one worksheet has been selected. - if ($this->activeSheet == 0) { - $this->workSheet[0]->selected = 1; + if ($this->_activesheet == 0) { + $this->_worksheets[0]->selected = 1; } // Calculate the number of selected worksheet tabs and call the finalization // methods for each worksheet - $totalNumberOfWorkSheets = count($this->workSheet); - - for ($i = 0; $i < $totalNumberOfWorkSheets; ++$i) { - if ($this->workSheet[$i]->selected) { - ++$this->selectedWorkBook; + $total_worksheets = count($this->_worksheets); + for ($i = 0; $i < $total_worksheets; $i++) { + if ($this->_worksheets[$i]->selected) { + $this->_selected++; } - - $this->workSheet[$i]->close($this->sheetNames); + $this->_worksheets[$i]->close($this->_sheetnames); } // Add Workbook globals - $this->storeBof(0x0005); - $this->storeCodepage(); - - if ($this->BIFF_version == 0x0600) { - $this->storeWindow1(); + $this->_storeBof(0x0005); + $this->_storeCodepage(); + if ($this->_BIFF_version == 0x0600) { + $this->_storeWindow1(); } - - if ($this->BIFF_version == 0x0500) { - $this->storeExterns(); // For print area and repeat rows + if ($this->_BIFF_version == 0x0500) { + $this->_storeExterns(); // For print area and repeat rows } - - $this->storeNames(); // For print area and repeat rows - - if ($this->BIFF_version == 0x0500) { - $this->storeWindow1(); + $this->_storeNames(); // For print area and repeat rows + if ($this->_BIFF_version == 0x0500) { + $this->_storeWindow1(); } - - $this->storeDatemode(); - $this->storeAllFonts(); - $this->storeAllNumFormats(); - $this->storeAllXfs(); - $this->storeAllStyles(); - $this->storePalette(); - $this->calcSheetOffsets(); + $this->_storeDatemode(); + $this->_storeAllFonts(); + $this->_storeAllNumFormats(); + $this->_storeAllXfs(); + $this->_storeAllStyles(); + $this->_storePalette(); + $this->_calcSheetOffsets(); // Add BOUNDSHEET records - for ($i = 0; $i < $totalNumberOfWorkSheets; ++$i) { - $this->storeBoundsheet($this->workSheet[$i]->name,$this->workSheet[$i]->offset); + for ($i = 0; $i < $total_worksheets; $i++) { + $this->_storeBoundsheet($this->_worksheets[$i]->name,$this->_worksheets[$i]->offset); } - if ($this->countryCode != -1) { - $this->storeCountry(); + if ($this->_country_code != -1) { + $this->_storeCountry(); } - if ($this->BIFF_version == 0x0600) { - //$this->storeSupbookInternal(); + if ($this->_BIFF_version == 0x0600) { + //$this->_storeSupbookInternal(); /* TODO: store external SUPBOOK records and XCT and CRN records in case of external references for BIFF8 */ - //$this->storeExternsheetBiff8(); - $this->storeSharedStringsTable(); + //$this->_storeExternsheetBiff8(); + $this->_storeSharedStringsTable(); } // End Workbook globals - $this->storeEof(); + $this->_storeEof(); // Store the workbook in an OLE container - $res = $this->storeOLEFile(); - + $res = $this->_storeOLEFile(); if ($this->isError($res)) { return $this->raiseError($res->getMessage()); } - return true; } @@ -613,46 +572,38 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * @access private * @return mixed true on success. PEAR_Error on failure */ - protected function storeOLEFile() + function _storeOLEFile() { - if ($this->BIFF_version == 0x0600) { + if($this->_BIFF_version == 0x0600) { $OLE = new OLE_PPS_File(OLE::Asc2Ucs('Workbook')); } else { $OLE = new OLE_PPS_File(OLE::Asc2Ucs('Book')); } - - if ($this->temporaryDirectory != '') { - $OLE->setTempDir($this->temporaryDirectory); + if ($this->_tmp_dir != '') { + $OLE->setTempDir($this->_tmp_dir); } - $res = $OLE->init(); - if ($this->isError($res)) { - return $this->raiseError('OLE Error: ' . $res->getMessage()); + return $this->raiseError("OLE Error: ".$res->getMessage()); } + $OLE->append($this->_data); - $OLE->append($this->data); - - $total_worksheets = count($this->workSheet); - - for ($i = 0; $i < $total_worksheets; ++$i) { - while ($tmp = $this->workSheet[$i]->getData()) { + $total_worksheets = count($this->_worksheets); + for ($i = 0; $i < $total_worksheets; $i++) { + while ($tmp = $this->_worksheets[$i]->getData()) { $OLE->append($tmp); } } $root = new OLE_PPS_Root($this->timestamp, $this->timestamp, array($OLE)); - - if ($this->temporaryDirectory != '') { - $root->setTempDir($this->temporaryDirectory); + if ($this->_tmp_dir != '') { + $root->setTempDir($this->_tmp_dir); } - $res = $root->save($this->fileName); - + $res = $root->save($this->_filename); if ($this->isError($res)) { - return $this->raiseError('OLE Error: ' . $res->getMessage()); + return $this->raiseError("OLE Error: ".$res->getMessage()); } - return true; } @@ -661,42 +612,38 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * * @access private */ - protected function calcSheetOffsets() + function _calcSheetOffsets() { - if ($this->BIFF_version == 0x0600) { - $lengthOfTheBoundSheet = 12; // fixed length for a BOUNDSHEET record + if ($this->_BIFF_version == 0x0600) { + $boundsheet_length = 12; // fixed length for a BOUNDSHEET record } else { - $lengthOfTheBoundSheet = 11; + $boundsheet_length = 11; } + $EOF = 4; + $offset = $this->_datasize; - $EOF = 4; - $offset = $this->dataSize; - - if ($this->BIFF_version == 0x0600) { + if ($this->_BIFF_version == 0x0600) { // add the length of the SST /* TODO: check this works for a lot of strings (> 8224 bytes) */ - $offset += $this->calculateSharedStringsSizes(); - - if ($this->countryCode != -1) { + $offset += $this->_calculateSharedStringsSizes(); + if ($this->_country_code != -1) { $offset += 8; // adding COUNTRY record } // add the lenght of SUPBOOK, EXTERNSHEET and NAME records //$offset += 8; // FIXME: calculate real value when storing the records } - $totalNumberOfWorkSheets = count($this->workSheet); + $total_worksheets = count($this->_worksheets); // add the length of the BOUNDSHEET records - - for ($i = 0; $i < $totalNumberOfWorkSheets; ++$i) { - $offset += $lengthOfTheBoundSheet + strlen($this->workSheet[$i]->name); + for ($i = 0; $i < $total_worksheets; $i++) { + $offset += $boundsheet_length + strlen($this->_worksheets[$i]->name); } $offset += $EOF; - for ($i = 0; $i < $totalNumberOfWorkSheets; ++$i) { - $this->workSheet[$i]->offset = $offset; - $offset += $this->workSheet[$i]->_datasize; + for ($i = 0; $i < $total_worksheets; $i++) { + $this->_worksheets[$i]->offset = $offset; + $offset += $this->_worksheets[$i]->_datasize; } - - $this->biffSize = $offset; + $this->_biffsize = $offset; } /** @@ -704,17 +651,17 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * * @access private */ - protected function storeAllFonts() + function _storeAllFonts() { // tmp_format is added by the constructor. We use this to write the default XF's - $format = $this->temporaryFormat; + $format = $this->_tmp_format; $font = $format->getFont(); // Note: Fonts are 0-indexed. According to the SDK there is no index 4, // so the following fonts are 0, 1, 2, 3, 5 // for ($i = 1; $i <= 5; $i++){ - $this->append($font); + $this->_append($font); } // Iterate through the XF objects and write a FONT record if it isn't the @@ -723,24 +670,22 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri $fonts = array(); $index = 6; // The first user defined FONT - $key = $format->getFontKey(); // The default font from temporaryFormat + $key = $format->getFontKey(); // The default font from _tmp_format $fonts[$key] = 0; // Index of the default font - $totalNumberOfFormats = count($this->formats); - - for ($i = 0; $i < $totalNumberOfFormats; ++$i) { - $key = $this->formats[$i]->getFontKey(); - + $total_formats = count($this->_formats); + for ($i = 0; $i < $total_formats; $i++) { + $key = $this->_formats[$i]->getFontKey(); if (isset($fonts[$key])) { // FONT has already been used - $this->formats[$i]->font_index = $fonts[$key]; + $this->_formats[$i]->font_index = $fonts[$key]; } else { // Add a new FONT record $fonts[$key] = $index; - $this->formats[$i]->font_index = $index; - ++$index; - $font = $this->formats[$i]->getFont(); - $this->append($font); + $this->_formats[$i]->font_index = $index; + $index++; + $font = $this->_formats[$i]->getFont(); + $this->_append($font); } } } @@ -750,48 +695,46 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * * @access private */ - protected function storeAllNumFormats() + function _storeAllNumFormats() { // Leaning num_format syndrome - $index = 164; - $numberFormatHashes = array(); - $numberFormats = array(); + $hash_num_formats = array(); + $num_formats = array(); + $index = 164; // Iterate through the XF objects and write a FORMAT record if it isn't a // built-in format type and if the FORMAT string hasn't already been used. - $total_formats = count($this->formats); - - for ($i = 0; $i < $total_formats; ++$i) { - $numberFormat = $this->formats[$i]->_num_format; + $total_formats = count($this->_formats); + for ($i = 0; $i < $total_formats; $i++) { + $num_format = $this->_formats[$i]->_num_format; // Check if $num_format is an index to a built-in format. // Also check for a string of zeros, which is a valid format string // but would evaluate to zero. // - //@todo check if we can saftly replace >>"<< with >>'<< - if (!preg_match("/^0+\d/", $numberFormat)) { - if (preg_match("/^\d+$/", $numberFormat)) { // built-in format + if (!preg_match("/^0+\d/", $num_format)) { + if (preg_match("/^\d+$/", $num_format)) { // built-in format continue; } } - if (isset($numberFormatHashes[$numberFormat])) { + if (isset($hash_num_formats[$num_format])) { // FORMAT has already been used - $this->formats[$i]->_num_format = $numberFormatHashes[$numberFormat]; + $this->_formats[$i]->_num_format = $hash_num_formats[$num_format]; } else{ // Add a new FORMAT - $numberFormatHashes[$numberFormat] = $index; - $this->formats[$i]->_num_format = $index; - array_push($numberFormats,$numberFormat); - ++$index; + $hash_num_formats[$num_format] = $index; + $this->_formats[$i]->_num_format = $index; + array_push($num_formats,$num_format); + $index++; } } // Write the new FORMAT records starting from 0xA4 $index = 164; - foreach ($numberFormats as $numberFormat) { - $this->storeNumFormat($numberFormat,$index); - ++$index; + foreach ($num_formats as $num_format) { + $this->_storeNumFormat($num_format,$index); + $index++; } } @@ -800,26 +743,25 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * * @access private */ - public function storeAllXfs() + function _storeAllXfs() { - // temporaryFormat is added by the constructor. We use this to write the default XF's + // _tmp_format is added by the constructor. We use this to write the default XF's // The default font index is 0 // - $format = $this->temporaryFormat; - - for ($i = 0; $i <= 14; ++$i) { + $format = $this->_tmp_format; + for ($i = 0; $i <= 14; $i++) { $xf = $format->getXf('style'); // Style XF - $this->append($xf); + $this->_append($xf); } $xf = $format->getXf('cell'); // Cell XF - $this->append($xf); + $this->_append($xf); // User defined XFs - $total_formats = count($this->formats); - for ($i = 0; $i < $total_formats; ++$i) { - $xf = $this->formats[$i]->getXf('cell'); - $this->append($xf); + $total_formats = count($this->_formats); + for ($i = 0; $i < $total_formats; $i++) { + $xf = $this->_formats[$i]->getXf('cell'); + $this->_append($xf); } } @@ -828,9 +770,9 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * * @access private */ - protected function storeAllStyles() + function _storeAllStyles() { - $this->storeStyle(); + $this->_storeStyle(); } /** @@ -839,14 +781,15 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * * @access private */ - protected function storeExterns() + function _storeExterns() + { // Create EXTERNCOUNT with number of worksheets - $this->storeExterncount(count($this->workSheet)); + $this->_storeExterncount(count($this->_worksheets)); // Create EXTERNSHEET for each worksheet - foreach ($this->sheetNames as $sheetname) { - $this->storeExternsheet($sheetname); + foreach ($this->_sheetnames as $sheetname) { + $this->_storeExternsheet($sheetname); } } @@ -855,33 +798,31 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * * @access private */ - protected function storeNames() + function _storeNames() { // Create the print area NAME records - $total_worksheets = count($this->workSheet); - - for ($i = 0; $i < $total_worksheets; ++$i) { + $total_worksheets = count($this->_worksheets); + for ($i = 0; $i < $total_worksheets; $i++) { // Write a Name record if the print area has been defined - if (isset($this->workSheet[$i]->print_rowmin)) { - $this->storeNameShort( - $this->workSheet[$i]->index, + if (isset($this->_worksheets[$i]->print_rowmin)) { + $this->_storeNameShort( + $this->_worksheets[$i]->index, 0x06, // NAME type - $this->workSheet[$i]->print_rowmin, - $this->workSheet[$i]->print_rowmax, - $this->workSheet[$i]->print_colmin, - $this->workSheet[$i]->print_colmax + $this->_worksheets[$i]->print_rowmin, + $this->_worksheets[$i]->print_rowmax, + $this->_worksheets[$i]->print_colmin, + $this->_worksheets[$i]->print_colmax ); } } // Create the print title NAME records - $total_worksheets = count($this->workSheet); - - for ($i = 0; $i < $total_worksheets; ++$i) { - $rowmin = $this->workSheet[$i]->title_rowmin; - $rowmax = $this->workSheet[$i]->title_rowmax; - $colmin = $this->workSheet[$i]->title_colmin; - $colmax = $this->workSheet[$i]->title_colmax; + $total_worksheets = count($this->_worksheets); + for ($i = 0; $i < $total_worksheets; $i++) { + $rowmin = $this->_worksheets[$i]->title_rowmin; + $rowmax = $this->_worksheets[$i]->title_rowmax; + $colmin = $this->_worksheets[$i]->title_colmin; + $colmax = $this->_worksheets[$i]->title_colmax; // Determine if row + col, row, col or nothing has been defined // and write the appropriate record @@ -889,8 +830,8 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri if (isset($rowmin) && isset($colmin)) { // Row and column titles have been defined. // Row title has been defined. - $this->storeNameLong( - $this->workSheet[$i]->index, + $this->_storeNameLong( + $this->_worksheets[$i]->index, 0x07, // NAME type $rowmin, $rowmax, @@ -899,8 +840,8 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri ); } elseif (isset($rowmin)) { // Row title has been defined. - $this->storeNameShort( - $this->workSheet[$i]->index, + $this->_storeNameShort( + $this->_worksheets[$i]->index, 0x07, // NAME type $rowmin, $rowmax, @@ -909,8 +850,8 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri ); } elseif (isset($colmin)) { // Column title has been defined. - $this->storeNameShort( - $this->workSheet[$i]->index, + $this->_storeNameShort( + $this->_worksheets[$i]->index, 0x07, // NAME type 0x0000, 0x3fff, @@ -937,16 +878,16 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * * @access private */ - protected function storeCodepage() + function _storeCodepage() { $record = 0x0042; // Record identifier $length = 0x0002; // Number of bytes to follow - $cv = $this->codePage; // The code page + $cv = $this->_codepage; // The code page $header = pack('vv', $record, $length); $data = pack('v', $cv); - $this->append($header . $data); + $this->_append($header . $data); } /** @@ -954,7 +895,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * * @access private */ - protected function storeWindow1() + function _storeWindow1() { $record = 0x003D; // Record identifier $length = 0x0012; // Number of bytes to follow @@ -965,55 +906,51 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri $dyWn = 0x1572; // Height of window $grbit = 0x0038; // Option flags - $ctabsel = $this->selectedWorkBook; // Number of workbook tabs selected + $ctabsel = $this->_selected; // Number of workbook tabs selected $wTabRatio = 0x0258; // Tab to scrollbar ratio - $itabFirst = $this->firstSheet; // 1st displayed worksheet - $itabCur = $this->activeSheet; // Active worksheet + $itabFirst = $this->_firstsheet; // 1st displayed worksheet + $itabCur = $this->_activesheet; // Active worksheet - $header = pack('vv', $record, $length); - $data = pack('vvvvvvvvv', $xWn, $yWn, $dxWn, $dyWn, + $header = pack("vv", $record, $length); + $data = pack("vvvvvvvvv", $xWn, $yWn, $dxWn, $dyWn, $grbit, $itabCur, $itabFirst, $ctabsel, $wTabRatio); - $this->append($header . $data); + $this->_append($header . $data); } /** * Writes Excel BIFF BOUNDSHEET record. * FIXME: inconsistent with BIFF documentation * - * @param string $sheetName Worksheet name + * @param string $sheetname Worksheet name * @param integer $offset Location of worksheet BOF * @access private */ - protected function storeBoundsheet($sheetName, $offset) + function _storeBoundsheet($sheetname,$offset) { - $record = 0x0085; // Record identifier - - if ($this->BIFF_version == 0x0600) { - $length = 0x08 + strlen($sheetName); // Number of bytes to follow + $record = 0x0085; // Record identifier + if ($this->_BIFF_version == 0x0600) { + $length = 0x08 + strlen($sheetname); // Number of bytes to follow } else { - $length = 0x07 + strlen($sheetName); // Number of bytes to follow + $length = 0x07 + strlen($sheetname); // Number of bytes to follow } - $grbit = 0x0000; // Visibility and sheet type - - if ($this->BIFF_version == 0x0600) { - $cch = mb_strlen($sheetName,'UTF-16LE'); // Length of sheet name + $grbit = 0x0000; // Visibility and sheet type + if ($this->_BIFF_version == 0x0600) { + $cch = mb_strlen($sheetname,'UTF-16LE'); // Length of sheet name } else { - $cch = strlen($sheetName); // Length of sheet name + $cch = strlen($sheetname); // Length of sheet name } - $header = pack('vv', $record, $length); - - if ($this->BIFF_version == 0x0600) { - $data = pack('VvCC', $offset, $grbit, $cch, 0x1); + $header = pack("vv", $record, $length); + if ($this->_BIFF_version == 0x0600) { + $data = pack("VvCC", $offset, $grbit, $cch, 0x1); } else { - $data = pack('VvC', $offset, $grbit, $cch); + $data = pack("VvC", $offset, $grbit, $cch); } - - $this->append($header . $data . $sheetName); + $this->_append($header.$data.$sheetname); } /** @@ -1021,14 +958,14 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * * @access private */ - protected function storeSupbookInternal() + function _storeSupbookInternal() { $record = 0x01AE; // Record identifier $length = 0x0004; // Bytes to follow - $header = pack('vv', $record, $length); - $data = pack('vv', count($this->workSheet), 0x0104); - $this->append($header . $data); + $header = pack("vv", $record, $length); + $data = pack("vv", count($this->_worksheets), 0x0104); + $this->_append($header . $data); } /** @@ -1038,19 +975,19 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * @param string $sheetname Worksheet name * @access private */ - protected function storeExternsheetBiff8() + function _storeExternsheetBiff8() { - $total_references = count($this->parser->_references); - $record = 0x0017; // Record identifier - $length = 2 + 6 * $total_references; // Number of bytes to follow - $header = pack('vv', $record, $length); - $data = pack('v', $total_references); + $total_references = count($this->_parser->_references); + $record = 0x0017; // Record identifier + $length = 2 + 6 * $total_references; // Number of bytes to follow - for ($i = 0; $i < $total_references; ++$i) { - $data .= $this->parser->_references[$i]; + $supbook_index = 0; // FIXME: only using internal SUPBOOK record + $header = pack("vv", $record, $length); + $data = pack('v', $total_references); + for ($i = 0; $i < $total_references; $i++) { + $data .= $this->_parser->_references[$i]; } - - $this->append($header . $data); + $this->_append($header . $data); } /** @@ -1058,7 +995,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * * @access private */ - protected function storeStyle() + function _storeStyle() { $record = 0x0293; // Record identifier $length = 0x0004; // Bytes to follow @@ -1067,9 +1004,9 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri $BuiltIn = 0x00; // Built-in style $iLevel = 0xff; // Outline style level - $header = pack('vv', $record, $length); - $data = pack('vCC', $ixfe, $BuiltIn, $iLevel); - $this->append($header . $data); + $header = pack("vv", $record, $length); + $data = pack("vCC", $ixfe, $BuiltIn, $iLevel); + $this->_append($header . $data); } @@ -1080,18 +1017,18 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * @param integer $ifmt Format index code * @access private */ - protected function storeNumFormat($format, $ifmt) + function _storeNumFormat($format, $ifmt) { $record = 0x041E; // Record identifier - if ($this->BIFF_version == 0x0600) { + if ($this->_BIFF_version == 0x0600) { $length = 5 + strlen($format); // Number of bytes to follow $encoding = 0x0; - } elseif ($this->BIFF_version == 0x0500) { + } elseif ($this->_BIFF_version == 0x0500) { $length = 3 + strlen($format); // Number of bytes to follow } - if ( $this->BIFF_version == 0x0600 && function_exists('iconv') ) { // Encode format String + if ( $this->_BIFF_version == 0x0600 && function_exists('iconv') ) { // Encode format String if (mb_detect_encoding($format, 'auto') !== 'UTF-16LE'){ $format = iconv(mb_detect_encoding($format, 'auto'),'UTF-16LE',$format); } @@ -1103,14 +1040,14 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri } $length = strlen($format); - if ($this->BIFF_version == 0x0600) { - $header = pack('vv', $record, 5 + $length); - $data = pack('vvC', $ifmt, $cch, $encoding); - } elseif ($this->BIFF_version == 0x0500) { - $header = pack('vv', $record, 3 + $length); - $data = pack('vC', $ifmt, $cch); + if ($this->_BIFF_version == 0x0600) { + $header = pack("vv", $record, 5 + $length); + $data = pack("vvC", $ifmt, $cch, $encoding); + } elseif ($this->_BIFF_version == 0x0500) { + $header = pack("vv", $record, 3 + $length); + $data = pack("vC", $ifmt, $cch); } - $this->append($header . $data . $format); + $this->_append($header . $data . $format); } /** @@ -1118,16 +1055,16 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * * @access private */ - protected function storeDatemode() + function _storeDatemode() { $record = 0x0022; // Record identifier $length = 0x0002; // Bytes to follow - $f1904 = $this->flagFor1904; // Flag for 1904 date system + $f1904 = $this->_1904; // Flag for 1904 date system - $header = pack('vv', $record, $length); - $data = pack('v', $f1904); - $this->append($header . $data); + $header = pack("vv", $record, $length); + $data = pack("v", $f1904); + $this->_append($header . $data); } @@ -1144,14 +1081,14 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * @param integer $cxals Number of external references * @access private */ - protected function storeExterncount($cxals) + function _storeExterncount($cxals) { $record = 0x0016; // Record identifier $length = 0x0002; // Number of bytes to follow - $header = pack('vv', $record, $length); - $data = pack('v', $cxals); - $this->append($header . $data); + $header = pack("vv", $record, $length); + $data = pack("v", $cxals); + $this->_append($header . $data); } @@ -1162,20 +1099,20 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * * A similar method is used in Worksheet.php for a slightly different purpose. * - * @param string $sheetName Worksheet name + * @param string $sheetname Worksheet name * @access private */ - protected function storeExternsheet($sheetName) + function _storeExternsheet($sheetname) { $record = 0x0017; // Record identifier - $length = 0x02 + strlen($sheetName); // Number of bytes to follow + $length = 0x02 + strlen($sheetname); // Number of bytes to follow - $cch = strlen($sheetName); // Length of sheet name + $cch = strlen($sheetname); // Length of sheet name $rgch = 0x03; // Filename encoding - $header = pack('vv', $record, $length); - $data = pack('CC', $cch, $rgch); - $this->append($header . $data . $sheetName); + $header = pack("vv", $record, $length); + $data = pack("CC", $cch, $rgch); + $this->_append($header . $data . $sheetname); } @@ -1191,7 +1128,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * @param integer $colmax End column * @access private */ - protected function storeNameShort($index, $type, $rowmin, $rowmax, $colmin, $colmax) + function _storeNameShort($index, $type, $rowmin, $rowmax, $colmin, $colmax) { $record = 0x0018; // Record identifier $length = 0x0024; // Number of bytes to follow @@ -1215,38 +1152,38 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri $unknown07 = 0x1087; $unknown08 = 0x8005; - $header = pack('vv', $record, $length); - $data = pack('v', $grbit); - $data .= pack('C', $chKey); - $data .= pack('C', $cch); - $data .= pack('v', $cce); - $data .= pack('v', $ixals); - $data .= pack('v', $itab); - $data .= pack('C', $cchCustMenu); - $data .= pack('C', $cchDescription); - $data .= pack('C', $cchHelptopic); - $data .= pack('C', $cchStatustext); - $data .= pack('C', $rgch); - $data .= pack('C', $unknown03); - $data .= pack('v', $unknown04); - $data .= pack('v', $unknown05); - $data .= pack('v', $unknown06); - $data .= pack('v', $unknown07); - $data .= pack('v', $unknown08); - $data .= pack('v', $index); - $data .= pack('v', $index); - $data .= pack('v', $rowmin); - $data .= pack('v', $rowmax); - $data .= pack('C', $colmin); - $data .= pack('C', $colmax); - $this->append($header . $data); + $header = pack("vv", $record, $length); + $data = pack("v", $grbit); + $data .= pack("C", $chKey); + $data .= pack("C", $cch); + $data .= pack("v", $cce); + $data .= pack("v", $ixals); + $data .= pack("v", $itab); + $data .= pack("C", $cchCustMenu); + $data .= pack("C", $cchDescription); + $data .= pack("C", $cchHelptopic); + $data .= pack("C", $cchStatustext); + $data .= pack("C", $rgch); + $data .= pack("C", $unknown03); + $data .= pack("v", $unknown04); + $data .= pack("v", $unknown05); + $data .= pack("v", $unknown06); + $data .= pack("v", $unknown07); + $data .= pack("v", $unknown08); + $data .= pack("v", $index); + $data .= pack("v", $index); + $data .= pack("v", $rowmin); + $data .= pack("v", $rowmax); + $data .= pack("C", $colmin); + $data .= pack("C", $colmax); + $this->_append($header . $data); } /** * Store the NAME record in the long format that is used for storing the repeat * rows and columns when both are specified. This shares a lot of code with - * storeNameShort() but we use a separate method to keep the code clean. + * _storeNameShort() but we use a separate method to keep the code clean. * Code abstraction for reuse can be carried too far, and I should know. ;-) * * @param integer $index Sheet index @@ -1257,7 +1194,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * @param integer $colmax End column * @access private */ - protected function storeNameLong($index, $type, $rowmin, $rowmax, $colmin, $colmax) + function _storeNameLong($index, $type, $rowmin, $rowmax, $colmin, $colmax) { $record = 0x0018; // Record identifier $length = 0x003d; // Number of bytes to follow @@ -1282,49 +1219,49 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri $unknown07 = 0x1087; $unknown08 = 0x8008; - $header = pack('vv', $record, $length); - $data = pack('v', $grbit); - $data .= pack('C', $chKey); - $data .= pack('C', $cch); - $data .= pack('v', $cce); - $data .= pack('v', $ixals); - $data .= pack('v', $itab); - $data .= pack('C', $cchCustMenu); - $data .= pack('C', $cchDescription); - $data .= pack('C', $cchHelptopic); - $data .= pack('C', $cchStatustext); - $data .= pack('C', $rgch); - $data .= pack('C', $unknown01); - $data .= pack('v', $unknown02); + $header = pack("vv", $record, $length); + $data = pack("v", $grbit); + $data .= pack("C", $chKey); + $data .= pack("C", $cch); + $data .= pack("v", $cce); + $data .= pack("v", $ixals); + $data .= pack("v", $itab); + $data .= pack("C", $cchCustMenu); + $data .= pack("C", $cchDescription); + $data .= pack("C", $cchHelptopic); + $data .= pack("C", $cchStatustext); + $data .= pack("C", $rgch); + $data .= pack("C", $unknown01); + $data .= pack("v", $unknown02); // Column definition - $data .= pack('C', $unknown03); - $data .= pack('v', $unknown04); - $data .= pack('v', $unknown05); - $data .= pack('v', $unknown06); - $data .= pack('v', $unknown07); - $data .= pack('v', $unknown08); - $data .= pack('v', $index); - $data .= pack('v', $index); - $data .= pack('v', 0x0000); - $data .= pack('v', 0x3fff); - $data .= pack('C', $colmin); - $data .= pack('C', $colmax); + $data .= pack("C", $unknown03); + $data .= pack("v", $unknown04); + $data .= pack("v", $unknown05); + $data .= pack("v", $unknown06); + $data .= pack("v", $unknown07); + $data .= pack("v", $unknown08); + $data .= pack("v", $index); + $data .= pack("v", $index); + $data .= pack("v", 0x0000); + $data .= pack("v", 0x3fff); + $data .= pack("C", $colmin); + $data .= pack("C", $colmax); // Row definition - $data .= pack('C', $unknown03); - $data .= pack('v', $unknown04); - $data .= pack('v', $unknown05); - $data .= pack('v', $unknown06); - $data .= pack('v', $unknown07); - $data .= pack('v', $unknown08); - $data .= pack('v', $index); - $data .= pack('v', $index); - $data .= pack('v', $rowmin); - $data .= pack('v', $rowmax); - $data .= pack('C', 0x00); - $data .= pack('C', 0xff); + $data .= pack("C", $unknown03); + $data .= pack("v", $unknown04); + $data .= pack("v", $unknown05); + $data .= pack("v", $unknown06); + $data .= pack("v", $unknown07); + $data .= pack("v", $unknown08); + $data .= pack("v", $index); + $data .= pack("v", $index); + $data .= pack("v", $rowmin); + $data .= pack("v", $rowmax); + $data .= pack("C", 0x00); + $data .= pack("C", 0xff); // End of data - $data .= pack('C', 0x10); - $this->append($header . $data); + $data .= pack("C", 0x10); + $this->_append($header . $data); } /** @@ -1332,15 +1269,15 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * * @access private */ - protected function storeCountry() + function _storeCountry() { $record = 0x008C; // Record identifier $length = 4; // Number of bytes to follow $header = pack('vv', $record, $length); /* using the same country code always for simplicity */ - $data = pack('vv', $this->countryCode, $this->countryCode); - $this->append($header . $data); + $data = pack('vv', $this->_country_code, $this->_country_code); + $this->_append($header . $data); } /** @@ -1348,9 +1285,9 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * * @access private */ - protected function storePalette() + function _storePalette() { - $aref = $this->palette; + $aref = $this->_palette; $record = 0x0092; // Record identifier $length = 2 + 4 * count($aref); // Number of bytes to follow @@ -1360,12 +1297,12 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri // Pack the RGB data foreach ($aref as $color) { foreach ($color as $byte) { - $data .= pack('C', $byte); + $data .= pack("C",$byte); } } - $header = pack('vvv', $record, $length, $ccv); - $this->append($header . $data); + $header = pack("vvv", $record, $length, $ccv); + $this->_append($header . $data); } /** @@ -1378,7 +1315,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * * @access private */ - protected function calculateSharedStringsSizes() + function _calculateSharedStringsSizes() { /* Iterate through the strings to calculate the CONTINUE block sizes. For simplicity we use the same size for the SST and CONTINUE records: @@ -1390,13 +1327,13 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri $continue_limit = 8208; $block_length = 0; $written = 0; - $this->blockSize = array(); + $this->_block_sizes = array(); $continue = 0; - foreach (array_keys($this->tableOfStrings) as $string) { + foreach (array_keys($this->_str_table) as $string) { $string_length = strlen($string); - $headerinfo = unpack('vlength/Cencoding', $string); - $encoding = $headerinfo['encoding']; + $headerinfo = unpack("vlength/Cencoding", $string); + $encoding = $headerinfo["encoding"]; $split_string = 0; // Block length is the total length of the strings that will be @@ -1456,7 +1393,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri $block_length -= $continue_limit - $continue - $align; // Store the max size for this block - $this->blockSize[] = $continue_limit - $align; + $this->_block_sizes[] = $continue_limit - $align; // If the current string was split then the next CONTINUE block // should have the string continue flag (grbit) set unless the @@ -1468,7 +1405,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri } } else { // Store the max size for this block - $this->blockSize[] = $written + $continue; + $this->_block_sizes[] = $written + $continue; // Not enough space to start the string in the current block $block_length -= $continue_limit - $space_remaining - $continue; @@ -1489,7 +1426,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri // Store the max size for the last block unless it is empty if ($written + $continue) { - $this->blockSize[] = $written + $continue; + $this->_block_sizes[] = $written + $continue; } @@ -1499,13 +1436,13 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri they must be written before the SST records */ - $tmp_block_sizes = $this->blockSize; - $length = 12; + $tmp_block_sizes = array(); + $tmp_block_sizes = $this->_block_sizes; + $length = 12; if (!empty($tmp_block_sizes)) { $length += array_shift($tmp_block_sizes); // SST } - while (!empty($tmp_block_sizes)) { $length += 4 + array_shift($tmp_block_sizes); // CONTINUEs } @@ -1524,7 +1461,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * * @access private */ - protected function storeSharedStringsTable() + function _storeSharedStringsTable() { $record = 0x00fc; // Record identifier $length = 0x0008; // Number of bytes to follow @@ -1537,8 +1474,8 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri $continue = 0; // sizes are upside down - $tmp_block_sizes = $this->blockSize; - // $tmp_block_sizes = array_reverse($this->blockSize); + $tmp_block_sizes = $this->_block_sizes; + // $tmp_block_sizes = array_reverse($this->_block_sizes); // The SST record is required even if it contains no strings. Thus we will // always have a length @@ -1554,19 +1491,19 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri // Write the SST block header information - $header = pack('vv', $record, $length); - $data = pack('VV', $this->totalStringLength, $this->uniqueString); - $this->append($header . $data); + $header = pack("vv", $record, $length); + $data = pack("VV", $this->_str_total, $this->_str_unique); + $this->_append($header . $data); /* TODO: not good for performance */ - foreach (array_keys($this->tableOfStrings) as $string) { + foreach (array_keys($this->_str_table) as $string) { $string_length = strlen($string); - $headerinfo = unpack('vlength/Cencoding', $string); - $encoding = $headerinfo['encoding']; + $headerinfo = unpack("vlength/Cencoding", $string); + $encoding = $headerinfo["encoding"]; $split_string = 0; // Block length is the total length of the strings that will be @@ -1577,7 +1514,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri // We can write the string if it doesn't cross a CONTINUE boundary if ($block_length < $continue_limit) { - $this->append($string); + $this->_append($string); $written += $string_length; continue; } @@ -1625,7 +1562,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri if ($space_remaining > $header_length) { // Write as much as possible of the string in the current block $tmp = substr($string, 0, $space_remaining); - $this->append($tmp); + $this->_append($tmp); // The remainder will be written in the next block(s) $string = substr($string, $space_remaining); @@ -1649,7 +1586,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri } // Write the CONTINUE block header - if (!empty($this->blockSize)) { + if (!empty($this->_block_sizes)) { $record = 0x003C; $length = array_shift($tmp_block_sizes); @@ -1657,7 +1594,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri if ($continue) { $header .= pack('C', $encoding); } - $this->append($header); + $this->_append($header); } // If the string (or substr) is small enough we can write it in the @@ -1665,7 +1602,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri // one or more CONTINUE blocks // if ($block_length < $continue_limit) { - $this->append($string); + $this->_append($string); $written = $block_length; } else { $written = 0; @@ -1673,5 +1610,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri } } } + + } diff --git a/Spreadsheet/Excel/Writer/Worksheet.php b/Spreadsheet/Excel/Writer/Worksheet.php index b38fa71..2cbf9b0 100644 --- a/Spreadsheet/Excel/Writer/Worksheet.php +++ b/Spreadsheet/Excel/Writer/Worksheet.php @@ -32,8 +32,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -require_once __DIR__ . '/Parser.php'; -require_once __DIR__ . '/BIFFwriter.php'; +require_once 'Spreadsheet/Excel/Writer/Parser.php'; +require_once 'Spreadsheet/Excel/Writer/BIFFwriter.php'; /** * Class for generating Excel Spreadsheets @@ -49,375 +49,364 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * Name of the Worksheet * @var string */ - public $name; + var $name; /** * Index for the Worksheet * @var integer */ - public $index; + var $index; /** * Reference to the (default) Format object for URLs - * @var Spreadsheet_Excel_Writer_Format + * @var object Format */ - public $_url_format; + var $_url_format; /** * Reference to the parser used for parsing formulas - * @var Spreadsheet_Excel_Writer_Format + * @var object Format */ - public $_parser; + var $_parser; /** * Filehandle to the temporary file for storing data * @var resource */ - public $_filehandle; + var $_filehandle; /** * Boolean indicating if we are using a temporary file for storing data * @var bool */ - public $_using_tmpfile; + var $_using_tmpfile; /** * Maximum number of rows for an Excel spreadsheet (BIFF5) * @var integer */ - public $_xls_rowmax; + var $_xls_rowmax; /** * Maximum number of columns for an Excel spreadsheet (BIFF5) * @var integer */ - public $_xls_colmax; + var $_xls_colmax; /** * Maximum number of characters for a string (LABEL record in BIFF5) * @var integer */ - public $_xls_strmax; + var $_xls_strmax; /** * First row for the DIMENSIONS record * @var integer * @see _storeDimensions() */ - public $_dim_rowmin; + var $_dim_rowmin; /** * Last row for the DIMENSIONS record * @var integer * @see _storeDimensions() */ - public $_dim_rowmax; + var $_dim_rowmax; /** * First column for the DIMENSIONS record * @var integer * @see _storeDimensions() */ - public $_dim_colmin; + var $_dim_colmin; /** * Last column for the DIMENSIONS record * @var integer * @see _storeDimensions() */ - public $_dim_colmax; + var $_dim_colmax; /** * Array containing format information for columns * @var array */ - public $_colinfo; + var $_colinfo; /** * Array containing the selected area for the worksheet * @var array */ - public $_selection; + var $_selection; /** * Array containing the panes for the worksheet * @var array */ - public $_panes; + var $_panes; /** * The active pane for the worksheet * @var integer */ - public $_active_pane; + var $_active_pane; /** * Bit specifying if panes are frozen * @var integer */ - public $_frozen; + var $_frozen; /** * Bit specifying if the worksheet is selected * @var integer */ - public $selected; + var $selected; /** * The paper size (for printing) (DOCUMENT!!!) * @var integer */ - public $_paper_size; + var $_paper_size; /** * Bit specifying paper orientation (for printing). 0 => landscape, 1 => portrait * @var integer */ - public $_orientation; + var $_orientation; /** * The page header caption * @var string */ - public $_header; + var $_header; /** * The page footer caption * @var string */ - public $_footer; + var $_footer; /** * The horizontal centering value for the page * @var integer */ - public $_hcenter; + var $_hcenter; /** * The vertical centering value for the page * @var integer */ - public $_vcenter; + var $_vcenter; /** * The margin for the header * @var float */ - public $_margin_head; + var $_margin_head; /** * The margin for the footer * @var float */ - public $_margin_foot; + var $_margin_foot; /** * The left margin for the worksheet in inches * @var float */ - public $_margin_left; + var $_margin_left; /** * The right margin for the worksheet in inches * @var float */ - public $_margin_right; + var $_margin_right; /** * The top margin for the worksheet in inches * @var float */ - public $_margin_top; + var $_margin_top; /** * The bottom margin for the worksheet in inches * @var float */ - public $_margin_bottom; + var $_margin_bottom; /** * First row to reapeat on each printed page * @var integer */ - public $title_rowmin; + var $title_rowmin; /** * Last row to reapeat on each printed page * @var integer */ - public $title_rowmax; + var $title_rowmax; /** * First column to reapeat on each printed page * @var integer */ - public $title_colmin; + var $title_colmin; /** * First row of the area to print * @var integer */ - public $print_rowmin; + var $print_rowmin; /** * Last row to of the area to print * @var integer */ - public $print_rowmax; + var $print_rowmax; /** * First column of the area to print * @var integer */ - public $print_colmin; + var $print_colmin; /** * Last column of the area to print * @var integer */ - public $print_colmax; + var $print_colmax; /** * Whether to display RightToLeft. * @var integer */ - public $_Arabic; + var $_Arabic; /** * Whether to use outline. * @var integer */ - public $_outline_on; + var $_outline_on; /** * Auto outline styles. * @var bool */ - public $_outline_style; + var $_outline_style; /** * Whether to have outline summary below. * @var bool */ - public $_outline_below; + var $_outline_below; /** * Whether to have outline summary at the right. * @var bool */ - public $_outline_right; + var $_outline_right; /** * Outline row level. * @var integer */ - public $_outline_row_level; + var $_outline_row_level; /** * Whether to fit to page when printing or not. * @var bool */ - public $_fit_page; + var $_fit_page; /** * Number of pages to fit wide * @var integer */ - public $_fit_width; + var $_fit_width; /** * Number of pages to fit high * @var integer */ - public $_fit_height; + var $_fit_height; /** * Reference to the total number of strings in the workbook * @var integer */ - public $_str_total; + var $_str_total; /** * Reference to the number of unique strings in the workbook * @var integer */ - public $_str_unique; + var $_str_unique; /** * Reference to the array containing all the unique strings in the workbook * @var array */ - public $_str_table; + var $_str_table; /** * Number of merged cell ranges in actual record * @var int $_merged_cells_counter */ - public $_merged_cells_counter = 0; + var $_merged_cells_counter = 0; /** * Number of actual mergedcells record * @var int $_merged_cells_record */ - public $_merged_cells_record = 0; + var $_merged_cells_record = 0; /** * Merged cell ranges * @var array */ - public $_merged_ranges; + var $_merged_ranges; /** * Charset encoding currently used when calling writeString() * @var string */ - public $_input_encoding; - - public $activesheet; - - public $firstsheet; + var $_input_encoding; /** * Constructor * * @param string $name The name of the new worksheet * @param integer $index The index of the new worksheet - * @param mixed $activeSheet The current activesheet of the workbook we belong to - * @param mixed $firstSheet The first worksheet in the workbook we belong to - * @param mixed $url_format The default format for hyperlinks - * @param mixed $parser The formula parser created for the Workbook + * @param mixed &$activesheet The current activesheet of the workbook we belong to + * @param mixed &$firstsheet The first worksheet in the workbook we belong to + * @param mixed &$url_format The default format for hyperlinks + * @param mixed &$parser The formula parser created for the Workbook * @param string $tmp_dir The path to the directory for temporary files * @access private */ - public function __construct( - $BIFF_version, - $name, - $index, - $activeSheet, - $firstSheet, - $str_total, - $str_unique, - $str_table, - $url_format, - $parser, - $tmp_dir - ) + function Spreadsheet_Excel_Writer_Worksheet($BIFF_version, $name, + $index, &$activesheet, + &$firstsheet, &$str_total, + &$str_unique, &$str_table, + &$url_format, &$parser, + $tmp_dir) { // It needs to call its parent's constructor explicitly - parent::__construct(); - $this->BIFF_version = $BIFF_version; + $this->Spreadsheet_Excel_Writer_BIFFwriter(); + $this->_BIFF_version = $BIFF_version; $rowmax = 65536; // 16384 in Excel 5 $colmax = 256; $this->name = $name; $this->index = $index; - $this->activesheet = $activeSheet; - $this->firstsheet = $firstSheet; - $this->_str_total = $str_total; - $this->_str_unique = $str_unique; - $this->_str_table = $str_table; - $this->_url_format = $url_format; - $this->_parser = $parser; + $this->activesheet = &$activesheet; + $this->firstsheet = &$firstsheet; + $this->_str_total = &$str_total; + $this->_str_unique = &$str_unique; + $this->_str_table = &$str_table; + $this->_url_format = &$url_format; + $this->_parser = &$parser; //$this->ext_sheets = array(); $this->_filehandle = ''; @@ -493,8 +482,8 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr $this->_dv = array(); - $this->temporaryDirectory = $tmp_dir; - $this->temporaryFile = ''; + $this->_tmp_dir = $tmp_dir; + $this->_tmp_file = ''; $this->_initialize(); } @@ -506,13 +495,13 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access private */ - protected function _initialize() + function _initialize() { if ($this->_using_tmpfile == false) { return; } - if ($this->temporaryDirectory === '' && ini_get('open_basedir') === true) { + if ($this->_tmp_dir === '' && ini_get('open_basedir') === true) { // open_basedir restriction in effect - store data in memory // ToDo: Let the error actually have an effect somewhere $this->_using_tmpfile = false; @@ -520,12 +509,12 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr } // Open tmp file for storing Worksheet data - if ($this->temporaryDirectory === '') { + if ($this->_tmp_dir === '') { $fh = tmpfile(); } else { // For people with open base dir restriction - $this->temporaryFile = tempnam($this->temporaryDirectory, 'Spreadsheet_Excel_Writer'); - $fh = @fopen($this->temporaryFile, 'w+b'); + $this->_tmp_file = tempnam($this->_tmp_dir, "Spreadsheet_Excel_Writer"); + $fh = @fopen($this->_tmp_file, "w+b"); } if ($fh === false) { @@ -546,7 +535,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param array $sheetnames The array of sheetnames from the Workbook this * worksheet belongs to */ - public function close($sheetnames) + function close($sheetnames) { $num_sheets = count($sheetnames); @@ -604,7 +593,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr $this->_storeGridset(); // Prepend GUTS - if ($this->BIFF_version == 0x0500) { + if ($this->_BIFF_version == 0x0500) { $this->_storeGuts(); } @@ -615,7 +604,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr $this->_storePrintHeaders(); // Prepend EXTERNSHEET references - if ($this->BIFF_version == 0x0500) { + if ($this->_BIFF_version == 0x0500) { for ($i = $num_sheets; $i > 0; $i--) { $sheetname = $sheetnames[$i-1]; $this->_storeExternsheet($sheetname); @@ -623,7 +612,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr } // Prepend the EXTERNCOUNT of external references. - if ($this->BIFF_version == 0x0500) { + if ($this->_BIFF_version == 0x0500) { $this->_storeExterncount($num_sheets); } @@ -637,7 +626,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr } // Prepend the BOF record - $this->storeBof(0x0010); + $this->_storeBof(0x0010); /* * End of prepend. Read upwards from here. @@ -652,18 +641,18 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr $this->_storeSelection($this->_selection); $this->_storeMergedCells(); /* TODO: add data validity */ - /*if ($this->BIFF_version == 0x0600) { + /*if ($this->_BIFF_version == 0x0600) { $this->_storeDataValidity(); }*/ - $this->storeEof(); + $this->_storeEof(); - if ( $this->temporaryFile != '' ) { + if ( $this->_tmp_file != '' ) { if ( $this->_filehandle ) { fclose($this->_filehandle); $this->_filehandle = ''; } - @unlink($this->temporaryFile); - $this->temporaryFile = ''; + @unlink($this->_tmp_file); + $this->_tmp_file = ''; $this->_using_tmpfile = true; } } @@ -675,7 +664,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @access public * @return string The worksheet's name */ - public function getName() + function getName() { return $this->name; } @@ -686,14 +675,14 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @return string The data */ - public function getData() + function getData() { $buffer = 4096; // Return data stored in memory - if (isset($this->data)) { - $tmp = $this->data; - unset($this->data); + if (isset($this->_data)) { + $tmp = $this->_data; + unset($this->_data); $fh = $this->_filehandle; if ($this->_using_tmpfile) { fseek($fh, 0); @@ -720,13 +709,13 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param integer $last_row Last row of the area to merge * @param integer $last_col Last column of the area to merge */ - public function setMerge($first_row, $first_col, $last_row, $last_col) + function setMerge($first_row, $first_col, $last_row, $last_col) { if (($last_row < $first_row) || ($last_col < $first_col)) { return; } - $max_record_ranges = floor(($this->limit - 6) / 8); + $max_record_ranges = floor(($this->_limit - 6) / 8); if($this->_merged_cells_counter >= $max_record_ranges) { $this->_merged_cells_record++; @@ -745,7 +734,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access public */ - public function select() + function select() { $this->selected = 1; } @@ -757,7 +746,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access public */ - public function activate() + function activate() { $this->selected = 1; $this->activesheet = $this->index; @@ -770,7 +759,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access public */ - public function setFirstSheet() + function setFirstSheet() { $this->firstsheet = $this->index; } @@ -783,7 +772,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @access public * @param string $password The password to use for protecting the sheet. */ - public function protect($password) + function protect($password) { $this->_protect = 1; $this->_password = $this->_encodePassword($password); @@ -800,7 +789,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param integer $hidden The optional hidden atribute * @param integer $level The optional outline level */ - public function setColumn($firstcol, $lastcol, $width, $format = null, $hidden = 0, $level = 0) + function setColumn($firstcol, $lastcol, $width, $format = null, $hidden = 0, $level = 0) { // added by Dan Lynn _colinfo as $key => $colinfo) @@ -845,7 +834,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param integer $last_row last row in the selected quadrant * @param integer $last_column last column in the selected quadrant */ - public function setSelection($first_row,$first_column,$last_row,$last_column) + function setSelection($first_row,$first_column,$last_row,$last_column) { $this->_selection = array($first_row,$first_column,$last_row,$last_column); } @@ -861,7 +850,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * 3 => Leftmost column visible * 4 => Active pane */ - public function freezePanes($panes) + function freezePanes($panes) { $this->_frozen = 1; $this->_panes = $panes; @@ -878,7 +867,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * 3 => Leftmost column visible * 4 => Active pane */ - public function thawPanes($panes) + function thawPanes($panes) { $this->_frozen = 0; $this->_panes = $panes; @@ -889,7 +878,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access public */ - public function setPortrait() + function setPortrait() { $this->_orientation = 1; } @@ -899,7 +888,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access public */ - public function setLandscape() + function setLandscape() { $this->_orientation = 0; } @@ -910,7 +899,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @access public * @param integer $size The type of paper size to use */ - public function setPaper($size = 0) + function setPaper($size = 0) { $this->_paper_size = $size; } @@ -923,7 +912,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param string $string The header text * @param float $margin optional head margin in inches. */ - public function setHeader($string,$margin = 0.50) + function setHeader($string,$margin = 0.50) { if (strlen($string) >= 255) { //carp 'Header string must be less than 255 characters'; @@ -940,7 +929,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param string $string The footer text * @param float $margin optional foot margin in inches. */ - public function setFooter($string,$margin = 0.50) + function setFooter($string,$margin = 0.50) { if (strlen($string) >= 255) { //carp 'Footer string must be less than 255 characters'; @@ -956,7 +945,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @access public * @param integer $center the optional value for centering. Defaults to 1 (center). */ - public function centerHorizontally($center = 1) + function centerHorizontally($center = 1) { $this->_hcenter = $center; } @@ -967,7 +956,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @access public * @param integer $center the optional value for centering. Defaults to 1 (center). */ - public function centerVertically($center = 1) + function centerVertically($center = 1) { $this->_vcenter = $center; } @@ -978,7 +967,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @access public * @param float $margin The margin to set in inches */ - public function setMargins($margin) + function setMargins($margin) { $this->setMarginLeft($margin); $this->setMarginRight($margin); @@ -992,7 +981,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @access public * @param float $margin The margin to set in inches */ - public function setMargins_LR($margin) + function setMargins_LR($margin) { $this->setMarginLeft($margin); $this->setMarginRight($margin); @@ -1004,7 +993,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @access public * @param float $margin The margin to set in inches */ - public function setMargins_TB($margin) + function setMargins_TB($margin) { $this->setMarginTop($margin); $this->setMarginBottom($margin); @@ -1016,7 +1005,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @access public * @param float $margin The margin to set in inches */ - public function setMarginLeft($margin = 0.75) + function setMarginLeft($margin = 0.75) { $this->_margin_left = $margin; } @@ -1027,7 +1016,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @access public * @param float $margin The margin to set in inches */ - public function setMarginRight($margin = 0.75) + function setMarginRight($margin = 0.75) { $this->_margin_right = $margin; } @@ -1038,7 +1027,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @access public * @param float $margin The margin to set in inches */ - public function setMarginTop($margin = 1.00) + function setMarginTop($margin = 1.00) { $this->_margin_top = $margin; } @@ -1049,7 +1038,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @access public * @param float $margin The margin to set in inches */ - public function setMarginBottom($margin = 1.00) + function setMarginBottom($margin = 1.00) { $this->_margin_bottom = $margin; } @@ -1061,7 +1050,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param integer $first_row First row to repeat * @param integer $last_row Last row to repeat. Optional. */ - public function repeatRows($first_row, $last_row = null) + function repeatRows($first_row, $last_row = null) { $this->title_rowmin = $first_row; if (isset($last_row)) { //Second row is optional @@ -1078,7 +1067,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param integer $first_col First column to repeat * @param integer $last_col Last column to repeat. Optional. */ - public function repeatColumns($first_col, $last_col = null) + function repeatColumns($first_col, $last_col = null) { $this->title_colmin = $first_col; if (isset($last_col)) { // Second col is optional @@ -1097,7 +1086,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param integer $last_row Last row of the area to print * @param integer $last_col Last column of the area to print */ - public function printArea($first_row, $first_col, $last_row, $last_col) + function printArea($first_row, $first_col, $last_row, $last_col) { $this->print_rowmin = $first_row; $this->print_colmin = $first_col; @@ -1111,7 +1100,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access public */ - public function hideGridlines() + function hideGridlines() { $this->_print_gridlines = 0; } @@ -1121,7 +1110,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access public */ - public function hideScreenGridlines() + function hideScreenGridlines() { $this->_screen_gridlines = 0; } @@ -1132,7 +1121,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @access public * @param integer $print Whether to print the headers or not. Defaults to 1 (print). */ - public function printRowColHeaders($print = 1) + function printRowColHeaders($print = 1) { $this->_print_headers = $print; } @@ -1146,7 +1135,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param integer $height Maximun heigth of printed area in pages * @see setPrintScale() */ - public function fitToPages($width, $height) + function fitToPages($width, $height) { $this->_fit_page = 1; $this->_fit_width = $width; @@ -1160,7 +1149,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @access public * @param array $breaks Array containing the horizontal page breaks */ - public function setHPagebreaks($breaks) + function setHPagebreaks($breaks) { foreach ($breaks as $break) { array_push($this->_hbreaks, $break); @@ -1174,7 +1163,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @access public * @param array $breaks Array containing the vertical page breaks */ - public function setVPagebreaks($breaks) + function setVPagebreaks($breaks) { foreach ($breaks as $break) { array_push($this->_vbreaks, $break); @@ -1188,11 +1177,11 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @access public * @param integer $scale The zoom factor */ - public function setZoom($scale = 100) + function setZoom($scale = 100) { // Confine the scale to Excel's range if ($scale < 10 || $scale > 400) { - $this->raiseError('Zoom factor ' . $scale . ' outside range: 10 <= zoom <= 400'); + $this->raiseError("Zoom factor $scale outside range: 10 <= zoom <= 400"); $scale = 100; } @@ -1206,7 +1195,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @access public * @param integer $scale The optional scale factor. Defaults to 100 */ - public function setPrintScale($scale = 100) + function setPrintScale($scale = 100) { // Confine the scale to Excel's range if ($scale < 10 || $scale > 400) { @@ -1229,7 +1218,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param mixed $token What we are writing * @param mixed $format The optional format to apply to the cell */ - public function write($row, $col, $token, $format = null) + function write($row, $col, $token, $format = null) { // Check for a cell reference in A1 notation and substitute row and column /*if ($_[0] =~ /^\D/) { @@ -1271,7 +1260,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @return mixed PEAR_Error on failure */ - public function writeRow($row, $col, $val, $format = null) + function writeRow($row, $col, $val, $format = null) { $retval = ''; if (is_array($val)) { @@ -1300,7 +1289,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @return mixed PEAR_Error on failure */ - public function writeCol($row, $col, $val, $format = null) + function writeCol($row, $col, $val, $format = null) { $retval = ''; if (is_array($val)) { @@ -1318,10 +1307,10 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * Returns an index to the XF record in the workbook * * @access private - * @param mixed $format The optional XF format + * @param mixed &$format The optional XF format * @return integer The XF record index */ - protected function _XF($format) + function _XF(&$format) { if ($format) { return($format->getXfIndex()); @@ -1345,17 +1334,17 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @access private * @param string $data The binary data to append */ - protected function _append($data) + function _append($data) { if ($this->_using_tmpfile) { // Add CONTINUE records if necessary - if (strlen($data) > $this->limit) { - $data = $this->addContinue($data); + if (strlen($data) > $this->_limit) { + $data = $this->_addContinue($data); } fwrite($this->_filehandle, $data); - $this->dataSize += strlen($data); + $this->_datasize += strlen($data); } else { - parent::append($data); + parent::_append($data); } } @@ -1369,7 +1358,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param string $cell The cell reference. Or range of cells. * @return array */ - protected function _substituteCellref($cell) + function _substituteCellref($cell) { $cell = strtoupper($cell); @@ -1405,7 +1394,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param string $cell The cell reference. * @return array containing (row, column) */ - protected function _cellToRowcol($cell) + function _cellToRowcol($cell) { preg_match("/\$?([A-I]?[A-Z])\$?(\d+)/",$cell,$match); $col = $match[1]; @@ -1436,7 +1425,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param string $plaintext The password to be encoded in plaintext. * @return string The encoded password */ - protected function _encodePassword($plaintext) + function _encodePassword($plaintext) { $password = 0x0000; $i = 1; // char position @@ -1466,7 +1455,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param bool $symbols_right * @param bool $auto_style */ - public function setOutline($visible = true, $symbols_below = true, $symbols_right = true, $auto_style = false) + function setOutline($visible = true, $symbols_below = true, $symbols_right = true, $auto_style = false) { $this->_outline_on = $visible; $this->_outline_below = $symbols_below; @@ -1484,7 +1473,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @param bool $rtl */ - public function setRTL($rtl = true) + function setRTL($rtl = true) { $this->_Arabic = ($rtl ? 1 : 0); } @@ -1511,7 +1500,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param mixed $format The optional XF format * @return integer */ - public function writeNumber($row, $col, $num, $format = null) + function writeNumber($row, $col, $num, $format = null) { $record = 0x0203; // Record identifier $length = 0x000E; // Number of bytes to follow @@ -1541,7 +1530,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr $header = pack("vv", $record, $length); $data = pack("vvv", $row, $col, $xf); $xl_double = pack("d", $num); - if ($this->byteOrder) { // if it's Big Endian + if ($this->_byte_order) { // if it's Big Endian $xl_double = strrev($xl_double); } @@ -1564,9 +1553,9 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param mixed $format The XF format for the cell * @return integer */ - public function writeString($row, $col, $str, $format = null) + function writeString($row, $col, $str, $format = null) { - if ($this->BIFF_version == 0x0600) { + if ($this->_BIFF_version == 0x0600) { return $this->writeStringBIFF8($row, $col, $str, $format); } $strlen = strlen($str); @@ -1615,7 +1604,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @access public * @param string $encoding The encoding. Ex: 'UTF-16LE', 'utf-8', 'ISO-859-7' */ - public function setInputEncoding($encoding) + function setInputEncoding($encoding) { if ($encoding != 'UTF-16LE' && !function_exists('iconv')) { $this->raiseError("Using an input encoding other than UTF-16LE requires PHP support for iconv"); @@ -1638,7 +1627,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param mixed $format The XF format for the cell * @return integer */ - public function writeStringBIFF8($row, $col, $str, $format = null) + function writeStringBIFF8($row, $col, $str, $format = null) { // If the string is Unicode and contains any "surrogate pairs" then using mb_strlen($str, 'UTF-16LE') // as the string length will cause a "found unreadable content" error when opening the worksheet in Excel @@ -1696,7 +1685,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @return boolean true for success, false if row and/or col are grester * then maximums allowed. */ - protected function _checkRowCol($row, $col) + function _checkRowCol($row, $col) { if ($row >= $this->_xls_rowmax) { return false; @@ -1728,7 +1717,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param integer $col Zero indexed column * @param string $note The note to write */ - public function writeNote($row, $col, $note) + function writeNote($row, $col, $note) { $note_length = strlen($note); $record = 0x001C; // Record identifier @@ -1788,7 +1777,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param integer $col Zero indexed column * @param mixed $format The XF format */ - public function writeBlank($row, $col, $format) + function writeBlank($row, $col, $format) { // Don't write a blank cell unless it has a format if (!$format) { @@ -1841,7 +1830,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param mixed $format The optional XF format * @return integer */ - public function writeFormula($row, $col, $formula, $format = null) + function writeFormula($row, $col, $formula, $format = null) { $record = 0x0006; // Record identifier @@ -1919,7 +1908,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param mixed $format The cell format * @return integer */ - public function writeUrl($row, $col, $url, $string = '', $format = null) + function writeUrl($row, $col, $url, $string = '', $format = null) { // Add start row and col to arg list return($this->_writeUrlRange($row, $col, $row, $col, $url, $string, $format)); @@ -1943,7 +1932,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @return integer */ - protected function _writeUrlRange($row1, $col1, $row2, $col2, $url, $string = '', $format = null) + function _writeUrlRange($row1, $col1, $row2, $col2, $url, $string = '', $format = null) { // Check for internal/external sheet links or default to web link @@ -1973,7 +1962,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param mixed $format The cell format * @return integer */ - protected function _writeUrlWeb($row1, $col1, $row2, $col2, $url, $str, $format = null) + function _writeUrlWeb($row1, $col1, $row2, $col2, $url, $str, $format = null) { $record = 0x01B8; // Record identifier $length = 0x00000; // Bytes to follow @@ -2033,7 +2022,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param mixed $format The cell format * @return integer */ - protected function _writeUrlInternal($row1, $col1, $row2, $col2, $url, $str, $format = null) + function _writeUrlInternal($row1, $col1, $row2, $col2, $url, $str, $format = null) { $record = 0x01B8; // Record identifier $length = 0x00000; // Bytes to follow @@ -2099,7 +2088,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param mixed $format The cell format * @return integer */ - protected function _writeUrlExternal($row1, $col1, $row2, $col2, $url, $str, $format = null) + function _writeUrlExternal($row1, $col1, $row2, $col2, $url, $str, $format = null) { // Network drives are different. We will handle them separately // MS/Novell network drives and shares start with \\ @@ -2229,7 +2218,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param bool $hidden The optional hidden attribute * @param integer $level The optional outline level for row, in range [0,7] */ - public function setRow($row, $height, $format = null, $hidden = false, $level = 0) + function setRow($row, $height, $format = null, $hidden = false, $level = 0) { $record = 0x0208; // Record identifier $length = 0x0010; // Number of bytes to follow @@ -2282,7 +2271,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access private */ - protected function _storeDimensions() + function _storeDimensions() { $record = 0x0200; // Record identifier $row_min = $this->_dim_rowmin; // First row @@ -2291,17 +2280,17 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr $col_max = $this->_dim_colmax + 1; // Last column plus 1 $reserved = 0x0000; // Reserved by Excel - if ($this->BIFF_version == 0x0500) { + if ($this->_BIFF_version == 0x0500) { $length = 0x000A; // Number of bytes to follow $data = pack("vvvvv", $row_min, $row_max, $col_min, $col_max, $reserved); - } elseif ($this->BIFF_version == 0x0600) { + } elseif ($this->_BIFF_version == 0x0600) { $length = 0x000E; $data = pack("VVvvv", $row_min, $row_max, $col_min, $col_max, $reserved); } $header = pack("vv", $record, $length); - $this->prepend($header.$data); + $this->_prepend($header.$data); } /** @@ -2309,12 +2298,12 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access private */ - protected function _storeWindow2() + function _storeWindow2() { $record = 0x023E; // Record identifier - if ($this->BIFF_version == 0x0500) { + if ($this->_BIFF_version == 0x0500) { $length = 0x000A; // Number of bytes to follow - } elseif ($this->BIFF_version == 0x0600) { + } elseif ($this->_BIFF_version == 0x0600) { $length = 0x0012; } @@ -2351,10 +2340,10 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr $header = pack("vv", $record, $length); $data = pack("vvv", $grbit, $rwTop, $colLeft); // FIXME !!! - if ($this->BIFF_version == 0x0500) { + if ($this->_BIFF_version == 0x0500) { $rgbHdr = 0x00000000; // Row/column heading and gridline color $data .= pack("V", $rgbHdr); - } elseif ($this->BIFF_version == 0x0600) { + } elseif ($this->_BIFF_version == 0x0600) { $rgbHdr = 0x0040; // Row/column heading and gridline color index $zoom_factor_page_break = 0x0000; $zoom_factor_normal = 0x0000; @@ -2368,7 +2357,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access private */ - protected function _storeDefcol() + function _storeDefcol() { $record = 0x0055; // Record identifier $length = 0x0002; // Number of bytes to follow @@ -2376,7 +2365,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr $header = pack("vv", $record, $length); $data = pack("v", $colwidth); - $this->prepend($header . $data); + $this->_prepend($header . $data); } /** @@ -2394,7 +2383,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * 4 => Option flags. * 5 => Optional outline level */ - protected function _storeColinfo($col_array) + function _storeColinfo($col_array) { if (isset($col_array[0])) { $colFirst = $col_array[0]; @@ -2437,7 +2426,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr $header = pack("vv", $record, $length); $data = pack("vvvvvC", $colFirst, $colLast, $coldx, $ixfe, $grbit, $reserved); - $this->prepend($header.$data); + $this->_prepend($header.$data); } /** @@ -2447,7 +2436,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param array $array array containing ($rwFirst,$colFirst,$rwLast,$colLast) * @see setSelection() */ - protected function _storeSelection($array) + function _storeSelection($array) { list($rwFirst,$colFirst,$rwLast,$colLast) = $array; $record = 0x001D; // Record identifier @@ -2488,7 +2477,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access private */ - protected function _storeMergedCells() + function _storeMergedCells() { // if there are no merged cell ranges set, return if (count($this->_merged_ranges) == 0) { @@ -2520,14 +2509,14 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @access private * @param integer $count The number of external sheet references in this worksheet */ - protected function _storeExterncount($count) + function _storeExterncount($count) { $record = 0x0016; // Record identifier $length = 0x0002; // Number of bytes to follow $header = pack("vv", $record, $length); $data = pack("v", $count); - $this->prepend($header . $data); + $this->_prepend($header . $data); } /** @@ -2539,7 +2528,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @access private * @param string $sheetname The name of a external worksheet */ - protected function _storeExternsheet($sheetname) + function _storeExternsheet($sheetname) { $record = 0x0017; // Record identifier @@ -2559,7 +2548,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr $header = pack("vv", $record, $length); $data = pack("CC", $cch, $rgch); - $this->prepend($header . $data . $sheetname); + $this->_prepend($header . $data . $sheetname); } /** @@ -2576,7 +2565,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * 3 => Leftmost column visible * 4 => Active pane */ - protected function _storePanes($panes) + function _storePanes($panes) { $y = $panes[0]; $x = $panes[1]; @@ -2648,7 +2637,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access private */ - protected function _storeSetup() + function _storeSetup() { $record = 0x00A1; // Record identifier $length = 0x0022; // Number of bytes to follow @@ -2685,7 +2674,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr $numHdr = pack("d", $numHdr); $numFtr = pack("d", $numFtr); - if ($this->byteOrder) { // if it's Big Endian + if ($this->_byte_order) { // if it's Big Endian $numHdr = strrev($numHdr); $numFtr = strrev($numFtr); } @@ -2701,7 +2690,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr $iVRes); $data2 = $numHdr.$numFtr; $data3 = pack("v", $iCopies); - $this->prepend($header . $data1 . $data2 . $data3); + $this->_prepend($header . $data1 . $data2 . $data3); } /** @@ -2709,13 +2698,13 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access private */ - protected function _storeHeader() + function _storeHeader() { $record = 0x0014; // Record identifier $str = $this->_header; // header string $cch = strlen($str); // Length of header string - if ($this->BIFF_version == 0x0600) { + if ($this->_BIFF_version == 0x0600) { $encoding = 0x0; // TODO: Unicode support $length = 3 + $cch; // Bytes to follow } else { @@ -2723,13 +2712,13 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr } $header = pack("vv", $record, $length); - if ($this->BIFF_version == 0x0600) { + if ($this->_BIFF_version == 0x0600) { $data = pack("vC", $cch, $encoding); } else { $data = pack("C", $cch); } - $this->prepend($header.$data.$str); + $this->_prepend($header.$data.$str); } /** @@ -2737,13 +2726,13 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access private */ - protected function _storeFooter() + function _storeFooter() { $record = 0x0015; // Record identifier $str = $this->_footer; // Footer string $cch = strlen($str); // Length of footer string - if ($this->BIFF_version == 0x0600) { + if ($this->_BIFF_version == 0x0600) { $encoding = 0x0; // TODO: Unicode support $length = 3 + $cch; // Bytes to follow } else { @@ -2751,13 +2740,13 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr } $header = pack("vv", $record, $length); - if ($this->BIFF_version == 0x0600) { + if ($this->_BIFF_version == 0x0600) { $data = pack("vC", $cch, $encoding); } else { $data = pack("C", $cch); } - $this->prepend($header . $data . $str); + $this->_prepend($header . $data . $str); } /** @@ -2765,7 +2754,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access private */ - protected function _storeHcenter() + function _storeHcenter() { $record = 0x0083; // Record identifier $length = 0x0002; // Bytes to follow @@ -2775,7 +2764,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr $header = pack("vv", $record, $length); $data = pack("v", $fHCenter); - $this->prepend($header.$data); + $this->_prepend($header.$data); } /** @@ -2783,7 +2772,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access private */ - protected function _storeVcenter() + function _storeVcenter() { $record = 0x0084; // Record identifier $length = 0x0002; // Bytes to follow @@ -2792,7 +2781,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr $header = pack("vv", $record, $length); $data = pack("v", $fVCenter); - $this->prepend($header . $data); + $this->_prepend($header . $data); } /** @@ -2800,7 +2789,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access private */ - protected function _storeMarginLeft() + function _storeMarginLeft() { $record = 0x0026; // Record identifier $length = 0x0008; // Bytes to follow @@ -2809,11 +2798,11 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr $header = pack("vv", $record, $length); $data = pack("d", $margin); - if ($this->byteOrder) { // if it's Big Endian + if ($this->_byte_order) { // if it's Big Endian $data = strrev($data); } - $this->prepend($header . $data); + $this->_prepend($header . $data); } /** @@ -2821,7 +2810,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access private */ - protected function _storeMarginRight() + function _storeMarginRight() { $record = 0x0027; // Record identifier $length = 0x0008; // Bytes to follow @@ -2830,11 +2819,11 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr $header = pack("vv", $record, $length); $data = pack("d", $margin); - if ($this->byteOrder) { // if it's Big Endian + if ($this->_byte_order) { // if it's Big Endian $data = strrev($data); } - $this->prepend($header . $data); + $this->_prepend($header . $data); } /** @@ -2842,7 +2831,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access private */ - protected function _storeMarginTop() + function _storeMarginTop() { $record = 0x0028; // Record identifier $length = 0x0008; // Bytes to follow @@ -2851,11 +2840,11 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr $header = pack("vv", $record, $length); $data = pack("d", $margin); - if ($this->byteOrder) { // if it's Big Endian + if ($this->_byte_order) { // if it's Big Endian $data = strrev($data); } - $this->prepend($header . $data); + $this->_prepend($header . $data); } /** @@ -2863,7 +2852,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access private */ - protected function _storeMarginBottom() + function _storeMarginBottom() { $record = 0x0029; // Record identifier $length = 0x0008; // Bytes to follow @@ -2872,11 +2861,11 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr $header = pack("vv", $record, $length); $data = pack("d", $margin); - if ($this->byteOrder) { // if it's Big Endian + if ($this->_byte_order) { // if it's Big Endian $data = strrev($data); } - $this->prepend($header . $data); + $this->_prepend($header . $data); } /** @@ -2890,7 +2879,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param integer $last_row Last row of the area to merge * @param integer $last_col Last column of the area to merge */ - public function mergeCells($first_row, $first_col, $last_row, $last_col) + function mergeCells($first_row, $first_col, $last_row, $last_col) { $record = 0x00E5; // Record identifier $length = 0x000A; // Bytes to follow @@ -2917,7 +2906,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access private */ - protected function _storePrintHeaders() + function _storePrintHeaders() { $record = 0x002a; // Record identifier $length = 0x0002; // Bytes to follow @@ -2926,7 +2915,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr $header = pack("vv", $record, $length); $data = pack("v", $fPrintRwCol); - $this->prepend($header . $data); + $this->_prepend($header . $data); } /** @@ -2935,7 +2924,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access private */ - protected function _storePrintGridlines() + function _storePrintGridlines() { $record = 0x002b; // Record identifier $length = 0x0002; // Bytes to follow @@ -2944,7 +2933,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr $header = pack("vv", $record, $length); $data = pack("v", $fPrintGrid); - $this->prepend($header . $data); + $this->_prepend($header . $data); } /** @@ -2953,7 +2942,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access private */ - protected function _storeGridset() + function _storeGridset() { $record = 0x0082; // Record identifier $length = 0x0002; // Bytes to follow @@ -2962,7 +2951,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr $header = pack("vv", $record, $length); $data = pack("v", $fGridSet); - $this->prepend($header . $data); + $this->_prepend($header . $data); } /** @@ -2973,7 +2962,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @see _storeWsbool() * @access private */ - protected function _storeGuts() + function _storeGuts() { $record = 0x0080; // Record identifier $length = 0x0008; // Bytes to follow @@ -3008,7 +2997,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr $header = pack("vv", $record, $length); $data = pack("vvvv", $dxRwGut, $dxColGut, $row_level, $col_level); - $this->prepend($header.$data); + $this->_prepend($header.$data); } @@ -3018,7 +3007,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access private */ - protected function _storeWsbool() + function _storeWsbool() { $record = 0x0081; // Record identifier $length = 0x0002; // Bytes to follow @@ -3052,7 +3041,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr $header = pack("vv", $record, $length); $data = pack("v", $grbit); - $this->prepend($header . $data); + $this->_prepend($header . $data); } /** @@ -3060,7 +3049,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access private */ - protected function _storeHbreak() + function _storeHbreak() { // Return if the user hasn't specified pagebreaks if (empty($this->_hbreaks)) { @@ -3076,7 +3065,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr $record = 0x001b; // Record identifier $cbrk = count($breaks); // Number of page breaks - if ($this->BIFF_version == 0x0600) { + if ($this->_BIFF_version == 0x0600) { $length = 2 + 6*$cbrk; // Bytes to follow } else { $length = 2 + 2*$cbrk; // Bytes to follow @@ -3087,14 +3076,14 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr // Append each page break foreach ($breaks as $break) { - if ($this->BIFF_version == 0x0600) { + if ($this->_BIFF_version == 0x0600) { $data .= pack("vvv", $break, 0x0000, 0x00ff); } else { $data .= pack("v", $break); } } - $this->prepend($header.$data); + $this->_prepend($header.$data); } @@ -3103,7 +3092,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access private */ - protected function _storeVbreak() + function _storeVbreak() { // Return if the user hasn't specified pagebreaks if (empty($this->_vbreaks)) { @@ -3122,7 +3111,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr $record = 0x001a; // Record identifier $cbrk = count($breaks); // Number of page breaks - if ($this->BIFF_version == 0x0600) { + if ($this->_BIFF_version == 0x0600) { $length = 2 + 6*$cbrk; // Bytes to follow } else { $length = 2 + 2*$cbrk; // Bytes to follow @@ -3133,14 +3122,14 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr // Append each page break foreach ($breaks as $break) { - if ($this->BIFF_version == 0x0600) { + if ($this->_BIFF_version == 0x0600) { $data .= pack("vvv", $break, 0x0000, 0xffff); } else { $data .= pack("v", $break); } } - $this->prepend($header . $data); + $this->_prepend($header . $data); } /** @@ -3148,7 +3137,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access private */ - protected function _storeProtect() + function _storeProtect() { // Exit unless sheet protection has been specified if ($this->_protect == 0) { @@ -3163,7 +3152,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr $header = pack("vv", $record, $length); $data = pack("v", $fLock); - $this->prepend($header.$data); + $this->_prepend($header.$data); } /** @@ -3171,7 +3160,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access private */ - protected function _storePassword() + function _storePassword() { // Exit unless sheet protection and password have been specified if (($this->_protect == 0) || (!isset($this->_password))) { @@ -3186,7 +3175,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr $header = pack("vv", $record, $length); $data = pack("v", $wPassword); - $this->prepend($header . $data); + $this->_prepend($header . $data); } @@ -3202,7 +3191,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param integer $scale_x The horizontal scale * @param integer $scale_y The vertical scale */ - public function insertBitmap($row, $col, $bitmap, $x = 0, $y = 0, $scale_x = 1, $scale_y = 1) + function insertBitmap($row, $col, $bitmap, $x = 0, $y = 0, $scale_x = 1, $scale_y = 1) { $bitmap_array = $this->_processBitmap($bitmap); if ($this->isError($bitmap_array)) { @@ -3280,7 +3269,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param integer $width Width of image frame * @param integer $height Height of image frame */ - protected function _positionImage($col_start, $row_start, $x1, $y1, $width, $height) + function _positionImage($col_start, $row_start, $x1, $y1, $width, $height) { // Initialise end cell to the same as the start cell $col_end = $col_start; // Col containing lower right corner of object @@ -3346,7 +3335,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param integer $col The column * @return integer The width in pixels */ - protected function _sizeCol($col) + function _sizeCol($col) { // Look up the cell value to see if it has been changed if (isset($this->col_sizes[$col])) { @@ -3370,7 +3359,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param integer $row The row * @return integer The width in pixels */ - protected function _sizeRow($row) + function _sizeRow($row) { // Look up the cell value to see if it has been changed if (isset($this->_row_sizes[$row])) { @@ -3398,7 +3387,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param integer $rwB Row containing bottom right corner of object * @param integer $dyB Distance from bottom of cell */ - protected function _storeObjPicture($colL,$dxL,$rwT,$dyT,$colR,$dxR,$rwB,$dyB) + function _storeObjPicture($colL,$dxL,$rwT,$dyT,$colR,$dxR,$rwB,$dyB) { $record = 0x005d; // Record identifier $length = 0x003c; // Bytes to follow @@ -3473,7 +3462,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param string $bitmap The bitmap to process * @return array Array with data and properties of the bitmap */ - protected function _processBitmap($bitmap) + function _processBitmap($bitmap) { // Open file. $bmp_fd = @fopen($bitmap,"rb"); @@ -3557,7 +3546,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access private */ - protected function _storeZoom() + function _storeZoom() { // If scale is 100 we don't need to write a record if ($this->_zoom == 100) { @@ -3575,7 +3564,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr /** * FIXME: add comments */ - public function setValidation($row1, $col1, $row2, $col2, $validator) + function setValidation($row1, $col1, $row2, $col2, &$validator) { $this->_dv[] = $validator->_getData() . pack("vvvvv", 1, $row1, $row2, $col1, $col2); @@ -3586,7 +3575,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access private */ - protected function _storeDataValidity() + function _storeDataValidity() { $record = 0x01b2; // Record identifier $length = 0x0012; // Bytes to follow From 22c7e1705f0c922690dc464f0f27f9d4a167954e Mon Sep 17 00:00:00 2001 From: Alexey Kopytko Date: Thu, 16 Jun 2016 11:06:38 +0900 Subject: [PATCH 03/15] New timestamp field should respect existing style for variable names --- Spreadsheet/Excel/Writer/Workbook.php | 6 +++--- .../Excel/Writer/Test_Spreadsheet_Excel_WriterTestCase.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Spreadsheet/Excel/Writer/Workbook.php b/Spreadsheet/Excel/Writer/Workbook.php index a1c97f3..788d461 100644 --- a/Spreadsheet/Excel/Writer/Workbook.php +++ b/Spreadsheet/Excel/Writer/Workbook.php @@ -166,7 +166,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri var $_string_sizeinfo_size; /** @var int */ - public $timestamp; + var $_timestamp; /** * Class constructor @@ -203,7 +203,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri $this->_str_total = 0; $this->_str_unique = 0; $this->_str_table = array(); - $this->timestamp = time(); + $this->_timestamp = time(); $this->_setPaletteXl97(); } @@ -595,7 +595,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri } } - $root = new OLE_PPS_Root($this->timestamp, $this->timestamp, array($OLE)); + $root = new OLE_PPS_Root($this->_timestamp, $this->_timestamp, array($OLE)); if ($this->_tmp_dir != '') { $root->setTempDir($this->_tmp_dir); } diff --git a/test/Test/Spreadsheet/Excel/Writer/Test_Spreadsheet_Excel_WriterTestCase.php b/test/Test/Spreadsheet/Excel/Writer/Test_Spreadsheet_Excel_WriterTestCase.php index 00faa30..7d7d2a8 100644 --- a/test/Test/Spreadsheet/Excel/Writer/Test_Spreadsheet_Excel_WriterTestCase.php +++ b/test/Test/Spreadsheet/Excel/Writer/Test_Spreadsheet_Excel_WriterTestCase.php @@ -20,10 +20,10 @@ class Test_Spreadsheet_Excel_WriterTestCase extends PHPUnit_Framework_TestCase protected function assertSameAsInFixture($filename, Spreadsheet_Excel_Writer $workbook) { - $this->assertEmpty($workbook->fileName, "Testing with fixtures works only for standard output"); + $this->assertEmpty($workbook->_filename, "Testing with fixtures works only for standard output"); // we have to fix timestamp for fixtures to work - $workbook->timestamp = 1000000000; // somewhere in 2001 + $workbook->_timestamp = 1000000000; // somewhere in 2001 ob_start(); $workbook->close(); From 012389ee13278b083a0a4fe0e0b9c5b53a20a25d Mon Sep 17 00:00:00 2001 From: Alexey Kopytko Date: Thu, 16 Jun 2016 11:20:14 +0900 Subject: [PATCH 04/15] Replace var with public, prefix function definitions with public or protected --- Spreadsheet/Excel/Writer/BIFFwriter.php | 36 +-- Spreadsheet/Excel/Writer/Format.php | 150 ++++++------ Spreadsheet/Excel/Writer/Parser.php | 126 +++++----- Spreadsheet/Excel/Writer/Validator.php | 60 ++--- Spreadsheet/Excel/Writer/Workbook.php | 114 ++++----- Spreadsheet/Excel/Writer/Worksheet.php | 312 ++++++++++++------------ 6 files changed, 399 insertions(+), 399 deletions(-) diff --git a/Spreadsheet/Excel/Writer/BIFFwriter.php b/Spreadsheet/Excel/Writer/BIFFwriter.php index c949b45..57e1de9 100644 --- a/Spreadsheet/Excel/Writer/BIFFwriter.php +++ b/Spreadsheet/Excel/Writer/BIFFwriter.php @@ -57,51 +57,51 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR * The BIFF/Excel version (5). * @var integer */ - var $_BIFF_version = 0x0500; + public $_BIFF_version = 0x0500; /** * The byte order of this architecture. 0 => little endian, 1 => big endian * @var integer */ - var $_byte_order; + public $_byte_order; /** * The string containing the data of the BIFF stream * @var string */ - var $_data; + public $_data; /** * The size of the data in bytes. Should be the same as strlen($this->_data) * @var integer */ - var $_datasize; + public $_datasize; /** * The maximun length for a BIFF record. See _addContinue() * @var integer * @see _addContinue() */ - var $_limit; + public $_limit; /** * The temporary dir for storing the OLE file * @var string */ - var $_tmp_dir; + public $_tmp_dir; /** * The temporary file for storing the OLE file * @var string */ - var $_tmp_file; + public $_tmp_file; /** * Constructor * * @access public */ - function Spreadsheet_Excel_Writer_BIFFwriter() + public function Spreadsheet_Excel_Writer_BIFFwriter() { $this->_byte_order = ''; $this->_data = ''; @@ -118,7 +118,7 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR * * @access private */ - function _setByteOrder() + protected function _setByteOrder() { // Check if "pack" gives the required IEEE 64bit float $teststr = pack("d", 1.2345); @@ -136,12 +136,12 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR } /** - * General storage function + * General storage public function * * @param string $data binary data to prepend * @access private */ - function _prepend($data) + protected function _prepend($data) { if (strlen($data) > $this->_limit) { $data = $this->_addContinue($data); @@ -151,12 +151,12 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR } /** - * General storage function + * General storage public function * * @param string $data binary data to append * @access private */ - function _append($data) + protected function _append($data) { if (strlen($data) > $this->_limit) { $data = $this->_addContinue($data); @@ -173,7 +173,7 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR * 0x0010 Worksheet. * @access private */ - function _storeBof($type) + protected function _storeBof($type) { $record = 0x0809; // Record identifier @@ -202,7 +202,7 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR * * @access private */ - function _storeEof() + protected function _storeEof() { $record = 0x000A; // Record identifier $length = 0x0000; // Number of bytes to follow @@ -215,14 +215,14 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR * Excel 97 the limit is 8228 bytes. Records that are longer than these limits * must be split up into CONTINUE blocks. * - * This function takes a long BIFF record and inserts CONTINUE records as + * This public function takes a long BIFF record and inserts CONTINUE records as * necessary. * * @param string $data The original binary data to be written * @return string A very convenient string of continue blocks * @access private */ - function _addContinue($data) + protected function _addContinue($data) { $limit = $this->_limit; $record = 0x003C; // Record identifier @@ -255,7 +255,7 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR * @param string $dir The dir to be used as temp dir * @return true if given dir is valid, false otherwise */ - function setTempDir($dir) + public function setTempDir($dir) { if (is_dir($dir)) { $this->_tmp_dir = $dir; diff --git a/Spreadsheet/Excel/Writer/Format.php b/Spreadsheet/Excel/Writer/Format.php index 8922360..58dc8d1 100644 --- a/Spreadsheet/Excel/Writer/Format.php +++ b/Spreadsheet/Excel/Writer/Format.php @@ -48,199 +48,199 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * The index given by the workbook when creating a new format. * @var integer */ - var $_xf_index; + public $_xf_index; /** * Index to the FONT record. * @var integer */ - var $font_index; + public $font_index; /** * The font name (ASCII). * @var string */ - var $_font_name; + public $_font_name; /** * Height of font (1/20 of a point) * @var integer */ - var $_size; + public $_size; /** * Bold style * @var integer */ - var $_bold; + public $_bold; /** * Bit specifiying if the font is italic. * @var integer */ - var $_italic; + public $_italic; /** * Index to the cell's color * @var integer */ - var $_color; + public $_color; /** * The text underline property * @var integer */ - var $_underline; + public $_underline; /** * Bit specifiying if the font has strikeout. * @var integer */ - var $_font_strikeout; + public $_font_strikeout; /** * Bit specifiying if the font has outline. * @var integer */ - var $_font_outline; + public $_font_outline; /** * Bit specifiying if the font has shadow. * @var integer */ - var $_font_shadow; + public $_font_shadow; /** * 2 bytes specifiying the script type for the font. * @var integer */ - var $_font_script; + public $_font_script; /** * Byte specifiying the font family. * @var integer */ - var $_font_family; + public $_font_family; /** * Byte specifiying the font charset. * @var integer */ - var $_font_charset; + public $_font_charset; /** * An index (2 bytes) to a FORMAT record (number format). * @var integer */ - var $_num_format; + public $_num_format; /** * Bit specifying if formulas are hidden. * @var integer */ - var $_hidden; + public $_hidden; /** * Bit specifying if the cell is locked. * @var integer */ - var $_locked; + public $_locked; /** * The three bits specifying the text horizontal alignment. * @var integer */ - var $_text_h_align; + public $_text_h_align; /** * Bit specifying if the text is wrapped at the right border. * @var integer */ - var $_text_wrap; + public $_text_wrap; /** * The three bits specifying the text vertical alignment. * @var integer */ - var $_text_v_align; + public $_text_v_align; /** * 1 bit, apparently not used. * @var integer */ - var $_text_justlast; + public $_text_justlast; /** * The two bits specifying the text rotation. * @var integer */ - var $_rotation; + public $_rotation; /** * The cell's foreground color. * @var integer */ - var $_fg_color; + public $_fg_color; /** * The cell's background color. * @var integer */ - var $_bg_color; + public $_bg_color; /** * The cell's background fill pattern. * @var integer */ - var $_pattern; + public $_pattern; /** * Style of the bottom border of the cell * @var integer */ - var $_bottom; + public $_bottom; /** * Color of the bottom border of the cell. * @var integer */ - var $_bottom_color; + public $_bottom_color; /** * Style of the top border of the cell * @var integer */ - var $_top; + public $_top; /** * Color of the top border of the cell. * @var integer */ - var $_top_color; + public $_top_color; /** * Style of the left border of the cell * @var integer */ - var $_left; + public $_left; /** * Color of the left border of the cell. * @var integer */ - var $_left_color; + public $_left_color; /** * Style of the right border of the cell * @var integer */ - var $_right; + public $_right; /** * Color of the right border of the cell. * @var integer */ - var $_right_color; + public $_right_color; /** * Constructor @@ -249,7 +249,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @param integer $index the XF index for the format. * @param array $properties array with properties to be set on initialization. */ - function Spreadsheet_Excel_Writer_Format($BIFF_version, $index = 0, $properties = array()) + public function Spreadsheet_Excel_Writer_Format($BIFF_version, $index = 0, $properties = array()) { $this->_xf_index = $index; $this->_BIFF_version = $BIFF_version; @@ -312,7 +312,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @param string $style The type of the XF record ('style' or 'cell'). * @return string The XF record */ - function getXf($style) + public function getXf($style) { // Set the type of the XF record and some of the attributes. if ($style == 'style') { @@ -444,7 +444,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * * @return string The FONT record */ - function getFont() + public function getFont() { $dyHeight = $this->_size * 20; // Height of font (1/20 of a point) $icv = $this->_color; // Index to color palette @@ -500,7 +500,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * * @return string A key for this font */ - function getFontKey() + public function getFontKey() { $key = "$this->_font_name$this->_size"; $key .= "$this->_font_script$this->_underline"; @@ -516,7 +516,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * * @return integer The index for the XF record */ - function getXfIndex() + public function getXfIndex() { return($this->_xf_index); } @@ -530,7 +530,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @param string $name_color name of the color (i.e.: 'blue', 'red', etc..). Optional. * @return integer The color index */ - function _getColor($name_color = '') + protected function _getColor($name_color = '') { $colors = array( 'aqua' => 0x07, @@ -583,7 +583,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @access public * @param string $location alignment for the cell ('left', 'right', etc...). */ - function setAlign($location) + public function setAlign($location) { if (preg_match("/\d/",$location)) { return; // Ignore numbers @@ -641,14 +641,14 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @access public * @param string $location alignment for the cell ('left', 'right', etc...). */ - function setHAlign($location) + public function setHAlign($location) { if (preg_match("/\d/",$location)) { return; // Ignore numbers } - + $location = strtolower($location); - + if ($location == 'left') { $this->_text_h_align = 1; } @@ -681,14 +681,14 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @access public * @param string $location alignment for the cell ('top', 'vleft', 'vright', etc...). */ - function setVAlign($location) + public function setVAlign($location) { if (preg_match("/\d/",$location)) { return; // Ignore numbers } - + $location = strtolower($location); - + if ($location == 'top') { $this->_text_v_align = 0; } @@ -714,7 +714,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * * @access public */ - function setMerge() + public function setMerge() { $this->setAlign('merge'); } @@ -729,7 +729,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR 1 maps to 700 (bold text). Valid range is: 100-1000. It's Optional, default is 1 (bold). */ - function setBold($weight = 1) + public function setBold($weight = 1) { if ($weight == 1) { $weight = 0x2BC; // Bold text @@ -757,7 +757,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @access public * @param integer $style style of the cell border. 1 => thin, 2 => thick. */ - function setBottom($style) + public function setBottom($style) { $this->_bottom = $style; } @@ -768,7 +768,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @access public * @param integer $style style of the cell top border. 1 => thin, 2 => thick. */ - function setTop($style) + public function setTop($style) { $this->_top = $style; } @@ -779,7 +779,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @access public * @param integer $style style of the cell left border. 1 => thin, 2 => thick. */ - function setLeft($style) + public function setLeft($style) { $this->_left = $style; } @@ -790,7 +790,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @access public * @param integer $style style of the cell right border. 1 => thin, 2 => thick. */ - function setRight($style) + public function setRight($style) { $this->_right = $style; } @@ -802,7 +802,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @access public * @param integer $style style to apply for all cell borders. 1 => thin, 2 => thick. */ - function setBorder($style) + public function setBorder($style) { $this->setBottom($style); $this->setTop($style); @@ -822,7 +822,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @param mixed $color The color we are setting. Either a string (like 'blue'), * or an integer (range is [8...63]). */ - function setBorderColor($color) + public function setBorderColor($color) { $this->setBottomColor($color); $this->setTopColor($color); @@ -836,7 +836,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @access public * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]). */ - function setBottomColor($color) + public function setBottomColor($color) { $value = $this->_getColor($color); $this->_bottom_color = $value; @@ -848,7 +848,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @access public * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]). */ - function setTopColor($color) + public function setTopColor($color) { $value = $this->_getColor($color); $this->_top_color = $value; @@ -860,7 +860,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @access public * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]). */ - function setLeftColor($color) + public function setLeftColor($color) { $value = $this->_getColor($color); $this->_left_color = $value; @@ -872,7 +872,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @access public * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]). */ - function setRightColor($color) + public function setRightColor($color) { $value = $this->_getColor($color); $this->_right_color = $value; @@ -885,7 +885,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @access public * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]). */ - function setFgColor($color) + public function setFgColor($color) { $value = $this->_getColor($color); $this->_fg_color = $value; @@ -900,7 +900,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @access public * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]). */ - function setBgColor($color) + public function setBgColor($color) { $value = $this->_getColor($color); $this->_bg_color = $value; @@ -915,7 +915,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @access public * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]). */ - function setColor($color) + public function setColor($color) { $value = $this->_getColor($color); $this->_color = $value; @@ -928,7 +928,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @param integer $arg Optional. Defaults to 1. Meaningful values are: 0-18, * 0 meaning no background. */ - function setPattern($arg = 1) + public function setPattern($arg = 1) { $this->_pattern = $arg; } @@ -940,7 +940,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @param integer $underline The value for underline. Possible values are: * 1 => underline, 2 => double underline. */ - function setUnderline($underline) + public function setUnderline($underline) { $this->_underline = $underline; } @@ -950,7 +950,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * * @access public */ - function setItalic() + public function setItalic() { $this->_italic = 1; } @@ -961,7 +961,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @access public * @param integer $size The font size (in pixels I think). */ - function setSize($size) + public function setSize($size) { $this->_size = $size; } @@ -971,7 +971,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * * @access public */ - function setTextWrap() + public function setTextWrap() { $this->_text_wrap = 1; } @@ -983,7 +983,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @param integer $angle The rotation angle for the text (clockwise). Possible values are: 0, 90, 270 and -1 for stacking top-to-bottom. */ - function setTextRotation($angle) + public function setTextRotation($angle) { switch ($angle) { @@ -1027,7 +1027,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @access public * @param integer $num_format The numeric format. */ - function setNumFormat($num_format) + public function setNumFormat($num_format) { $this->_num_format = $num_format; } @@ -1037,7 +1037,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * * @access public */ - function setStrikeOut() + public function setStrikeOut() { $this->_font_strikeout = 1; } @@ -1047,7 +1047,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * * @access public */ - function setOutLine() + public function setOutLine() { $this->_font_outline = 1; } @@ -1057,7 +1057,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * * @access public */ - function setShadow() + public function setShadow() { $this->_font_shadow = 1; } @@ -1069,7 +1069,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @param integer $script The value for script type. Possible values are: * 1 => superscript, 2 => subscript. */ - function setScript($script) + public function setScript($script) { $this->_font_script = $script; } @@ -1079,7 +1079,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * * @access public */ - function setLocked() + public function setLocked() { $this->_locked = 1; } @@ -1089,7 +1089,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * * @access public */ - function setUnLocked() + public function setUnLocked() { $this->_locked = 0; } @@ -1101,7 +1101,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @param string $fontfamily The font family name. Possible values are: * 'Times New Roman', 'Arial', 'Courier'. */ - function setFontFamily($font_family) + public function setFontFamily($font_family) { $this->_font_name = $font_family; } diff --git a/Spreadsheet/Excel/Writer/Parser.php b/Spreadsheet/Excel/Writer/Parser.php index bd93824..ee43e12 100644 --- a/Spreadsheet/Excel/Writer/Parser.php +++ b/Spreadsheet/Excel/Writer/Parser.php @@ -113,55 +113,55 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * The index of the character we are currently looking at * @var integer */ - var $_current_char; + public $_current_char; /** * The token we are working on. * @var string */ - var $_current_token; + public $_current_token; /** * The formula to parse * @var string */ - var $_formula; + public $_formula; /** * The character ahead of the current char * @var string */ - var $_lookahead; + public $_lookahead; /** * The parse tree to be generated * @var string */ - var $_parse_tree; + public $_parse_tree; /** * The byte order. 1 => big endian, 0 => little endian. * @var integer */ - var $_byte_order; + public $_byte_order; /** * Array of external sheets * @var array */ - var $_ext_sheets; + public $_ext_sheets; /** * Array of sheet references in the form of REF structures * @var array */ - var $_references; + public $_references; /** * The BIFF version for the workbook * @var integer */ - var $_BIFF_version; + public $_BIFF_version; /** * The class constructor @@ -169,7 +169,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * @param integer $byte_order The byte order (Little endian or Big endian) of the architecture (optional). 1 => big endian, 0 (default) little endian. */ - function Spreadsheet_Excel_Writer_Parser($byte_order, $biff_version) + public function Spreadsheet_Excel_Writer_Parser($byte_order, $biff_version) { $this->_current_char = 0; $this->_BIFF_version = $biff_version; @@ -177,18 +177,18 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR $this->_formula = ''; // The formula to parse. $this->_lookahead = ''; // The character ahead of the current char. $this->_parse_tree = ''; // The parse tree to be generated. - $this->_initializeHashes(); // Initialize the hashes: ptg's and function's ptg's + $this->_initializeHashes(); // Initialize the hashes: ptg's and public function's ptg's $this->_byte_order = $byte_order; // Little Endian or Big Endian $this->_ext_sheets = array(); $this->_references = array(); } /** - * Initialize the ptg and function hashes. + * Initialize the ptg and public function hashes. * * @access private */ - function _initializeHashes() + protected function _initializeHashes() { // The Excel ptg indices $this->ptg = array( @@ -292,18 +292,18 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR // Thanks to Michael Meeks and Gnumeric for the initial arg values. // // The following hash was generated by "function_locale.pl" in the distro. - // Refer to function_locale.pl for non-English function names. + // Refer to function_locale.pl for non-English public function names. // // The array elements are as follow: - // ptg: The Excel function ptg code. - // args: The number of arguments that the function takes: + // ptg: The Excel public function ptg code. + // args: The number of arguments that the public function takes: // >=0 is a fixed number of arguments. // -1 is a variable number of arguments. - // class: The reference, value or array class of the function args. - // vol: The function is volatile. + // class: The reference, value or array class of the public function args. + // vol: The public function is volatile. // $this->_functions = array( - // function ptg args class vol + // public function ptg args class vol 'COUNT' => array( 0, -1, 0, 0 ), 'IF' => array( 1, -1, 1, 0 ), 'ISNA' => array( 2, 1, 1, 0 ), @@ -540,7 +540,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * @return mixed the converted token on success. PEAR_Error if the token * is not recognized */ - function _convert($token) + protected function _convert($token) { if (preg_match("/^\"[^\"]{0,255}\"$/", $token)) { return $this->_convertString($token); @@ -600,7 +600,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * @access private * @param mixed $num an integer or double for conversion to its ptg value */ - function _convertNumber($num) + protected function _convertNumber($num) { // Integer in the range 0..2**16-1 if ((preg_match("/^\d+$/", $num)) and ($num <= 65535)) { @@ -621,7 +621,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * @return mixed the converted token on success. PEAR_Error if the string * is longer than 255 characters. */ - function _convertString($string) + protected function _convertString($string) { // chop away beggining and ending quotes $string = substr($string, 1, strlen($string) - 2); @@ -638,15 +638,15 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR } /** - * Convert a function to a ptgFunc or ptgFuncVarV depending on the number of + * Convert a public function to a ptgFunc or ptgFuncVarV depending on the number of * args that it takes. * * @access private - * @param string $token The name of the function for convertion to ptg value. - * @param integer $num_args The number of arguments the function receives. - * @return string The packed ptg for the function + * @param string $token The name of the public function for convertion to ptg value. + * @param integer $num_args The number of arguments the public function receives. + * @return string The packed ptg for the public function */ - function _convertFunction($token, $num_args) + protected function _convertFunction($token, $num_args) { $args = $this->_functions[$token][1]; $volatile = $this->_functions[$token][3]; @@ -667,7 +667,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * @access private * @param string $range An Excel range in the A1:A2 or A1..A2 format. */ - function _convertRange2d($range, $class=0) + protected function _convertRange2d($range, $class=0) { // TODO: possible class value 0,1,2 check Formula.pm @@ -716,7 +716,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * @param string $token An Excel range in the Sheet1!A1:A2 format. * @return mixed The packed ptgArea3d token on success, PEAR_Error on failure. */ - function _convertRange3d($token) + protected function _convertRange3d($token) { $class = 2; // as far as I know, this is magick. @@ -780,7 +780,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * @param string $cell An Excel cell reference * @return string The cell in packed() format with the corresponding ptg */ - function _convertRef2d($cell) + protected function _convertRef2d($cell) { $class = 2; // as far as I know, this is magick. @@ -813,7 +813,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * @param string $cell An Excel cell reference * @return mixed The packed ptgRef3d token on success, PEAR_Error on failure. */ - function _convertRef3d($cell) + protected function _convertRef3d($cell) { $class = 2; // as far as I know, this is magick. @@ -858,7 +858,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * @param string $ext_ref The name of the external reference * @return string The reference index in packed() format */ - function _packExtRef($ext_ref) + protected function _packExtRef($ext_ref) { $ext_ref = preg_replace("/^'/", '', $ext_ref); // Remove leading ' if any. $ext_ref = preg_replace("/'$/", '', $ext_ref); // Remove trailing ' if any. @@ -904,7 +904,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * @return mixed The reference index in packed() format on success, * PEAR_Error on failure */ - function _getRefIndex($ext_ref) + protected function _getRefIndex($ext_ref) { $ext_ref = preg_replace("/^'/", '', $ext_ref); // Remove leading ' if any. $ext_ref = preg_replace("/'$/", '', $ext_ref); // Remove trailing ' if any. @@ -962,7 +962,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * @access private * @return integer The sheet index, -1 if the sheet was not found */ - function _getSheetIndex($sheet_name) + protected function _getSheetIndex($sheet_name) { if (!isset($this->_ext_sheets[$sheet_name])) { return -1; @@ -981,7 +981,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * @param string $name The name of the worksheet being added * @param integer $index The index of the worksheet being added */ - function setExtSheet($name, $index) + public function setExtSheet($name, $index) { $this->_ext_sheets[$name] = $index; } @@ -993,7 +993,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * @param string $cell The Excel cell reference to be packed * @return array Array containing the row and column in packed() format */ - function _cellToPackedRowcol($cell) + protected function _cellToPackedRowcol($cell) { $cell = strtoupper($cell); list($row, $col, $row_rel, $col_rel) = $this->_cellToRowcol($cell); @@ -1028,7 +1028,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * @param string $range The Excel range to be packed * @return array Array containing (row1,col1,row2,col2) in packed() format */ - function _rangeToPackedRange($range) + protected function _rangeToPackedRange($range) { preg_match('/(\$)?(\d+)\:(\$)?(\d+)/', $range, $match); // return absolute rows if there is a $ in the ref @@ -1075,7 +1075,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * @param string $cell The Excel cell reference in A1 format. * @return array */ - function _cellToRowcol($cell) + protected function _cellToRowcol($cell) { preg_match('/(\$)?([A-I]?[A-Z])(\$)?(\d+)/',$cell,$match); // return absolute column if there is a $ in the ref @@ -1105,7 +1105,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * * @access private */ - function _advance() + protected function _advance() { $i = $this->_current_char; $formula_length = strlen($this->_formula); @@ -1155,7 +1155,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * @param mixed $token The token to check. * @return mixed The checked token or false on failure */ - function _match($token) + protected function _match($token) { switch($token) { case SPREADSHEET_EXCEL_WRITER_ADD: @@ -1213,7 +1213,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR default: // if it's a reference if (preg_match('/^\$?[A-Ia-i]?[A-Za-z]\$?[0-9]+$/',$token) and - !preg_match("/[0-9]/",$this->_lookahead) and + !preg_match("/[0-9]/",$this->_lookahead) and ($this->_lookahead != ':') and ($this->_lookahead != '.') and ($this->_lookahead != '!')) { @@ -1234,13 +1234,13 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR return $token; } // if it's a range (A1:A2) - elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+:(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$token) and + elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+:(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$token) and !preg_match("/[0-9]/",$this->_lookahead)) { return $token; } // if it's a range (A1..A2) - elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+\.\.(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$token) and + elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+\.\.(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$token) and !preg_match("/[0-9]/",$this->_lookahead)) { return $token; @@ -1258,7 +1258,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR return $token; } // If it's a number (check that it's not a sheet name or range) - elseif (is_numeric($token) and + elseif (is_numeric($token) and (!is_numeric($token.$this->_lookahead) or ($this->_lookahead == '')) and ($this->_lookahead != '!') and ($this->_lookahead != ':')) { @@ -1269,7 +1269,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR { return $token; } - // if it's a function call + // if it's a public function call elseif (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/i",$token) and ($this->_lookahead == "(")) { return $token; @@ -1286,7 +1286,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * sign (=). * @return mixed true on success, PEAR_Error on failure */ - function parse($formula) + public function parse($formula) { $this->_current_char = 0; $this->_formula = $formula; @@ -1306,7 +1306,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * @access private * @return mixed The parsed ptg'd tree on success, PEAR_Error on failure */ - function _condition() + protected function _condition() { $result = $this->_expression(); if (PEAR::isError($result)) { @@ -1374,7 +1374,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * @access private * @return mixed The parsed ptg'd tree on success, PEAR_Error on failure */ - function _expression() + protected function _expression() { // If it's a string return a string node if (preg_match("/^\"[^\"]{0,255}\"$/", $this->_current_token)) { @@ -1415,14 +1415,14 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR } /** - * This function just introduces a ptgParen element in the tree, so that Excel + * This public function just introduces a ptgParen element in the tree, so that Excel * doesn't get confused when working with a parenthesized formula afterwards. * * @access private * @see _fact() * @return array The parsed ptg'd tree */ - function _parenthesizedExpression() + protected function _parenthesizedExpression() { $result = $this->_createTree('ptgParen', $this->_expression(), ''); return $result; @@ -1435,7 +1435,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * @access private * @return mixed The parsed ptg'd tree on success, PEAR_Error on failure */ - function _term() + protected function _term() { $result = $this->_fact(); if (PEAR::isError($result)) { @@ -1474,7 +1474,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * @access private * @return mixed The parsed ptg'd tree on success, PEAR_Error on failure */ - function _fact() + protected function _fact() { if ($this->_current_token == SPREADSHEET_EXCEL_WRITER_OPEN) { $this->_advance(); // eat the "(" @@ -1507,7 +1507,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR return $result; } // if it's a range - elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+:(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$this->_current_token) or + elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+:(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$this->_current_token) or preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+\.\.(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$this->_current_token)) { $result = $this->_current_token; @@ -1534,7 +1534,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR $this->_advance(); return $result; } - // if it's a function call + // if it's a public function call elseif (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/i",$this->_current_token)) { $result = $this->_func(); @@ -1546,13 +1546,13 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR } /** - * It parses a function call. It assumes the following rule: + * It parses a public function call. It assumes the following rule: * Func -> ( Expr [,Expr]* ) * * @access private * @return mixed The parsed ptg'd tree on success, PEAR_Error on failure */ - function _func() + protected function _func() { $num_args = 0; // number of arguments received $function = strtoupper($this->_current_token); @@ -1568,7 +1568,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR $this->_advance(); // eat the "," or ";" } else { return $this->raiseError("Syntax error: comma expected in ". - "function $function, arg #{$num_args}"); + "public function $function, arg #{$num_args}"); } $result2 = $this->_condition(); if (PEAR::isError($result2)) { @@ -1590,7 +1590,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR $args = $this->_functions[$function][1]; // If fixed number of args eg. TIME($i,$j,$k). Check that the number of args is valid. if (($args >= 0) and ($args != $num_args)) { - return $this->raiseError("Incorrect number of arguments in function $function() "); + return $this->raiseError("Incorrect number of arguments in public function $function() "); } $result = $this->_createTree($function, $result, $num_args); @@ -1608,7 +1608,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * @param mixed $right The right array (sub-tree) or a final node. * @return array A tree */ - function _createTree($value, $left, $right) + protected function _createTree($value, $left, $right) { return array('value' => $value, 'left' => $left, 'right' => $right); } @@ -1640,7 +1640,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * @param array $tree The optional tree to convert. * @return string The tree in reverse polish notation */ - function toReversePolish($tree = array()) + public function toReversePolish($tree = array()) { $polish = ""; // the string we are going to return if (empty($tree)) { // If it's the first call use _parse_tree @@ -1672,14 +1672,14 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR } $polish .= $converted_tree; } - // if it's a function convert it here (so we can set it's arguments) + // if it's a public function convert it here (so we can set it's arguments) if (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/",$tree['value']) and !preg_match('/^([A-Ia-i]?[A-Za-z])(\d+)$/',$tree['value']) and !preg_match("/^[A-Ia-i]?[A-Za-z](\d+)\.\.[A-Ia-i]?[A-Za-z](\d+)$/",$tree['value']) and !is_numeric($tree['value']) and !isset($this->ptg[$tree['value']])) { - // left subtree for a function is always an array. + // left subtree for a public function is always an array. if ($tree['left'] != '') { $left_tree = $this->toReversePolish($tree['left']); } else { @@ -1700,4 +1700,4 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR return $polish; } } -?> + diff --git a/Spreadsheet/Excel/Writer/Validator.php b/Spreadsheet/Excel/Writer/Validator.php index 0f091c6..e100326 100644 --- a/Spreadsheet/Excel/Writer/Validator.php +++ b/Spreadsheet/Excel/Writer/Validator.php @@ -47,27 +47,27 @@ define("OP_LTE", 0x07); */ class Spreadsheet_Excel_Writer_Validator { - var $_type; - var $_style; - var $_fixedList; - var $_blank; - var $_incell; - var $_showprompt; - var $_showerror; - var $_title_prompt; - var $_descr_prompt; - var $_title_error; - var $_descr_error; - var $_operator; - var $_formula1; - var $_formula2; + public $_type; + public $_style; + public $_fixedList; + public $_blank; + public $_incell; + public $_showprompt; + public $_showerror; + public $_title_prompt; + public $_descr_prompt; + public $_title_error; + public $_descr_error; + public $_operator; + public $_formula1; + public $_formula2; /** * The parser from the workbook. Used to parse validation formulas also * @var Spreadsheet_Excel_Writer_Parser */ - var $_parser; + public $_parser; - function Spreadsheet_Excel_Writer_Validator(&$parser) + public function Spreadsheet_Excel_Writer_Validator(&$parser) { $this->_parser = $parser; $this->_type = 0x01; // FIXME: add method for setting datatype @@ -86,41 +86,41 @@ class Spreadsheet_Excel_Writer_Validator $this->_formula2 = ''; } - function setPrompt($promptTitle = "\x00", $promptDescription = "\x00", $showPrompt = true) + public function setPrompt($promptTitle = "\x00", $promptDescription = "\x00", $showPrompt = true) { $this->_showprompt = $showPrompt; $this->_title_prompt = $promptTitle; $this->_descr_prompt = $promptDescription; } - function setError($errorTitle = "\x00", $errorDescription = "\x00", $showError = true) + public function setError($errorTitle = "\x00", $errorDescription = "\x00", $showError = true) { $this->_showerror = $showError; $this->_title_error = $errorTitle; $this->_descr_error = $errorDescription; } - function allowBlank() + public function allowBlank() { $this->_blank = true; } - function onInvalidStop() + public function onInvalidStop() { $this->_style = 0x00; } - function onInvalidWarn() + public function onInvalidWarn() { $this->_style = 0x01; } - function onInvalidInfo() + public function onInvalidInfo() { $this->_style = 0x02; } - function setFormula1($formula) + public function setFormula1($formula) { // Parse the formula using the parser in Parser.php $error = $this->_parser->parse($formula); @@ -135,7 +135,7 @@ class Spreadsheet_Excel_Writer_Validator return true; } - function setFormula2($formula) + public function setFormula2($formula) { // Parse the formula using the parser in Parser.php $error = $this->_parser->parse($formula); @@ -150,7 +150,7 @@ class Spreadsheet_Excel_Writer_Validator return true; } - function _getOptions() + protected function _getOptions() { $options = $this->_type; $options |= $this->_style << 3; @@ -174,7 +174,7 @@ class Spreadsheet_Excel_Writer_Validator return $options; } - function _getData() + protected function _getData() { $title_prompt_len = strlen($this->_title_prompt); $descr_prompt_len = strlen($this->_descr_prompt); @@ -199,13 +199,13 @@ class Spreadsheet_Excel_Writer_Validator /*class Spreadsheet_Excel_Writer_Validation_List extends Spreadsheet_Excel_Writer_Validation { - function Spreadsheet_Excel_Writer_Validation_list() + public function Spreadsheet_Excel_Writer_Validation_list() { parent::Spreadsheet_Excel_Writer_Validation(); $this->_type = 0x03; } - function setList($source, $incell = true) + public function setList($source, $incell = true) { $this->_incell = $incell; $this->_fixedList = true; @@ -214,13 +214,13 @@ class Spreadsheet_Excel_Writer_Validator $this->_formula1 = pack("CCC", 0x17, strlen($source), 0x0c) . $source; } - function setRow($row, $col1, $col2, $incell = true) + public function setRow($row, $col1, $col2, $incell = true) { $this->_incell = $incell; //$this->_formula1 = ...; } - function setCol($col, $row1, $row2, $incell = true) + public function setCol($col, $row1, $row2, $incell = true) { $this->_incell = $incell; //$this->_formula1 = ...; diff --git a/Spreadsheet/Excel/Writer/Workbook.php b/Spreadsheet/Excel/Writer/Workbook.php index 788d461..00d9a5c 100644 --- a/Spreadsheet/Excel/Writer/Workbook.php +++ b/Spreadsheet/Excel/Writer/Workbook.php @@ -53,120 +53,120 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * Filename for the Workbook * @var string */ - var $_filename; + public $_filename; /** * Formula parser * @var object Parser */ - var $_parser; + public $_parser; /** * Flag for 1904 date system (0 => base date is 1900, 1 => base date is 1904) * @var integer */ - var $_1904; + public $_1904; /** * The active worksheet of the workbook (0 indexed) * @var integer */ - var $_activesheet; + public $_activesheet; /** * 1st displayed worksheet in the workbook (0 indexed) * @var integer */ - var $_firstsheet; + public $_firstsheet; /** * Number of workbook tabs selected * @var integer */ - var $_selected; + public $_selected; /** * Index for creating adding new formats to the workbook * @var integer */ - var $_xf_index; + public $_xf_index; /** * Flag for preventing close from being called twice. * @var integer * @see close() */ - var $_fileclosed; + public $_fileclosed; /** * The BIFF file size for the workbook. * @var integer * @see _calcSheetOffsets() */ - var $_biffsize; + public $_biffsize; /** * The default sheetname for all sheets created. * @var string */ - var $_sheetname; + public $_sheetname; /** * The default XF format. * @var object Format */ - var $_tmp_format; + public $_tmp_format; /** * Array containing references to all of this workbook's worksheets * @var array */ - var $_worksheets; + public $_worksheets; /** * Array of sheetnames for creating the EXTERNSHEET records * @var array */ - var $_sheetnames; + public $_sheetnames; /** * Array containing references to all of this workbook's formats * @var array */ - var $_formats; + public $_formats; /** * Array containing the colour palette * @var array */ - var $_palette; + public $_palette; /** * The default format for URLs. * @var object Format */ - var $_url_format; + public $_url_format; /** * The codepage indicates the text encoding used for strings * @var integer */ - var $_codepage; + public $_codepage; /** * The country code used for localization * @var integer */ - var $_country_code; + public $_country_code; /** * number of bytes for sizeinfo of strings * @var integer */ - var $_string_sizeinfo_size; + public $_string_sizeinfo_size; /** @var int */ - var $_timestamp; + public $_timestamp; /** * Class constructor @@ -174,7 +174,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * @param string filename for storing the workbook. "-" for writing to stdout. * @access public */ - function Spreadsheet_Excel_Writer_Workbook($filename) + public function Spreadsheet_Excel_Writer_Workbook($filename) { // It needs to call its parent's constructor explicitly $this->Spreadsheet_Excel_Writer_BIFFwriter(); @@ -215,7 +215,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * @access public * @return mixed true on success. PEAR_Error on failure */ - function close() + public function close() { if ($this->_fileclosed) { // Prevent close() from being called twice. return true; @@ -237,7 +237,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * @see worksheets() * @return array */ - function sheets() + public function sheets() { return $this->worksheets(); } @@ -249,14 +249,14 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * @access public * @return array */ - function worksheets() + public function worksheets() { return $this->_worksheets; } /** * Sets the BIFF version. - * This method exists just to access experimental functionality + * This method exists just to access experimental public functionality * from BIFF8. It will be deprecated ! * Only possible value is 8 (Excel 97/2000). * For any other value it fails silently. @@ -264,7 +264,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * @access public * @param integer $version The BIFF version */ - function setVersion($version) + public function setVersion($version) { if ($version == 8) { // only accept version 8 $version = 0x0600; @@ -297,7 +297,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * @param integer $code Is the international calling country code for the * chosen country. */ - function setCountry($code) + public function setCountry($code) { $this->_country_code = $code; } @@ -312,7 +312,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * @return mixed reference to a worksheet object on success, PEAR_Error * on failure */ - function &addWorksheet($name = '') + public function &addWorksheet($name = '') { $index = count($this->_worksheets); $sheetname = $this->_sheetname; @@ -362,7 +362,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * @param array $properties array with properties for initializing the format. * @return &Spreadsheet_Excel_Writer_Format reference to an Excel Format */ - function &addFormat($properties = array()) + public function &addFormat($properties = array()) { $format = new Spreadsheet_Excel_Writer_Format($this->_BIFF_version, $this->_xf_index, $properties); $this->_xf_index += 1; @@ -376,7 +376,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * @access public * @return &Spreadsheet_Excel_Writer_Validator reference to a Validator */ - function &addValidator() + public function &addValidator() { include_once 'Spreadsheet/Excel/Writer/Validator.php'; /* FIXME: check for successful inclusion*/ @@ -394,7 +394,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * @param integer $blue blue RGB value [0-255] * @return integer The palette index for the custom color */ - function setCustomColor($index, $red, $green, $blue) + public function setCustomColor($index, $red, $green, $blue) { // Match a HTML #xxyyzz style parameter /*if (defined $_[1] and $_[1] =~ /^#(\w\w)(\w\w)(\w\w)/ ) { @@ -427,7 +427,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * * @access private */ - function _setPaletteXl97() + protected function _setPaletteXl97() { $this->_palette = array( array(0x00, 0x00, 0x00, 0x00), // 8 @@ -496,7 +496,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * @access private * @return mixed true on success. PEAR_Error on failure */ - function _storeWorkbook() + protected function _storeWorkbook() { if (count($this->_worksheets) == 0) { return true; @@ -572,7 +572,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * @access private * @return mixed true on success. PEAR_Error on failure */ - function _storeOLEFile() + protected function _storeOLEFile() { if($this->_BIFF_version == 0x0600) { $OLE = new OLE_PPS_File(OLE::Asc2Ucs('Workbook')); @@ -612,7 +612,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * * @access private */ - function _calcSheetOffsets() + protected function _calcSheetOffsets() { if ($this->_BIFF_version == 0x0600) { $boundsheet_length = 12; // fixed length for a BOUNDSHEET record @@ -651,7 +651,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * * @access private */ - function _storeAllFonts() + protected function _storeAllFonts() { // tmp_format is added by the constructor. We use this to write the default XF's $format = $this->_tmp_format; @@ -695,7 +695,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * * @access private */ - function _storeAllNumFormats() + protected function _storeAllNumFormats() { // Leaning num_format syndrome $hash_num_formats = array(); @@ -743,7 +743,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * * @access private */ - function _storeAllXfs() + protected function _storeAllXfs() { // _tmp_format is added by the constructor. We use this to write the default XF's // The default font index is 0 @@ -770,7 +770,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * * @access private */ - function _storeAllStyles() + protected function _storeAllStyles() { $this->_storeStyle(); } @@ -781,7 +781,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * * @access private */ - function _storeExterns() + protected function _storeExterns() { // Create EXTERNCOUNT with number of worksheets @@ -798,7 +798,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * * @access private */ - function _storeNames() + protected function _storeNames() { // Create the print area NAME records $total_worksheets = count($this->_worksheets); @@ -878,7 +878,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * * @access private */ - function _storeCodepage() + protected function _storeCodepage() { $record = 0x0042; // Record identifier $length = 0x0002; // Number of bytes to follow @@ -895,7 +895,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * * @access private */ - function _storeWindow1() + protected function _storeWindow1() { $record = 0x003D; // Record identifier $length = 0x0012; // Number of bytes to follow @@ -928,7 +928,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * @param integer $offset Location of worksheet BOF * @access private */ - function _storeBoundsheet($sheetname,$offset) + protected function _storeBoundsheet($sheetname,$offset) { $record = 0x0085; // Record identifier if ($this->_BIFF_version == 0x0600) { @@ -958,7 +958,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * * @access private */ - function _storeSupbookInternal() + protected function _storeSupbookInternal() { $record = 0x01AE; // Record identifier $length = 0x0004; // Bytes to follow @@ -975,7 +975,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * @param string $sheetname Worksheet name * @access private */ - function _storeExternsheetBiff8() + protected function _storeExternsheetBiff8() { $total_references = count($this->_parser->_references); $record = 0x0017; // Record identifier @@ -995,7 +995,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * * @access private */ - function _storeStyle() + protected function _storeStyle() { $record = 0x0293; // Record identifier $length = 0x0004; // Bytes to follow @@ -1017,7 +1017,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * @param integer $ifmt Format index code * @access private */ - function _storeNumFormat($format, $ifmt) + protected function _storeNumFormat($format, $ifmt) { $record = 0x041E; // Record identifier @@ -1055,7 +1055,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * * @access private */ - function _storeDatemode() + protected function _storeDatemode() { $record = 0x0022; // Record identifier $length = 0x0002; // Bytes to follow @@ -1081,7 +1081,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * @param integer $cxals Number of external references * @access private */ - function _storeExterncount($cxals) + protected function _storeExterncount($cxals) { $record = 0x0016; // Record identifier $length = 0x0002; // Number of bytes to follow @@ -1102,7 +1102,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * @param string $sheetname Worksheet name * @access private */ - function _storeExternsheet($sheetname) + protected function _storeExternsheet($sheetname) { $record = 0x0017; // Record identifier $length = 0x02 + strlen($sheetname); // Number of bytes to follow @@ -1128,7 +1128,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * @param integer $colmax End column * @access private */ - function _storeNameShort($index, $type, $rowmin, $rowmax, $colmin, $colmax) + protected function _storeNameShort($index, $type, $rowmin, $rowmax, $colmin, $colmax) { $record = 0x0018; // Record identifier $length = 0x0024; // Number of bytes to follow @@ -1194,7 +1194,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * @param integer $colmax End column * @access private */ - function _storeNameLong($index, $type, $rowmin, $rowmax, $colmin, $colmax) + protected function _storeNameLong($index, $type, $rowmin, $rowmax, $colmin, $colmax) { $record = 0x0018; // Record identifier $length = 0x003d; // Number of bytes to follow @@ -1269,7 +1269,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * * @access private */ - function _storeCountry() + protected function _storeCountry() { $record = 0x008C; // Record identifier $length = 4; // Number of bytes to follow @@ -1285,7 +1285,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * * @access private */ - function _storePalette() + protected function _storePalette() { $aref = $this->_palette; @@ -1315,7 +1315,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * * @access private */ - function _calculateSharedStringsSizes() + protected function _calculateSharedStringsSizes() { /* Iterate through the strings to calculate the CONTINUE block sizes. For simplicity we use the same size for the SST and CONTINUE records: @@ -1461,7 +1461,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * * @access private */ - function _storeSharedStringsTable() + protected function _storeSharedStringsTable() { $record = 0x00fc; // Record identifier $length = 0x0008; // Number of bytes to follow diff --git a/Spreadsheet/Excel/Writer/Worksheet.php b/Spreadsheet/Excel/Writer/Worksheet.php index 2cbf9b0..1ff4947 100644 --- a/Spreadsheet/Excel/Writer/Worksheet.php +++ b/Spreadsheet/Excel/Writer/Worksheet.php @@ -49,329 +49,329 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * Name of the Worksheet * @var string */ - var $name; + public $name; /** * Index for the Worksheet * @var integer */ - var $index; + public $index; /** * Reference to the (default) Format object for URLs * @var object Format */ - var $_url_format; + public $_url_format; /** * Reference to the parser used for parsing formulas * @var object Format */ - var $_parser; + public $_parser; /** * Filehandle to the temporary file for storing data * @var resource */ - var $_filehandle; + public $_filehandle; /** * Boolean indicating if we are using a temporary file for storing data * @var bool */ - var $_using_tmpfile; + public $_using_tmpfile; /** * Maximum number of rows for an Excel spreadsheet (BIFF5) * @var integer */ - var $_xls_rowmax; + public $_xls_rowmax; /** * Maximum number of columns for an Excel spreadsheet (BIFF5) * @var integer */ - var $_xls_colmax; + public $_xls_colmax; /** * Maximum number of characters for a string (LABEL record in BIFF5) * @var integer */ - var $_xls_strmax; + public $_xls_strmax; /** * First row for the DIMENSIONS record * @var integer * @see _storeDimensions() */ - var $_dim_rowmin; + public $_dim_rowmin; /** * Last row for the DIMENSIONS record * @var integer * @see _storeDimensions() */ - var $_dim_rowmax; + public $_dim_rowmax; /** * First column for the DIMENSIONS record * @var integer * @see _storeDimensions() */ - var $_dim_colmin; + public $_dim_colmin; /** * Last column for the DIMENSIONS record * @var integer * @see _storeDimensions() */ - var $_dim_colmax; + public $_dim_colmax; /** * Array containing format information for columns * @var array */ - var $_colinfo; + public $_colinfo; /** * Array containing the selected area for the worksheet * @var array */ - var $_selection; + public $_selection; /** * Array containing the panes for the worksheet * @var array */ - var $_panes; + public $_panes; /** * The active pane for the worksheet * @var integer */ - var $_active_pane; + public $_active_pane; /** * Bit specifying if panes are frozen * @var integer */ - var $_frozen; + public $_frozen; /** * Bit specifying if the worksheet is selected * @var integer */ - var $selected; + public $selected; /** * The paper size (for printing) (DOCUMENT!!!) * @var integer */ - var $_paper_size; + public $_paper_size; /** * Bit specifying paper orientation (for printing). 0 => landscape, 1 => portrait * @var integer */ - var $_orientation; + public $_orientation; /** * The page header caption * @var string */ - var $_header; + public $_header; /** * The page footer caption * @var string */ - var $_footer; + public $_footer; /** * The horizontal centering value for the page * @var integer */ - var $_hcenter; + public $_hcenter; /** * The vertical centering value for the page * @var integer */ - var $_vcenter; + public $_vcenter; /** * The margin for the header * @var float */ - var $_margin_head; + public $_margin_head; /** * The margin for the footer * @var float */ - var $_margin_foot; + public $_margin_foot; /** * The left margin for the worksheet in inches * @var float */ - var $_margin_left; + public $_margin_left; /** * The right margin for the worksheet in inches * @var float */ - var $_margin_right; + public $_margin_right; /** * The top margin for the worksheet in inches * @var float */ - var $_margin_top; + public $_margin_top; /** * The bottom margin for the worksheet in inches * @var float */ - var $_margin_bottom; + public $_margin_bottom; /** * First row to reapeat on each printed page * @var integer */ - var $title_rowmin; + public $title_rowmin; /** * Last row to reapeat on each printed page * @var integer */ - var $title_rowmax; + public $title_rowmax; /** * First column to reapeat on each printed page * @var integer */ - var $title_colmin; + public $title_colmin; /** * First row of the area to print * @var integer */ - var $print_rowmin; + public $print_rowmin; /** * Last row to of the area to print * @var integer */ - var $print_rowmax; + public $print_rowmax; /** * First column of the area to print * @var integer */ - var $print_colmin; + public $print_colmin; /** * Last column of the area to print * @var integer */ - var $print_colmax; + public $print_colmax; /** * Whether to display RightToLeft. * @var integer */ - var $_Arabic; + public $_Arabic; /** * Whether to use outline. * @var integer */ - var $_outline_on; + public $_outline_on; /** * Auto outline styles. * @var bool */ - var $_outline_style; + public $_outline_style; /** * Whether to have outline summary below. * @var bool */ - var $_outline_below; + public $_outline_below; /** * Whether to have outline summary at the right. * @var bool */ - var $_outline_right; + public $_outline_right; /** * Outline row level. * @var integer */ - var $_outline_row_level; + public $_outline_row_level; /** * Whether to fit to page when printing or not. * @var bool */ - var $_fit_page; + public $_fit_page; /** * Number of pages to fit wide * @var integer */ - var $_fit_width; + public $_fit_width; /** * Number of pages to fit high * @var integer */ - var $_fit_height; + public $_fit_height; /** * Reference to the total number of strings in the workbook * @var integer */ - var $_str_total; + public $_str_total; /** * Reference to the number of unique strings in the workbook * @var integer */ - var $_str_unique; + public $_str_unique; /** * Reference to the array containing all the unique strings in the workbook * @var array */ - var $_str_table; + public $_str_table; /** * Number of merged cell ranges in actual record * @var int $_merged_cells_counter */ - var $_merged_cells_counter = 0; + public $_merged_cells_counter = 0; /** * Number of actual mergedcells record * @var int $_merged_cells_record */ - var $_merged_cells_record = 0; + public $_merged_cells_record = 0; /** * Merged cell ranges * @var array */ - var $_merged_ranges; + public $_merged_ranges; /** * Charset encoding currently used when calling writeString() * @var string */ - var $_input_encoding; + public $_input_encoding; /** * Constructor @@ -385,7 +385,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param string $tmp_dir The path to the directory for temporary files * @access private */ - function Spreadsheet_Excel_Writer_Worksheet($BIFF_version, $name, + public function Spreadsheet_Excel_Writer_Worksheet($BIFF_version, $name, $index, &$activesheet, &$firstsheet, &$str_total, &$str_unique, &$str_table, @@ -495,7 +495,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access private */ - function _initialize() + protected function _initialize() { if ($this->_using_tmpfile == false) { return; @@ -535,7 +535,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param array $sheetnames The array of sheetnames from the Workbook this * worksheet belongs to */ - function close($sheetnames) + public function close($sheetnames) { $num_sheets = count($sheetnames); @@ -664,7 +664,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @access public * @return string The worksheet's name */ - function getName() + public function getName() { return $this->name; } @@ -675,7 +675,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @return string The data */ - function getData() + public function getData() { $buffer = 4096; @@ -709,7 +709,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param integer $last_row Last row of the area to merge * @param integer $last_col Last column of the area to merge */ - function setMerge($first_row, $first_col, $last_row, $last_col) + public function setMerge($first_row, $first_col, $last_row, $last_col) { if (($last_row < $first_row) || ($last_col < $first_col)) { return; @@ -734,7 +734,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access public */ - function select() + public function select() { $this->selected = 1; } @@ -746,7 +746,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access public */ - function activate() + public function activate() { $this->selected = 1; $this->activesheet = $this->index; @@ -759,7 +759,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access public */ - function setFirstSheet() + public function setFirstSheet() { $this->firstsheet = $this->index; } @@ -772,7 +772,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @access public * @param string $password The password to use for protecting the sheet. */ - function protect($password) + public function protect($password) { $this->_protect = 1; $this->_password = $this->_encodePassword($password); @@ -789,7 +789,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param integer $hidden The optional hidden atribute * @param integer $level The optional outline level */ - function setColumn($firstcol, $lastcol, $width, $format = null, $hidden = 0, $level = 0) + public function setColumn($firstcol, $lastcol, $width, $format = null, $hidden = 0, $level = 0) { // added by Dan Lynn _colinfo as $key => $colinfo) @@ -834,7 +834,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param integer $last_row last row in the selected quadrant * @param integer $last_column last column in the selected quadrant */ - function setSelection($first_row,$first_column,$last_row,$last_column) + public function setSelection($first_row,$first_column,$last_row,$last_column) { $this->_selection = array($first_row,$first_column,$last_row,$last_column); } @@ -850,7 +850,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * 3 => Leftmost column visible * 4 => Active pane */ - function freezePanes($panes) + public function freezePanes($panes) { $this->_frozen = 1; $this->_panes = $panes; @@ -867,7 +867,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * 3 => Leftmost column visible * 4 => Active pane */ - function thawPanes($panes) + public function thawPanes($panes) { $this->_frozen = 0; $this->_panes = $panes; @@ -878,7 +878,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access public */ - function setPortrait() + public function setPortrait() { $this->_orientation = 1; } @@ -888,7 +888,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access public */ - function setLandscape() + public function setLandscape() { $this->_orientation = 0; } @@ -899,7 +899,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @access public * @param integer $size The type of paper size to use */ - function setPaper($size = 0) + public function setPaper($size = 0) { $this->_paper_size = $size; } @@ -912,7 +912,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param string $string The header text * @param float $margin optional head margin in inches. */ - function setHeader($string,$margin = 0.50) + public function setHeader($string,$margin = 0.50) { if (strlen($string) >= 255) { //carp 'Header string must be less than 255 characters'; @@ -929,7 +929,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param string $string The footer text * @param float $margin optional foot margin in inches. */ - function setFooter($string,$margin = 0.50) + public function setFooter($string,$margin = 0.50) { if (strlen($string) >= 255) { //carp 'Footer string must be less than 255 characters'; @@ -945,7 +945,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @access public * @param integer $center the optional value for centering. Defaults to 1 (center). */ - function centerHorizontally($center = 1) + public function centerHorizontally($center = 1) { $this->_hcenter = $center; } @@ -956,7 +956,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @access public * @param integer $center the optional value for centering. Defaults to 1 (center). */ - function centerVertically($center = 1) + public function centerVertically($center = 1) { $this->_vcenter = $center; } @@ -967,7 +967,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @access public * @param float $margin The margin to set in inches */ - function setMargins($margin) + public function setMargins($margin) { $this->setMarginLeft($margin); $this->setMarginRight($margin); @@ -981,7 +981,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @access public * @param float $margin The margin to set in inches */ - function setMargins_LR($margin) + public function setMargins_LR($margin) { $this->setMarginLeft($margin); $this->setMarginRight($margin); @@ -993,7 +993,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @access public * @param float $margin The margin to set in inches */ - function setMargins_TB($margin) + public function setMargins_TB($margin) { $this->setMarginTop($margin); $this->setMarginBottom($margin); @@ -1005,7 +1005,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @access public * @param float $margin The margin to set in inches */ - function setMarginLeft($margin = 0.75) + public function setMarginLeft($margin = 0.75) { $this->_margin_left = $margin; } @@ -1016,7 +1016,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @access public * @param float $margin The margin to set in inches */ - function setMarginRight($margin = 0.75) + public function setMarginRight($margin = 0.75) { $this->_margin_right = $margin; } @@ -1027,7 +1027,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @access public * @param float $margin The margin to set in inches */ - function setMarginTop($margin = 1.00) + public function setMarginTop($margin = 1.00) { $this->_margin_top = $margin; } @@ -1038,7 +1038,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @access public * @param float $margin The margin to set in inches */ - function setMarginBottom($margin = 1.00) + public function setMarginBottom($margin = 1.00) { $this->_margin_bottom = $margin; } @@ -1050,7 +1050,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param integer $first_row First row to repeat * @param integer $last_row Last row to repeat. Optional. */ - function repeatRows($first_row, $last_row = null) + public function repeatRows($first_row, $last_row = null) { $this->title_rowmin = $first_row; if (isset($last_row)) { //Second row is optional @@ -1067,7 +1067,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param integer $first_col First column to repeat * @param integer $last_col Last column to repeat. Optional. */ - function repeatColumns($first_col, $last_col = null) + public function repeatColumns($first_col, $last_col = null) { $this->title_colmin = $first_col; if (isset($last_col)) { // Second col is optional @@ -1086,7 +1086,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param integer $last_row Last row of the area to print * @param integer $last_col Last column of the area to print */ - function printArea($first_row, $first_col, $last_row, $last_col) + public function printArea($first_row, $first_col, $last_row, $last_col) { $this->print_rowmin = $first_row; $this->print_colmin = $first_col; @@ -1100,7 +1100,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access public */ - function hideGridlines() + public function hideGridlines() { $this->_print_gridlines = 0; } @@ -1110,7 +1110,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access public */ - function hideScreenGridlines() + public function hideScreenGridlines() { $this->_screen_gridlines = 0; } @@ -1121,7 +1121,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @access public * @param integer $print Whether to print the headers or not. Defaults to 1 (print). */ - function printRowColHeaders($print = 1) + public function printRowColHeaders($print = 1) { $this->_print_headers = $print; } @@ -1135,7 +1135,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param integer $height Maximun heigth of printed area in pages * @see setPrintScale() */ - function fitToPages($width, $height) + public function fitToPages($width, $height) { $this->_fit_page = 1; $this->_fit_width = $width; @@ -1149,7 +1149,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @access public * @param array $breaks Array containing the horizontal page breaks */ - function setHPagebreaks($breaks) + public function setHPagebreaks($breaks) { foreach ($breaks as $break) { array_push($this->_hbreaks, $break); @@ -1163,7 +1163,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @access public * @param array $breaks Array containing the vertical page breaks */ - function setVPagebreaks($breaks) + public function setVPagebreaks($breaks) { foreach ($breaks as $break) { array_push($this->_vbreaks, $break); @@ -1177,7 +1177,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @access public * @param integer $scale The zoom factor */ - function setZoom($scale = 100) + public function setZoom($scale = 100) { // Confine the scale to Excel's range if ($scale < 10 || $scale > 400) { @@ -1195,7 +1195,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @access public * @param integer $scale The optional scale factor. Defaults to 100 */ - function setPrintScale($scale = 100) + public function setPrintScale($scale = 100) { // Confine the scale to Excel's range if ($scale < 10 || $scale > 400) { @@ -1218,7 +1218,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param mixed $token What we are writing * @param mixed $format The optional format to apply to the cell */ - function write($row, $col, $token, $format = null) + public function write($row, $col, $token, $format = null) { // Check for a cell reference in A1 notation and substitute row and column /*if ($_[0] =~ /^\D/) { @@ -1260,7 +1260,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @return mixed PEAR_Error on failure */ - function writeRow($row, $col, $val, $format = null) + public function writeRow($row, $col, $val, $format = null) { $retval = ''; if (is_array($val)) { @@ -1289,7 +1289,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @return mixed PEAR_Error on failure */ - function writeCol($row, $col, $val, $format = null) + public function writeCol($row, $col, $val, $format = null) { $retval = ''; if (is_array($val)) { @@ -1310,7 +1310,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param mixed &$format The optional XF format * @return integer The XF record index */ - function _XF(&$format) + protected function _XF(&$format) { if ($format) { return($format->getXfIndex()); @@ -1334,7 +1334,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @access private * @param string $data The binary data to append */ - function _append($data) + protected function _append($data) { if ($this->_using_tmpfile) { // Add CONTINUE records if necessary @@ -1358,7 +1358,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param string $cell The cell reference. Or range of cells. * @return array */ - function _substituteCellref($cell) + protected function _substituteCellref($cell) { $cell = strtoupper($cell); @@ -1394,7 +1394,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param string $cell The cell reference. * @return array containing (row, column) */ - function _cellToRowcol($cell) + protected function _cellToRowcol($cell) { preg_match("/\$?([A-I]?[A-Z])\$?(\d+)/",$cell,$match); $col = $match[1]; @@ -1425,7 +1425,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param string $plaintext The password to be encoded in plaintext. * @return string The encoded password */ - function _encodePassword($plaintext) + protected function _encodePassword($plaintext) { $password = 0x0000; $i = 1; // char position @@ -1455,7 +1455,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param bool $symbols_right * @param bool $auto_style */ - function setOutline($visible = true, $symbols_below = true, $symbols_right = true, $auto_style = false) + public function setOutline($visible = true, $symbols_below = true, $symbols_right = true, $auto_style = false) { $this->_outline_on = $visible; $this->_outline_below = $symbols_below; @@ -1473,7 +1473,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @param bool $rtl */ - function setRTL($rtl = true) + public function setRTL($rtl = true) { $this->_Arabic = ($rtl ? 1 : 0); } @@ -1500,7 +1500,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param mixed $format The optional XF format * @return integer */ - function writeNumber($row, $col, $num, $format = null) + public function writeNumber($row, $col, $num, $format = null) { $record = 0x0203; // Record identifier $length = 0x000E; // Number of bytes to follow @@ -1553,7 +1553,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param mixed $format The XF format for the cell * @return integer */ - function writeString($row, $col, $str, $format = null) + public function writeString($row, $col, $str, $format = null) { if ($this->_BIFF_version == 0x0600) { return $this->writeStringBIFF8($row, $col, $str, $format); @@ -1604,7 +1604,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @access public * @param string $encoding The encoding. Ex: 'UTF-16LE', 'utf-8', 'ISO-859-7' */ - function setInputEncoding($encoding) + public function setInputEncoding($encoding) { if ($encoding != 'UTF-16LE' && !function_exists('iconv')) { $this->raiseError("Using an input encoding other than UTF-16LE requires PHP support for iconv"); @@ -1627,7 +1627,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param mixed $format The XF format for the cell * @return integer */ - function writeStringBIFF8($row, $col, $str, $format = null) + public function writeStringBIFF8($row, $col, $str, $format = null) { // If the string is Unicode and contains any "surrogate pairs" then using mb_strlen($str, 'UTF-16LE') // as the string length will cause a "found unreadable content" error when opening the worksheet in Excel @@ -1685,7 +1685,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @return boolean true for success, false if row and/or col are grester * then maximums allowed. */ - function _checkRowCol($row, $col) + protected function _checkRowCol($row, $col) { if ($row >= $this->_xls_rowmax) { return false; @@ -1717,7 +1717,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param integer $col Zero indexed column * @param string $note The note to write */ - function writeNote($row, $col, $note) + public function writeNote($row, $col, $note) { $note_length = strlen($note); $record = 0x001C; // Record identifier @@ -1777,7 +1777,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param integer $col Zero indexed column * @param mixed $format The XF format */ - function writeBlank($row, $col, $format) + public function writeBlank($row, $col, $format) { // Don't write a blank cell unless it has a format if (!$format) { @@ -1830,7 +1830,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param mixed $format The optional XF format * @return integer */ - function writeFormula($row, $col, $formula, $format = null) + public function writeFormula($row, $col, $formula, $format = null) { $record = 0x0006; // Record identifier @@ -1908,7 +1908,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param mixed $format The cell format * @return integer */ - function writeUrl($row, $col, $url, $string = '', $format = null) + public function writeUrl($row, $col, $url, $string = '', $format = null) { // Add start row and col to arg list return($this->_writeUrlRange($row, $col, $row, $col, $url, $string, $format)); @@ -1916,7 +1916,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr /** * This is the more general form of writeUrl(). It allows a hyperlink to be - * written to a range of cells. This function also decides the type of hyperlink + * written to a range of cells. This public function also decides the type of hyperlink * to be written. These are either, Web (http, ftp, mailto), Internal * (Sheet1!A1) or external ('c:\temp\foo.xls#Sheet1!A1'). * @@ -1932,7 +1932,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @return integer */ - function _writeUrlRange($row1, $col1, $row2, $col2, $url, $string = '', $format = null) + protected function _writeUrlRange($row1, $col1, $row2, $col2, $url, $string = '', $format = null) { // Check for internal/external sheet links or default to web link @@ -1962,7 +1962,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param mixed $format The cell format * @return integer */ - function _writeUrlWeb($row1, $col1, $row2, $col2, $url, $str, $format = null) + protected function _writeUrlWeb($row1, $col1, $row2, $col2, $url, $str, $format = null) { $record = 0x01B8; // Record identifier $length = 0x00000; // Bytes to follow @@ -2022,7 +2022,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param mixed $format The cell format * @return integer */ - function _writeUrlInternal($row1, $col1, $row2, $col2, $url, $str, $format = null) + protected function _writeUrlInternal($row1, $col1, $row2, $col2, $url, $str, $format = null) { $record = 0x01B8; // Record identifier $length = 0x00000; // Bytes to follow @@ -2088,7 +2088,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param mixed $format The cell format * @return integer */ - function _writeUrlExternal($row1, $col1, $row2, $col2, $url, $str, $format = null) + protected function _writeUrlExternal($row1, $col1, $row2, $col2, $url, $str, $format = null) { // Network drives are different. We will handle them separately // MS/Novell network drives and shares start with \\ @@ -2218,7 +2218,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param bool $hidden The optional hidden attribute * @param integer $level The optional outline level for row, in range [0,7] */ - function setRow($row, $height, $format = null, $hidden = false, $level = 0) + public function setRow($row, $height, $format = null, $hidden = false, $level = 0) { $record = 0x0208; // Record identifier $length = 0x0010; // Number of bytes to follow @@ -2271,7 +2271,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access private */ - function _storeDimensions() + protected function _storeDimensions() { $record = 0x0200; // Record identifier $row_min = $this->_dim_rowmin; // First row @@ -2298,7 +2298,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access private */ - function _storeWindow2() + protected function _storeWindow2() { $record = 0x023E; // Record identifier if ($this->_BIFF_version == 0x0500) { @@ -2357,7 +2357,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access private */ - function _storeDefcol() + protected function _storeDefcol() { $record = 0x0055; // Record identifier $length = 0x0002; // Number of bytes to follow @@ -2383,7 +2383,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * 4 => Option flags. * 5 => Optional outline level */ - function _storeColinfo($col_array) + protected function _storeColinfo($col_array) { if (isset($col_array[0])) { $colFirst = $col_array[0]; @@ -2436,7 +2436,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param array $array array containing ($rwFirst,$colFirst,$rwLast,$colLast) * @see setSelection() */ - function _storeSelection($array) + protected function _storeSelection($array) { list($rwFirst,$colFirst,$rwLast,$colLast) = $array; $record = 0x001D; // Record identifier @@ -2477,7 +2477,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access private */ - function _storeMergedCells() + protected function _storeMergedCells() { // if there are no merged cell ranges set, return if (count($this->_merged_ranges) == 0) { @@ -2509,7 +2509,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @access private * @param integer $count The number of external sheet references in this worksheet */ - function _storeExterncount($count) + protected function _storeExterncount($count) { $record = 0x0016; // Record identifier $length = 0x0002; // Number of bytes to follow @@ -2528,7 +2528,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @access private * @param string $sheetname The name of a external worksheet */ - function _storeExternsheet($sheetname) + protected function _storeExternsheet($sheetname) { $record = 0x0017; // Record identifier @@ -2565,7 +2565,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * 3 => Leftmost column visible * 4 => Active pane */ - function _storePanes($panes) + protected function _storePanes($panes) { $y = $panes[0]; $x = $panes[1]; @@ -2637,7 +2637,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access private */ - function _storeSetup() + protected function _storeSetup() { $record = 0x00A1; // Record identifier $length = 0x0022; // Number of bytes to follow @@ -2698,7 +2698,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access private */ - function _storeHeader() + protected function _storeHeader() { $record = 0x0014; // Record identifier @@ -2726,7 +2726,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access private */ - function _storeFooter() + protected function _storeFooter() { $record = 0x0015; // Record identifier @@ -2754,7 +2754,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access private */ - function _storeHcenter() + protected function _storeHcenter() { $record = 0x0083; // Record identifier $length = 0x0002; // Bytes to follow @@ -2772,7 +2772,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access private */ - function _storeVcenter() + protected function _storeVcenter() { $record = 0x0084; // Record identifier $length = 0x0002; // Bytes to follow @@ -2789,7 +2789,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access private */ - function _storeMarginLeft() + protected function _storeMarginLeft() { $record = 0x0026; // Record identifier $length = 0x0008; // Bytes to follow @@ -2810,7 +2810,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access private */ - function _storeMarginRight() + protected function _storeMarginRight() { $record = 0x0027; // Record identifier $length = 0x0008; // Bytes to follow @@ -2831,7 +2831,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access private */ - function _storeMarginTop() + protected function _storeMarginTop() { $record = 0x0028; // Record identifier $length = 0x0008; // Bytes to follow @@ -2852,7 +2852,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access private */ - function _storeMarginBottom() + protected function _storeMarginBottom() { $record = 0x0029; // Record identifier $length = 0x0008; // Bytes to follow @@ -2879,7 +2879,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param integer $last_row Last row of the area to merge * @param integer $last_col Last column of the area to merge */ - function mergeCells($first_row, $first_col, $last_row, $last_col) + public function mergeCells($first_row, $first_col, $last_row, $last_col) { $record = 0x00E5; // Record identifier $length = 0x000A; // Bytes to follow @@ -2906,7 +2906,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access private */ - function _storePrintHeaders() + protected function _storePrintHeaders() { $record = 0x002a; // Record identifier $length = 0x0002; // Bytes to follow @@ -2924,7 +2924,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access private */ - function _storePrintGridlines() + protected function _storePrintGridlines() { $record = 0x002b; // Record identifier $length = 0x0002; // Bytes to follow @@ -2942,7 +2942,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access private */ - function _storeGridset() + protected function _storeGridset() { $record = 0x0082; // Record identifier $length = 0x0002; // Bytes to follow @@ -2962,7 +2962,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @see _storeWsbool() * @access private */ - function _storeGuts() + protected function _storeGuts() { $record = 0x0080; // Record identifier $length = 0x0008; // Bytes to follow @@ -3007,7 +3007,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access private */ - function _storeWsbool() + protected function _storeWsbool() { $record = 0x0081; // Record identifier $length = 0x0002; // Bytes to follow @@ -3049,7 +3049,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access private */ - function _storeHbreak() + protected function _storeHbreak() { // Return if the user hasn't specified pagebreaks if (empty($this->_hbreaks)) { @@ -3092,7 +3092,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access private */ - function _storeVbreak() + protected function _storeVbreak() { // Return if the user hasn't specified pagebreaks if (empty($this->_vbreaks)) { @@ -3137,7 +3137,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access private */ - function _storeProtect() + protected function _storeProtect() { // Exit unless sheet protection has been specified if ($this->_protect == 0) { @@ -3160,7 +3160,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access private */ - function _storePassword() + protected function _storePassword() { // Exit unless sheet protection and password have been specified if (($this->_protect == 0) || (!isset($this->_password))) { @@ -3191,7 +3191,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param integer $scale_x The horizontal scale * @param integer $scale_y The vertical scale */ - function insertBitmap($row, $col, $bitmap, $x = 0, $y = 0, $scale_x = 1, $scale_y = 1) + public function insertBitmap($row, $col, $bitmap, $x = 0, $y = 0, $scale_x = 1, $scale_y = 1) { $bitmap_array = $this->_processBitmap($bitmap); if ($this->isError($bitmap_array)) { @@ -3243,7 +3243,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * The width and height of the cells are also variable and have to be taken into * account. * The values of $col_start and $row_start are passed in from the calling - * function. The values of $col_end and $row_end are calculated by subtracting + * public function. The values of $col_end and $row_end are calculated by subtracting * the width and height of the bitmap from the width and height of the * underlying cells. * The vertices are expressed as a percentage of the underlying cell width as @@ -3269,7 +3269,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param integer $width Width of image frame * @param integer $height Height of image frame */ - function _positionImage($col_start, $row_start, $x1, $y1, $width, $height) + protected function _positionImage($col_start, $row_start, $x1, $y1, $width, $height) { // Initialise end cell to the same as the start cell $col_end = $col_start; // Col containing lower right corner of object @@ -3335,7 +3335,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param integer $col The column * @return integer The width in pixels */ - function _sizeCol($col) + protected function _sizeCol($col) { // Look up the cell value to see if it has been changed if (isset($this->col_sizes[$col])) { @@ -3359,7 +3359,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param integer $row The row * @return integer The width in pixels */ - function _sizeRow($row) + protected function _sizeRow($row) { // Look up the cell value to see if it has been changed if (isset($this->_row_sizes[$row])) { @@ -3387,7 +3387,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param integer $rwB Row containing bottom right corner of object * @param integer $dyB Distance from bottom of cell */ - function _storeObjPicture($colL,$dxL,$rwT,$dyT,$colR,$dxR,$rwB,$dyB) + protected function _storeObjPicture($colL,$dxL,$rwT,$dyT,$colR,$dxR,$rwB,$dyB) { $record = 0x005d; // Record identifier $length = 0x003c; // Bytes to follow @@ -3462,7 +3462,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param string $bitmap The bitmap to process * @return array Array with data and properties of the bitmap */ - function _processBitmap($bitmap) + protected function _processBitmap($bitmap) { // Open file. $bmp_fd = @fopen($bitmap,"rb"); @@ -3546,7 +3546,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access private */ - function _storeZoom() + protected function _storeZoom() { // If scale is 100 we don't need to write a record if ($this->_zoom == 100) { @@ -3564,7 +3564,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr /** * FIXME: add comments */ - function setValidation($row1, $col1, $row2, $col2, &$validator) + public function setValidation($row1, $col1, $row2, $col2, &$validator) { $this->_dv[] = $validator->_getData() . pack("vvvvv", 1, $row1, $row2, $col1, $col2); @@ -3575,7 +3575,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @access private */ - function _storeDataValidity() + protected function _storeDataValidity() { $record = 0x01b2; // Record identifier $length = 0x0012; // Bytes to follow From 3e8a35b81f9d663a3286171cb666e6b24fe1d5d3 Mon Sep 17 00:00:00 2001 From: Alexey Kopytko Date: Thu, 16 Jun 2016 11:27:22 +0900 Subject: [PATCH 05/15] Make sure traditional include-path-style class loading does not interfere with a working class autoloader --- Spreadsheet/Excel/Writer.php | 5 +++-- Spreadsheet/Excel/Writer/BIFFwriter.php | 4 +++- Spreadsheet/Excel/Writer/Format.php | 4 +++- Spreadsheet/Excel/Writer/Parser.php | 4 +++- Spreadsheet/Excel/Writer/Workbook.php | 24 +++++++++++++++++------- Spreadsheet/Excel/Writer/Worksheet.php | 6 ++++-- 6 files changed, 33 insertions(+), 14 deletions(-) diff --git a/Spreadsheet/Excel/Writer.php b/Spreadsheet/Excel/Writer.php index d62e9cf..fc5baca 100644 --- a/Spreadsheet/Excel/Writer.php +++ b/Spreadsheet/Excel/Writer.php @@ -31,8 +31,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -require_once 'PEAR.php'; -require_once 'Spreadsheet/Excel/Writer/Workbook.php'; +if (!class_exists('Spreadsheet_Excel_Writer_Workbook')) { + require_once 'Spreadsheet/Excel/Writer/Workbook.php'; +} /** * Class for writing Excel Spreadsheets. This class should change COMPLETELY. diff --git a/Spreadsheet/Excel/Writer/BIFFwriter.php b/Spreadsheet/Excel/Writer/BIFFwriter.php index 57e1de9..5a5abe8 100644 --- a/Spreadsheet/Excel/Writer/BIFFwriter.php +++ b/Spreadsheet/Excel/Writer/BIFFwriter.php @@ -32,7 +32,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -require_once 'PEAR.php'; +if (!class_exists('PEAR')) { + require_once 'PEAR.php'; +} /** * Class for writing Excel BIFF records. diff --git a/Spreadsheet/Excel/Writer/Format.php b/Spreadsheet/Excel/Writer/Format.php index 58dc8d1..8cead32 100644 --- a/Spreadsheet/Excel/Writer/Format.php +++ b/Spreadsheet/Excel/Writer/Format.php @@ -32,7 +32,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -require_once 'PEAR.php'; +if (!class_exists('PEAR')) { + require_once 'PEAR.php'; +} /** * Class for generating Excel XF records (formats) diff --git a/Spreadsheet/Excel/Writer/Parser.php b/Spreadsheet/Excel/Writer/Parser.php index ee43e12..26b5f65 100644 --- a/Spreadsheet/Excel/Writer/Parser.php +++ b/Spreadsheet/Excel/Writer/Parser.php @@ -97,7 +97,9 @@ define('SPREADSHEET_EXCEL_WRITER_NE', "<>"); */ define('SPREADSHEET_EXCEL_WRITER_CONCAT', "&"); -require_once 'PEAR.php'; +if (!class_exists('PEAR')) { + require_once 'PEAR.php'; +} /** * Class for parsing Excel formulas diff --git a/Spreadsheet/Excel/Writer/Workbook.php b/Spreadsheet/Excel/Writer/Workbook.php index 00d9a5c..6a3c3cb 100644 --- a/Spreadsheet/Excel/Writer/Workbook.php +++ b/Spreadsheet/Excel/Writer/Workbook.php @@ -32,12 +32,20 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -require_once 'Spreadsheet/Excel/Writer/Format.php'; -require_once 'Spreadsheet/Excel/Writer/BIFFwriter.php'; -require_once 'Spreadsheet/Excel/Writer/Worksheet.php'; -require_once 'Spreadsheet/Excel/Writer/Parser.php'; -require_once 'OLE/PPS/Root.php'; -require_once 'OLE/PPS/File.php'; +if (!class_exists('Spreadsheet_Excel_Writer_BIFFwriter')) { + require_once 'Spreadsheet/Excel/Writer/Format.php'; + require_once 'Spreadsheet/Excel/Writer/BIFFwriter.php'; + require_once 'Spreadsheet/Excel/Writer/Worksheet.php'; + require_once 'Spreadsheet/Excel/Writer/Parser.php'; +} + +if (!class_exists('OLE_PPS_Root')) { + require_once 'OLE/PPS/Root.php'; +} + +if (!class_exists('OLE_PPS_File')) { + require_once 'OLE/PPS/File.php'; +} /** * Class for generating Excel Spreadsheets @@ -378,7 +386,9 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri */ public function &addValidator() { - include_once 'Spreadsheet/Excel/Writer/Validator.php'; + if (!class_exists('Spreadsheet_Excel_Writer_Validator')) { + include_once 'Spreadsheet/Excel/Writer/Validator.php'; + } /* FIXME: check for successful inclusion*/ $valid = new Spreadsheet_Excel_Writer_Validator($this->_parser); return $valid; diff --git a/Spreadsheet/Excel/Writer/Worksheet.php b/Spreadsheet/Excel/Writer/Worksheet.php index 1ff4947..d46d6b5 100644 --- a/Spreadsheet/Excel/Writer/Worksheet.php +++ b/Spreadsheet/Excel/Writer/Worksheet.php @@ -32,8 +32,10 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -require_once 'Spreadsheet/Excel/Writer/Parser.php'; -require_once 'Spreadsheet/Excel/Writer/BIFFwriter.php'; +if (!class_exists('Spreadsheet_Excel_Writer_BIFFwriter')) { + require_once 'Spreadsheet/Excel/Writer/Parser.php'; + require_once 'Spreadsheet/Excel/Writer/BIFFwriter.php'; +} /** * Class for generating Excel Spreadsheets From 2ec40810e8057f6f15ff32d612b93fc34a4d8cdd Mon Sep 17 00:00:00 2001 From: Alexey Kopytko Date: Thu, 16 Jun 2016 11:30:51 +0900 Subject: [PATCH 06/15] Removed trailing ?> --- Spreadsheet/Excel/Writer.php | 3 +-- Spreadsheet/Excel/Writer/BIFFwriter.php | 3 +-- Spreadsheet/Excel/Writer/Format.php | 3 +-- Spreadsheet/Excel/Writer/Parser.php | 3 +-- Spreadsheet/Excel/Writer/Validator.php | 4 +--- Spreadsheet/Excel/Writer/Worksheet.php | 3 +-- 6 files changed, 6 insertions(+), 13 deletions(-) diff --git a/Spreadsheet/Excel/Writer.php b/Spreadsheet/Excel/Writer.php index fc5baca..2da963d 100644 --- a/Spreadsheet/Excel/Writer.php +++ b/Spreadsheet/Excel/Writer.php @@ -101,5 +101,4 @@ class Spreadsheet_Excel_Writer extends Spreadsheet_Excel_Writer_Workbook return $chr1 . $chr2 . $row; } -} -?> +} \ No newline at end of file diff --git a/Spreadsheet/Excel/Writer/BIFFwriter.php b/Spreadsheet/Excel/Writer/BIFFwriter.php index 5a5abe8..1a2910b 100644 --- a/Spreadsheet/Excel/Writer/BIFFwriter.php +++ b/Spreadsheet/Excel/Writer/BIFFwriter.php @@ -265,5 +265,4 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR } return false; } -} -?> +} \ No newline at end of file diff --git a/Spreadsheet/Excel/Writer/Format.php b/Spreadsheet/Excel/Writer/Format.php index 8cead32..9d9da69 100644 --- a/Spreadsheet/Excel/Writer/Format.php +++ b/Spreadsheet/Excel/Writer/Format.php @@ -1107,5 +1107,4 @@ class Spreadsheet_Excel_Writer_Format extends PEAR { $this->_font_name = $font_family; } -} -?> +} \ No newline at end of file diff --git a/Spreadsheet/Excel/Writer/Parser.php b/Spreadsheet/Excel/Writer/Parser.php index 26b5f65..e443290 100644 --- a/Spreadsheet/Excel/Writer/Parser.php +++ b/Spreadsheet/Excel/Writer/Parser.php @@ -1701,5 +1701,4 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR $polish .= $converted_tree; return $polish; } -} - +} \ No newline at end of file diff --git a/Spreadsheet/Excel/Writer/Validator.php b/Spreadsheet/Excel/Writer/Validator.php index e100326..5d8970f 100644 --- a/Spreadsheet/Excel/Writer/Validator.php +++ b/Spreadsheet/Excel/Writer/Validator.php @@ -225,6 +225,4 @@ class Spreadsheet_Excel_Writer_Validator $this->_incell = $incell; //$this->_formula1 = ...; } -}*/ - -?> +}*/ \ No newline at end of file diff --git a/Spreadsheet/Excel/Writer/Worksheet.php b/Spreadsheet/Excel/Writer/Worksheet.php index d46d6b5..8f89b4b 100644 --- a/Spreadsheet/Excel/Writer/Worksheet.php +++ b/Spreadsheet/Excel/Writer/Worksheet.php @@ -3599,5 +3599,4 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr $this->_append($header . $dv); } } -} -?> +} \ No newline at end of file From 2cfd980499590222e11c1d73b6c971de73b787a1 Mon Sep 17 00:00:00 2001 From: Alexey Kopytko Date: Thu, 16 Jun 2016 11:31:05 +0900 Subject: [PATCH 07/15] Trim whitespace in Worksheet --- Spreadsheet/Excel/Writer/Worksheet.php | 108 ++++++++++++------------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/Spreadsheet/Excel/Writer/Worksheet.php b/Spreadsheet/Excel/Writer/Worksheet.php index 8f89b4b..7485faf 100644 --- a/Spreadsheet/Excel/Writer/Worksheet.php +++ b/Spreadsheet/Excel/Writer/Worksheet.php @@ -483,7 +483,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr $this->_input_encoding = ''; $this->_dv = array(); - + $this->_tmp_dir = $tmp_dir; $this->_tmp_file = ''; @@ -506,7 +506,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr if ($this->_tmp_dir === '' && ini_get('open_basedir') === true) { // open_basedir restriction in effect - store data in memory // ToDo: Let the error actually have an effect somewhere - $this->_using_tmpfile = false; + $this->_using_tmpfile = false; return new PEAR_Error('Temp file could not be opened since open_basedir restriction in effect - please use setTmpDir() - using memory storage instead'); } @@ -791,40 +791,40 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param integer $hidden The optional hidden atribute * @param integer $level The optional outline level */ - public function setColumn($firstcol, $lastcol, $width, $format = null, $hidden = 0, $level = 0) - { // added by Dan Lynn _colinfo as $key => $colinfo) + public function setColumn($firstcol, $lastcol, $width, $format = null, $hidden = 0, $level = 0) + { // added by Dan Lynn _colinfo as $key => $colinfo) { - $existing_start = $colinfo[0]; $existing_end = $colinfo[1]; - // if the new range starts within another range - if ($firstcol > $existing_start && $firstcol < $existing_end) - { // trim the existing range to the beginning of the new range - $this->_colinfo[$key][1] = $firstcol - 1; - // if the new range lies WITHIN the existing range - if ($lastcol < $existing_end) - { // split the existing range by adding a range after our new range - $this->_colinfo[] = array($lastcol+1, $existing_end, $colinfo[2], &$colinfo[3], $colinfo[4], $colinfo[5]); - } - } // if the new range ends inside an existing range - elseif ($lastcol > $existing_start && $lastcol < $existing_end) - { // trim the existing range to the end of the new range - $this->_colinfo[$key][0] = $lastcol + 1; - } // if the new range completely overlaps the existing range - elseif ($firstcol <= $existing_start && $lastcol >= $existing_end) - { - unset($this->_colinfo[$key]); - } - } // added by Dan Lynn _colinfo = array_values($this->_colinfo); - $this->_colinfo[] = array($firstcol, $lastcol, $width, &$format, $hidden, $level); - // Set width to zero if column is hidden - $width = ($hidden) ? 0 : $width; - for ($col = $firstcol; $col <= $lastcol; $col++) - { - $this->col_sizes[$col] = $width; - } + $existing_start = $colinfo[0]; $existing_end = $colinfo[1]; + // if the new range starts within another range + if ($firstcol > $existing_start && $firstcol < $existing_end) + { // trim the existing range to the beginning of the new range + $this->_colinfo[$key][1] = $firstcol - 1; + // if the new range lies WITHIN the existing range + if ($lastcol < $existing_end) + { // split the existing range by adding a range after our new range + $this->_colinfo[] = array($lastcol+1, $existing_end, $colinfo[2], &$colinfo[3], $colinfo[4], $colinfo[5]); + } + } // if the new range ends inside an existing range + elseif ($lastcol > $existing_start && $lastcol < $existing_end) + { // trim the existing range to the end of the new range + $this->_colinfo[$key][0] = $lastcol + 1; + } // if the new range completely overlaps the existing range + elseif ($firstcol <= $existing_start && $lastcol >= $existing_end) + { + unset($this->_colinfo[$key]); + } + } // added by Dan Lynn _colinfo = array_values($this->_colinfo); + $this->_colinfo[] = array($firstcol, $lastcol, $width, &$format, $hidden, $level); + // Set width to zero if column is hidden + $width = ($hidden) ? 0 : $width; + for ($col = $firstcol; $col <= $lastcol; $col++) + { + $this->col_sizes[$col] = $width; + } } /** @@ -2097,19 +2097,19 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr if (preg_match('[^external:\\\\]', $url)) { return; //($this->_writeUrlExternal_net($row1, $col1, $row2, $col2, $url, $str, $format)); } - + $record = 0x01B8; // Record identifier $length = 0x00000; // Bytes to follow - + if (!$format) { $format = $this->_url_format; } - + // Strip URL type and change Unix dir separator to Dos style (if needed) // $url = preg_replace('/^external:/', '', $url); $url = preg_replace('/\//', "\\", $url); - + // Write the visible label if ($str == '') { $str = preg_replace('/\#/', ' - ', $url); @@ -2118,12 +2118,12 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr if (($str_error == -2) or ($str_error == -3)) { return $str_error; } - + // Determine if the link is relative or absolute: // relative if link contains no dir separator, "somefile.xls" // relative if link starts with up-dir, "..\..\somefile.xls" // otherwise, absolute - + $absolute = 0x02; // Bit mask if (!preg_match("/\\\/", $url)) { $absolute = 0x00; @@ -2132,7 +2132,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr $absolute = 0x00; } $link_type = 0x01 | $absolute; - + // Determine if the link contains a sheet reference and change some of the // parameters accordingly. // Split the dir name and sheet name (if it exists) @@ -2141,7 +2141,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr } else { $dir_long = $url; } - + if (isset($sheet)) { $link_type |= 0x08; $sheet_len = pack("V", strlen($sheet) + 0x01); @@ -2157,32 +2157,32 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr } - + // Pack the link type $link_type = pack("V", $link_type); - + // Calculate the up-level dir count e.g.. (..\..\..\ == 3) $up_count = preg_match_all("/\.\.\\\/", $dir_long, $useless); $up_count = pack("v", $up_count); - + // Store the short dos dir name (null terminated) $dir_short = preg_replace("/\.\.\\\/", '', $dir_long) . "\0"; - + // Store the long dir name as a wchar string (non-null terminated) //$dir_long = join("\0", split('', $dir_long)); $dir_long = $dir_long . "\0"; - + // Pack the lengths of the dir strings $dir_short_len = pack("V", strlen($dir_short) ); $dir_long_len = pack("V", strlen($dir_long) ); $stream_len = pack("V", 0);//strlen($dir_long) + 0x06); - + // Pack the undocumented parts of the hyperlink stream $unknown1 = pack("H*",'D0C9EA79F9BACE118C8200AA004BA90B02000000' ); $unknown2 = pack("H*",'0303000000000000C000000000000046' ); $unknown3 = pack("H*",'FFFFADDE000000000000000000000000000000000000000'); $unknown4 = pack("v", 0x03 ); - + // Pack the main data stream $data = pack("vvvv", $row1, $row2, $col1, $col2) . $unknown1 . @@ -2198,11 +2198,11 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr $dir_long . $sheet_len . $sheet ;*/ - + // Pack the header data $length = strlen($data); $header = pack("vv", $record, $length); - + // Write the packed data $this->_append($header. $data); return($str_error); @@ -2488,10 +2488,10 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr $record = 0x00E5; foreach($this->_merged_ranges as $ranges) { - $length = 2 + count($ranges) * 8; + $length = 2 + count($ranges) * 8; $header = pack('vv', $record, $length); $data = pack('v', count($ranges)); - foreach ($ranges as $range) + foreach ($ranges as $range) $data .= pack('vvvv', $range[0], $range[2], $range[1], $range[3]); $string = $header.$data; $this->_append($string, true); From 0da21c8611e45ad1d0a871284c8c1b73349f3faf Mon Sep 17 00:00:00 2001 From: Alexey Kopytko Date: Thu, 16 Jun 2016 11:41:45 +0900 Subject: [PATCH 08/15] Renamed old-style constructors --- Spreadsheet/Excel/Writer.php | 4 ++-- Spreadsheet/Excel/Writer/BIFFwriter.php | 2 +- Spreadsheet/Excel/Writer/Format.php | 2 +- Spreadsheet/Excel/Writer/Parser.php | 2 +- Spreadsheet/Excel/Writer/Validator.php | 2 +- Spreadsheet/Excel/Writer/Workbook.php | 4 ++-- Spreadsheet/Excel/Writer/Worksheet.php | 4 ++-- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Spreadsheet/Excel/Writer.php b/Spreadsheet/Excel/Writer.php index 2da963d..4eec27e 100644 --- a/Spreadsheet/Excel/Writer.php +++ b/Spreadsheet/Excel/Writer.php @@ -51,10 +51,10 @@ class Spreadsheet_Excel_Writer extends Spreadsheet_Excel_Writer_Workbook * @param string $filename The optional filename for the Workbook. * @return Spreadsheet_Excel_Writer_Workbook The Workbook created */ - function Spreadsheet_Excel_Writer($filename = '') + function __construct($filename = '') { $this->_filename = $filename; - $this->Spreadsheet_Excel_Writer_Workbook($filename); + parent::__construct($filename); } /** diff --git a/Spreadsheet/Excel/Writer/BIFFwriter.php b/Spreadsheet/Excel/Writer/BIFFwriter.php index 1a2910b..cb08407 100644 --- a/Spreadsheet/Excel/Writer/BIFFwriter.php +++ b/Spreadsheet/Excel/Writer/BIFFwriter.php @@ -103,7 +103,7 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR * * @access public */ - public function Spreadsheet_Excel_Writer_BIFFwriter() + public function __construct() { $this->_byte_order = ''; $this->_data = ''; diff --git a/Spreadsheet/Excel/Writer/Format.php b/Spreadsheet/Excel/Writer/Format.php index 9d9da69..c19d4e5 100644 --- a/Spreadsheet/Excel/Writer/Format.php +++ b/Spreadsheet/Excel/Writer/Format.php @@ -251,7 +251,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR * @param integer $index the XF index for the format. * @param array $properties array with properties to be set on initialization. */ - public function Spreadsheet_Excel_Writer_Format($BIFF_version, $index = 0, $properties = array()) + public function __construct($BIFF_version, $index = 0, $properties = array()) { $this->_xf_index = $index; $this->_BIFF_version = $BIFF_version; diff --git a/Spreadsheet/Excel/Writer/Parser.php b/Spreadsheet/Excel/Writer/Parser.php index e443290..9182f9b 100644 --- a/Spreadsheet/Excel/Writer/Parser.php +++ b/Spreadsheet/Excel/Writer/Parser.php @@ -171,7 +171,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR * @param integer $byte_order The byte order (Little endian or Big endian) of the architecture (optional). 1 => big endian, 0 (default) little endian. */ - public function Spreadsheet_Excel_Writer_Parser($byte_order, $biff_version) + public function __construct($byte_order, $biff_version) { $this->_current_char = 0; $this->_BIFF_version = $biff_version; diff --git a/Spreadsheet/Excel/Writer/Validator.php b/Spreadsheet/Excel/Writer/Validator.php index 5d8970f..6612315 100644 --- a/Spreadsheet/Excel/Writer/Validator.php +++ b/Spreadsheet/Excel/Writer/Validator.php @@ -67,7 +67,7 @@ class Spreadsheet_Excel_Writer_Validator */ public $_parser; - public function Spreadsheet_Excel_Writer_Validator(&$parser) + public function __construct(&$parser) { $this->_parser = $parser; $this->_type = 0x01; // FIXME: add method for setting datatype diff --git a/Spreadsheet/Excel/Writer/Workbook.php b/Spreadsheet/Excel/Writer/Workbook.php index 6a3c3cb..7b5da14 100644 --- a/Spreadsheet/Excel/Writer/Workbook.php +++ b/Spreadsheet/Excel/Writer/Workbook.php @@ -182,10 +182,10 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * @param string filename for storing the workbook. "-" for writing to stdout. * @access public */ - public function Spreadsheet_Excel_Writer_Workbook($filename) + public function __construct($filename) { // It needs to call its parent's constructor explicitly - $this->Spreadsheet_Excel_Writer_BIFFwriter(); + parent::__construct(); $this->_filename = $filename; $this->_parser = new Spreadsheet_Excel_Writer_Parser($this->_byte_order, $this->_BIFF_version); diff --git a/Spreadsheet/Excel/Writer/Worksheet.php b/Spreadsheet/Excel/Writer/Worksheet.php index 7485faf..0d73ca5 100644 --- a/Spreadsheet/Excel/Writer/Worksheet.php +++ b/Spreadsheet/Excel/Writer/Worksheet.php @@ -387,7 +387,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * @param string $tmp_dir The path to the directory for temporary files * @access private */ - public function Spreadsheet_Excel_Writer_Worksheet($BIFF_version, $name, + public function __construct($BIFF_version, $name, $index, &$activesheet, &$firstsheet, &$str_total, &$str_unique, &$str_table, @@ -395,7 +395,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr $tmp_dir) { // It needs to call its parent's constructor explicitly - $this->Spreadsheet_Excel_Writer_BIFFwriter(); + parent::__construct(); $this->_BIFF_version = $BIFF_version; $rowmax = 65536; // 16384 in Excel 5 $colmax = 256; From 779a081aa00e1c4f6bad792285d269564529cceb Mon Sep 17 00:00:00 2001 From: Alexey Kopytko Date: Thu, 16 Jun 2016 11:45:57 +0900 Subject: [PATCH 09/15] Remove references except where they're actually used --- Spreadsheet/Excel/Writer/Validator.php | 2 +- Spreadsheet/Excel/Writer/Workbook.php | 16 +++++------ Spreadsheet/Excel/Writer/Worksheet.php | 37 +++++++++++++++----------- 3 files changed, 30 insertions(+), 25 deletions(-) diff --git a/Spreadsheet/Excel/Writer/Validator.php b/Spreadsheet/Excel/Writer/Validator.php index 6612315..e2bd4cf 100644 --- a/Spreadsheet/Excel/Writer/Validator.php +++ b/Spreadsheet/Excel/Writer/Validator.php @@ -67,7 +67,7 @@ class Spreadsheet_Excel_Writer_Validator */ public $_parser; - public function __construct(&$parser) + public function __construct($parser) { $this->_parser = $parser; $this->_type = 0x01; // FIXME: add method for setting datatype diff --git a/Spreadsheet/Excel/Writer/Workbook.php b/Spreadsheet/Excel/Writer/Workbook.php index 7b5da14..5948472 100644 --- a/Spreadsheet/Excel/Writer/Workbook.php +++ b/Spreadsheet/Excel/Writer/Workbook.php @@ -207,7 +207,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri $this->_string_sizeinfo = 3; // Add the default format for hyperlinks - $this->_url_format =& $this->addFormat(array('color' => 'blue', 'underline' => 1)); + $this->_url_format = $this->addFormat(array('color' => 'blue', 'underline' => 1)); $this->_str_total = 0; $this->_str_unique = 0; $this->_str_table = array(); @@ -320,7 +320,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * @return mixed reference to a worksheet object on success, PEAR_Error * on failure */ - public function &addWorksheet($name = '') + public function addWorksheet($name = '') { $index = count($this->_worksheets); $sheetname = $this->_sheetname; @@ -356,7 +356,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri $this->_str_table, $this->_url_format, $this->_parser, $this->_tmp_dir); - $this->_worksheets[$index] = &$worksheet; // Store ref for iterator + $this->_worksheets[$index] = $worksheet; // Store ref for iterator $this->_sheetnames[$index] = $name; // Store EXTERNSHEET names $this->_parser->setExtSheet($name, $index); // Register worksheet name with parser return $worksheet; @@ -368,13 +368,13 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * * @access public * @param array $properties array with properties for initializing the format. - * @return &Spreadsheet_Excel_Writer_Format reference to an Excel Format + * @return Spreadsheet_Excel_Writer_Format */ - public function &addFormat($properties = array()) + public function addFormat($properties = array()) { $format = new Spreadsheet_Excel_Writer_Format($this->_BIFF_version, $this->_xf_index, $properties); $this->_xf_index += 1; - $this->_formats[] = &$format; + $this->_formats[] = $format; return $format; } @@ -382,9 +382,9 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * Create new validator. * * @access public - * @return &Spreadsheet_Excel_Writer_Validator reference to a Validator + * @return Spreadsheet_Excel_Writer_Validator */ - public function &addValidator() + public function addValidator() { if (!class_exists('Spreadsheet_Excel_Writer_Validator')) { include_once 'Spreadsheet/Excel/Writer/Validator.php'; diff --git a/Spreadsheet/Excel/Writer/Worksheet.php b/Spreadsheet/Excel/Writer/Worksheet.php index 0d73ca5..4997477 100644 --- a/Spreadsheet/Excel/Writer/Worksheet.php +++ b/Spreadsheet/Excel/Writer/Worksheet.php @@ -380,18 +380,21 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @param string $name The name of the new worksheet * @param integer $index The index of the new worksheet - * @param mixed &$activesheet The current activesheet of the workbook we belong to - * @param mixed &$firstsheet The first worksheet in the workbook we belong to - * @param mixed &$url_format The default format for hyperlinks - * @param mixed &$parser The formula parser created for the Workbook + * @param mixed $activesheet The current activesheet of the workbook we belong to + * @param mixed $firstsheet The first worksheet in the workbook we belong to + * @param int &$str_total Reference to the total number of strings in the workbook + * @param int &$str_unique Reference to the number of unique strings in the workbook + * @param array &$str_table Reference to the array containing all the unique strings in the workbook + * @param mixed $url_format The default format for hyperlinks + * @param mixed $parser The formula parser created for the Workbook * @param string $tmp_dir The path to the directory for temporary files * @access private */ public function __construct($BIFF_version, $name, - $index, &$activesheet, - &$firstsheet, &$str_total, + $index, $activesheet, + $firstsheet, &$str_total, &$str_unique, &$str_table, - &$url_format, &$parser, + $url_format, $parser, $tmp_dir) { // It needs to call its parent's constructor explicitly @@ -402,13 +405,15 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr $this->name = $name; $this->index = $index; - $this->activesheet = &$activesheet; - $this->firstsheet = &$firstsheet; + $this->activesheet = $activesheet; + $this->firstsheet = $firstsheet; + // _str_total _str_unique _str_table - are actual references + // everything breaks if they're not $this->_str_total = &$str_total; $this->_str_unique = &$str_unique; $this->_str_table = &$str_table; - $this->_url_format = &$url_format; - $this->_parser = &$parser; + $this->_url_format = $url_format; + $this->_parser = $parser; //$this->ext_sheets = array(); $this->_filehandle = ''; @@ -804,7 +809,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr // if the new range lies WITHIN the existing range if ($lastcol < $existing_end) { // split the existing range by adding a range after our new range - $this->_colinfo[] = array($lastcol+1, $existing_end, $colinfo[2], &$colinfo[3], $colinfo[4], $colinfo[5]); + $this->_colinfo[] = array($lastcol+1, $existing_end, $colinfo[2], /* format */ $colinfo[3], $colinfo[4], $colinfo[5]); } } // if the new range ends inside an existing range elseif ($lastcol > $existing_start && $lastcol < $existing_end) @@ -818,7 +823,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr } // added by Dan Lynn _colinfo = array_values($this->_colinfo); - $this->_colinfo[] = array($firstcol, $lastcol, $width, &$format, $hidden, $level); + $this->_colinfo[] = array($firstcol, $lastcol, $width, $format, $hidden, $level); // Set width to zero if column is hidden $width = ($hidden) ? 0 : $width; for ($col = $firstcol; $col <= $lastcol; $col++) @@ -1309,10 +1314,10 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * Returns an index to the XF record in the workbook * * @access private - * @param mixed &$format The optional XF format + * @param mixed $format The optional XF format * @return integer The XF record index */ - protected function _XF(&$format) + protected function _XF($format) { if ($format) { return($format->getXfIndex()); @@ -3566,7 +3571,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr /** * FIXME: add comments */ - public function setValidation($row1, $col1, $row2, $col2, &$validator) + public function setValidation($row1, $col1, $row2, $col2, $validator) { $this->_dv[] = $validator->_getData() . pack("vvvvv", 1, $row1, $row2, $col1, $col2); From f1195b4a2162acf835304a28003926020399ae7a Mon Sep 17 00:00:00 2001 From: Alexey Kopytko Date: Thu, 16 Jun 2016 11:58:07 +0900 Subject: [PATCH 10/15] Correct class names in @var --- Spreadsheet/Excel/Writer/Workbook.php | 6 +++--- Spreadsheet/Excel/Writer/Worksheet.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Spreadsheet/Excel/Writer/Workbook.php b/Spreadsheet/Excel/Writer/Workbook.php index 5948472..4c9e525 100644 --- a/Spreadsheet/Excel/Writer/Workbook.php +++ b/Spreadsheet/Excel/Writer/Workbook.php @@ -65,7 +65,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri /** * Formula parser - * @var object Parser + * @var Spreadsheet_Excel_Writer_Parser */ public $_parser; @@ -121,7 +121,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri /** * The default XF format. - * @var object Format + * @var Spreadsheet_Excel_Writer_Format */ public $_tmp_format; @@ -151,7 +151,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri /** * The default format for URLs. - * @var object Format + * @var Spreadsheet_Excel_Writer_Format */ public $_url_format; diff --git a/Spreadsheet/Excel/Writer/Worksheet.php b/Spreadsheet/Excel/Writer/Worksheet.php index 4997477..b70603b 100644 --- a/Spreadsheet/Excel/Writer/Worksheet.php +++ b/Spreadsheet/Excel/Writer/Worksheet.php @@ -61,13 +61,13 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr /** * Reference to the (default) Format object for URLs - * @var object Format + * @var Spreadsheet_Excel_Writer_Format */ public $_url_format; /** * Reference to the parser used for parsing formulas - * @var object Format + * @var Spreadsheet_Excel_Writer_Format */ public $_parser; From 8878394496ced7f14a83a43c32c58ba131eaef46 Mon Sep 17 00:00:00 2001 From: Alexey Kopytko Date: Thu, 16 Jun 2016 12:01:18 +0900 Subject: [PATCH 11/15] Prefix with "public" functions in Writer --- Spreadsheet/Excel/Writer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Spreadsheet/Excel/Writer.php b/Spreadsheet/Excel/Writer.php index 4eec27e..8141cb2 100644 --- a/Spreadsheet/Excel/Writer.php +++ b/Spreadsheet/Excel/Writer.php @@ -51,7 +51,7 @@ class Spreadsheet_Excel_Writer extends Spreadsheet_Excel_Writer_Workbook * @param string $filename The optional filename for the Workbook. * @return Spreadsheet_Excel_Writer_Workbook The Workbook created */ - function __construct($filename = '') + public function __construct($filename = '') { $this->_filename = $filename; parent::__construct($filename); @@ -63,7 +63,7 @@ class Spreadsheet_Excel_Writer extends Spreadsheet_Excel_Writer_Workbook * @param string $filename The filename to use for HTTP headers * @access public */ - function send($filename) + public function send($filename) { header("Content-type: application/vnd.ms-excel"); header("Content-Disposition: attachment; filename=\"$filename\""); From 4b6d1a34533cbe073fa65a2daaca1c6cc49c1329 Mon Sep 17 00:00:00 2001 From: Alexey Kopytko Date: Thu, 16 Jun 2016 12:05:40 +0900 Subject: [PATCH 12/15] Escape filename used in Content-Disposition header --- Spreadsheet/Excel/Writer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/Spreadsheet/Excel/Writer.php b/Spreadsheet/Excel/Writer.php index 8141cb2..8bb710c 100644 --- a/Spreadsheet/Excel/Writer.php +++ b/Spreadsheet/Excel/Writer.php @@ -65,6 +65,7 @@ class Spreadsheet_Excel_Writer extends Spreadsheet_Excel_Writer_Workbook */ public function send($filename) { + $filename = addslashes($filename); header("Content-type: application/vnd.ms-excel"); header("Content-Disposition: attachment; filename=\"$filename\""); header("Expires: 0"); From 68e370a91781358c0d2110b479c8ef659d42b838 Mon Sep 17 00:00:00 2001 From: Alexey Kopytko Date: Thu, 16 Jun 2016 12:09:30 +0900 Subject: [PATCH 13/15] Added coverage report for PHPUnit --- phpunit.xml.dist | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 13323cf..d25b855 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -14,4 +14,15 @@ test/ + + + + Spreadsheet/ + + + + + + + From 760a4dd30789919e1622db5af1e6e39049f665ee Mon Sep 17 00:00:00 2001 From: Alexey Kopytko Date: Thu, 16 Jun 2016 12:26:32 +0900 Subject: [PATCH 14/15] Fixed autoloading for tests --- composer.json | 8 ++++++-- phpunit.xml.dist | 2 +- ...eet_Excel_Writer_WorkbookTest.php => WorkbookTest.php} | 0 ...dsheet_Excel_WriterTestCase.php => WriterTestCase.php} | 0 test/bootstrap.php | 4 ---- 5 files changed, 7 insertions(+), 7 deletions(-) rename test/Test/Spreadsheet/Excel/Writer/{Test_Spreadsheet_Excel_Writer_WorkbookTest.php => WorkbookTest.php} (100%) rename test/Test/Spreadsheet/Excel/{Writer/Test_Spreadsheet_Excel_WriterTestCase.php => WriterTestCase.php} (100%) delete mode 100644 test/bootstrap.php diff --git a/composer.json b/composer.json index 2887d5f..7d140d7 100644 --- a/composer.json +++ b/composer.json @@ -23,8 +23,12 @@ ], "autoload": { "psr-0": { - "Spreadsheet": "./", - "Test": "./test" + "Spreadsheet": "" + } + }, + "autoload-dev": { + "psr-0": { + "Test": "test" } }, "description": "More info available on: http://pear.php.net/package/Spreadsheet_Excel_Writer", diff --git a/phpunit.xml.dist b/phpunit.xml.dist index d25b855..5c26d15 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,4 +1,4 @@ - Date: Thu, 16 Jun 2016 13:06:51 +0900 Subject: [PATCH 15/15] Additional tests with default version, and with formats --- .../Spreadsheet/Excel/Writer/WorkbookTest.php | 38 ++++++++++++++++++ test/fixture/example2.xls | Bin 0 -> 5120 bytes test/fixture/with_format.xls | Bin 0 -> 3584 bytes 3 files changed, 38 insertions(+) create mode 100644 test/fixture/example2.xls create mode 100644 test/fixture/with_format.xls diff --git a/test/Test/Spreadsheet/Excel/Writer/WorkbookTest.php b/test/Test/Spreadsheet/Excel/Writer/WorkbookTest.php index beb9a0e..a7416ef 100644 --- a/test/Test/Spreadsheet/Excel/Writer/WorkbookTest.php +++ b/test/Test/Spreadsheet/Excel/Writer/WorkbookTest.php @@ -34,4 +34,42 @@ class Test_Spreadsheet_Excel_Writer_WorkbookTest extends Test_Spreadsheet_Excel_ $this->assertSameAsInFixture('example.xls', $workbook); } + public function testWriteWithFormat() + { + $workbook = $this->getNewWorkbook(); + $workbook->setVersion(8); + + $format = $workbook->addFormat(); + $format->setFontFamily('Helvetica'); + $format->setSize(16); + $format->setVAlign('vcenter'); + $format->setBorder(1); + + $sheet = $workbook->addWorksheet('Example report'); + $sheet->setInputEncoding('utf-8'); + + $sheet->setColumn(0, 10, 35); + + $sheet->writeString(0, 0, "Test string", $format); + $sheet->setRow(0, 40); + + $sheet->writeString(1, 0, "こんにちわ"); + + $this->assertSameAsInFixture('with_format.xls', $workbook); + } + + public function testWithDefaultVersion() + { + $workbook = $this->getNewWorkbook(); + + $sheet = $workbook->addWorksheet("Example"); + + for ($i = 0; $i < 10; $i++) { + for ($j = 0; $j < 10; $j++) { + $sheet->write($i, $j, "Row $i $j"); + } + } + + $this->assertSameAsInFixture('example2.xls', $workbook); + } } diff --git a/test/fixture/example2.xls b/test/fixture/example2.xls new file mode 100644 index 0000000000000000000000000000000000000000..963ff0c84015bb5c4504d4dff1963b5cc1ca5963 GIT binary patch literal 5120 zcmeI#ON$(36b9h0?p5)YXlB%Cw2bC5i9)*Tj_6=8{(!7z8_))EG+_|bmF;aW3Inyw zPjKVPMQ5kbp#FnVT)1@O(vxI07UVpI39o{ZbaxgxbY!!XEJieU9<`WIaRX+IwckPwLwX>)03Y0nHfhTMhR zjogFWi`<7u7dV03k34{!MAndXzmY z9=U*QAQzEK$kWI(i1fFk>94s0S&CMUBDbA=m0Uqj_#s@!+(Y|iE(xx_ef{;D+pj#Q zP3+tkXLr_GG=RenTmBjCI1@Dcm#7Tyek^?nQ}n{ltJk;xu6pR?ymD%ucTc;eb3YHc zTjb(#?x^OGa)?dz<4Dr|?BPCiG>Xmf<>a*KWL(U(PSHuW6-%)x)hs2Z)UcGAQp-|iN}ZJO7af!))O#q7f6ydXy@%_u zDyiPXGi_B;z2{c?Nv?ViPrTJ$s`u~!T$NPs;qt9Ys`t<`tCH$HjG3#F>ZO6k(v*4` zT~{U5`$j*_Rqq@9G*`WE^i%46qo3xg_lePHwj^?}hB)CWdiP#+k5L49EK1@(c^7u1JFUs4|$eMx<2^d`pD=j>La7CsE>@kqCPVEih6m1jQX1T*ywBOW23LBkBz>jJ~sNA`q=1e>SLp? zsgI4mram_Mn)=x2YwG3Ychoo3Cq~~;pBQ~ZePZ+t^@-6p)F(#YP@fomLw#cO4fTo9 zH`FIa-%u~F?W4Y>J~jH5`qb!K>Qkd{sZWi*r9L(KmipA_Tk2DzZ>dj>zNJ1j`j&e6 z!7=JP>NBJ7sLzbPqdqhGj{3~#JL)r|@2Hm_xvMkkh>3S!Q_>MLGy0DD%;>wkdmc~T z&!yw*bQ%ZHmk7R`N=+Wh|Fr3vyMfP}E_YYm8(8kRcm5D@9oKXGB_fY%m+_rs!K1vS zi}~>4x9x4u?Js4&x%{BSbVbkq8aMvL{1`gIcz#(Pdj3O>dvpK%hy2(7swBUqrNyMH U$^&!!{V#RNFUZmK-@O9A0`TUwY5)KL literal 0 HcmV?d00001 diff --git a/test/fixture/with_format.xls b/test/fixture/with_format.xls new file mode 100644 index 0000000000000000000000000000000000000000..97e501571725325794be6b5e990fef8c7b31accb GIT binary patch literal 3584 zcmeHJ&1(};5dUqOv`K3}5?et*Sn5|*kjP#NqS=ZS&wgO8QL|DKZHYnjAg*6$#X?|@ z{SWjaf*#VFhXwUNh=SnJi#OZnZ)P`Xlw1lTlw{K1d-LYKH}g6(@6CStm~E}S-uDH6 z(J2gJ(_}E*CAY{Y+vBN-5!t3OMn)-u?0|NV2PA$8Vu+B~N(?3DBSf0W5TnExv5Ocd zCWuKwQXos@h~30AA-OQ1o#TN_no%51;oW#RvcULB?9VbIUL{X!T!Ht8YBTec0v3vi zSlAQxBsdp`hn?Bgx{Q8A%hUKXXut~@sSoXlmjuI<`#p49}OBOm4^z9LFLUMgsv zi5n?8Dk0;Gg1GV7`!XQYY&O~X2m*t^@mQWhgk10OXDElqaVQFDN`AtsKGmQ)#0od* zzL5Kk2@r5>0`8?=69#ZR11AhA=W0PfcvSBNXfzt&0yqH$4*!TiL7Bt76gOq zygc5~C7=4^l3$^oG#==~K8m*o9lQYvEcPao4oCf2fM&?0lE&Lq3PEpO~$wzaFB z_#K%joXtqfdF_02?(_V*g}9e>u6$^au4-aea81uqiGe VS0eddlZeT!5MHoB45&Xm@EcNwYJ>m) literal 0 HcmV?d00001