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