Reverted the bulk of recently itroduced breaking changes

This reverts commits 631bbb5f72, 3d299d9938, b3be543ba3.
This commit is contained in:
Alexey Kopytko 2016-06-16 11:35:47 +09:00
parent 923008d208
commit 85e4049be9
8 changed files with 996 additions and 1079 deletions

2
.gitignore vendored
View File

@ -1,5 +1,3 @@
# ide related
.idea
# composer related # composer related
composer.lock composer.lock
composer.phar composer.phar

View File

@ -31,7 +31,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * 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. * 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 * 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; $this->_filename = $filename;
parent::__construct($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 * @param string $filename The filename to use for HTTP headers
* @access public * @access public
*/ */
public function send($filename) function send($filename)
{ {
header('Content-type: application/vnd.ms-excel'); header("Content-type: application/vnd.ms-excel");
header('Content-Disposition: attachment; filename="' . $filename .'"'); header("Content-Disposition: attachment; filename=\"$filename\"");
header('Expires: 0'); header("Expires: 0");
header('Cache-Control: must-revalidate, post-check=0,pre-check=0'); header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
header('Pragma: public'); header("Pragma: public");
} }
/** /**
@ -76,26 +78,27 @@ class Spreadsheet_Excel_Writer extends Spreadsheet_Excel_Writer_Workbook
* @access public * @access public
* @static * @static
* @param integer $row Row for the cell to convert (0-indexed). * @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 * @return string The cell identifier in A1 format
*/ */
public function rowcolToCell($row, $column) function rowcolToCell($row, $col)
{ {
if ($column > 255) { //maximum column value exceeded if ($col > 255) { //maximum column value exceeded
return new PEAR_Error('Maximum column value exceeded: ' . $column); return new PEAR_Error("Maximum column value exceeded: $col");
} }
$int = (int)($column / 26); $int = (int)($col / 26);
$frac = $column % 26; $frac = $col % 26;
$chr1 = ''; $chr1 = '';
if ($int > 0) { if ($int > 0) {
$chr1 = chr(ord('A') + $int - 1); $chr1 = chr(ord('A') + $int - 1);
} }
$chr2 = chr(ord('A') + $frac); $chr2 = chr(ord('A') + $frac);
++$row; $row++;
return $chr1 . $chr2 . $row; return $chr1 . $chr2 . $row;
} }
} }
?>

View File

@ -32,6 +32,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
require_once 'PEAR.php';
/** /**
* Class for writing Excel BIFF records. * Class for writing Excel BIFF records.
* *
@ -55,59 +57,59 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR
* The BIFF/Excel version (5). * The BIFF/Excel version (5).
* @var integer * @var integer
*/ */
public $BIFF_version = 0x0500; var $_BIFF_version = 0x0500;
/** /**
* The byte order of this architecture. 0 => little endian, 1 => big endian * The byte order of this architecture. 0 => little endian, 1 => big endian
* @var integer * @var integer
*/ */
public $byteOrder; var $_byte_order;
/** /**
* The string containing the data of the BIFF stream * The string containing the data of the BIFF stream
* @var string * @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 * @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 * @var integer
* @see addContinue() * @see _addContinue()
*/ */
public $limit; var $_limit;
/** /**
* The temporary dir for storing the OLE file * The temporary dir for storing the OLE file
* @var string * @var string
*/ */
public $temporaryDirectory; var $_tmp_dir;
/** /**
* The temporary file for storing the OLE file * The temporary file for storing the OLE file
* @var string * @var string
*/ */
public $temporaryFile; var $_tmp_file;
/** /**
* Constructor * Constructor
* *
* @access public * @access public
*/ */
public function __construct() function Spreadsheet_Excel_Writer_BIFFwriter()
{ {
$this->byteOrder = ''; $this->_byte_order = '';
$this->data = ''; $this->_data = '';
$this->dataSize = 0; $this->_datasize = 0;
$this->limit = 2080; $this->_limit = 2080;
$this->temporaryDirectory = ''; $this->_tmp_dir = '';
// Set the byte order // Set the byte order
$this->setByteOrder(); $this->_setByteOrder();
} }
/** /**
@ -116,23 +118,21 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR
* *
* @access private * @access private
*/ */
protected function setByteOrder() function _setByteOrder()
{ {
// Check if "pack" gives the required IEEE 64bit float // Check if "pack" gives the required IEEE 64bit float
$testString = pack('d', 1.2345); $teststr = pack("d", 1.2345);
$number = pack('C8', 0x8D, 0x97, 0x6E, 0x12, 0x83, 0xC0, 0xF3, 0x3F); $number = pack("C8", 0x8D, 0x97, 0x6E, 0x12, 0x83, 0xC0, 0xF3, 0x3F);
if ($number == $teststr) {
if ($number == $testString) {
$byte_order = 0; // Little Endian $byte_order = 0; // Little Endian
} elseif ($number == strrev($testString)){ } elseif ($number == strrev($teststr)){
$byte_order = 1; // Big Endian $byte_order = 1; // Big Endian
} else { } else {
// Give up. I'll fix this in a later version. // Give up. I'll fix this in a later version.
return $this->raiseError('Required floating point format ' . return $this->raiseError("Required floating point format ".
'not supported on this platform.'); "not supported on this platform.");
} }
$this->_byte_order = $byte_order;
$this->byteOrder = $byte_order;
} }
/** /**
@ -141,14 +141,13 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR
* @param string $data binary data to prepend * @param string $data binary data to prepend
* @access private * @access private
*/ */
protected function prepend($data) function _prepend($data)
{ {
if (strlen($data) > $this->limit) { if (strlen($data) > $this->_limit) {
$data = $this->addContinue($data); $data = $this->_addContinue($data);
} }
$this->_data = $data.$this->_data;
$this->data = $data . $this->data; $this->_datasize += strlen($data);
$this->dataSize += strlen($data);
} }
/** /**
@ -157,14 +156,13 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR
* @param string $data binary data to append * @param string $data binary data to append
* @access private * @access private
*/ */
protected function append($data) function _append($data)
{ {
if (strlen($data) > $this->limit) { if (strlen($data) > $this->_limit) {
$data = $this->addContinue($data); $data = $this->_addContinue($data);
} }
$this->_data = $this->_data.$data;
$this->data = $this->data . $data; $this->_datasize += strlen($data);
$this->dataSize += strlen($data);
} }
/** /**
@ -175,28 +173,28 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR
* 0x0010 Worksheet. * 0x0010 Worksheet.
* @access private * @access private
*/ */
protected function storeBof($type) function _storeBof($type)
{ {
$record = 0x0809; // Record identifier $record = 0x0809; // Record identifier
// According to the SDK $build and $year should be set to zero. // According to the SDK $build and $year should be set to zero.
// However, this throws a warning in Excel 5. So, use magic numbers. // However, this throws a warning in Excel 5. So, use magic numbers.
if ($this->BIFF_version == 0x0500) { if ($this->_BIFF_version == 0x0500) {
$length = 0x0008; $length = 0x0008;
$unknown = ''; $unknown = '';
$build = 0x096C; $build = 0x096C;
$year = 0x07C9; $year = 0x07C9;
} elseif ($this->BIFF_version == 0x0600) { } elseif ($this->_BIFF_version == 0x0600) {
$length = 0x0010; $length = 0x0010;
$unknown = pack("VV", 0x00000041, 0x00000006); //unknown last 8 bytes for BIFF8 $unknown = pack("VV", 0x00000041, 0x00000006); //unknown last 8 bytes for BIFF8
$build = 0x0DBB; $build = 0x0DBB;
$year = 0x07CC; $year = 0x07CC;
} }
$version = $this->BIFF_version; $version = $this->_BIFF_version;
$header = pack('vv', $record, $length); $header = pack("vv", $record, $length);
$data = pack('vvvv', $version, $type, $build, $year); $data = pack("vvvv", $version, $type, $build, $year);
$this->prepend($header . $data . $unknown); $this->_prepend($header . $data . $unknown);
} }
/** /**
@ -204,12 +202,12 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR
* *
* @access private * @access private
*/ */
protected function storeEof() function _storeEof()
{ {
$record = 0x000A; // Record identifier $record = 0x000A; // Record identifier
$length = 0x0000; // Number of bytes to follow $length = 0x0000; // Number of bytes to follow
$header = pack('vv', $record, $length); $header = pack("vv", $record, $length);
$this->append($header); $this->_append($header);
} }
/** /**
@ -224,16 +222,16 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR
* @return string A very convenient string of continue blocks * @return string A very convenient string of continue blocks
* @access private * @access private
*/ */
protected function addContinue($data) function _addContinue($data)
{ {
$limit = $this->limit; $limit = $this->_limit;
$record = 0x003C; // Record identifier $record = 0x003C; // Record identifier
// The first 2080/8224 bytes remain intact. However, we have to change // The first 2080/8224 bytes remain intact. However, we have to change
// the length field of the record. // 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. // Retrieve chunks of 2080/8224 bytes +4 for the header.
$data_length = strlen($data); $data_length = strlen($data);
@ -243,7 +241,7 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR
} }
// Retrieve the last chunk of data // Retrieve the last chunk of data
$header = pack('vv', $record, strlen($data) - $i); $header = pack("vv", $record, strlen($data) - $i);
$tmp .= $header; $tmp .= $header;
$tmp .= substr($data, $i, strlen($data) - $i); $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 * @param string $dir The dir to be used as temp dir
* @return true if given dir is valid, false otherwise * @return true if given dir is valid, false otherwise
*/ */
protected function setTempDir($dir) function setTempDir($dir)
{ {
if (is_dir($dir)) { if (is_dir($dir)) {
$this->temporaryDirectory = $dir; $this->_tmp_dir = $dir;
return true; return true;
} }
return false; return false;
} }
} }
?>

View File

@ -32,6 +32,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
require_once 'PEAR.php';
/** /**
* Class for generating Excel XF records (formats) * Class for generating Excel XF records (formats)
* *
@ -42,219 +44,212 @@
class Spreadsheet_Excel_Writer_Format extends PEAR 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. * The index given by the workbook when creating a new format.
* @var integer * @var integer
*/ */
public $_xf_index; var $_xf_index;
/**
* Index to the FONT record.
* @var integer
*/
var $font_index;
/** /**
* The font name (ASCII). * The font name (ASCII).
* @var string * @var string
*/ */
public $_font_name; var $_font_name;
/** /**
* Height of font (1/20 of a point) * Height of font (1/20 of a point)
* @var integer * @var integer
*/ */
public $_size; var $_size;
/** /**
* Bold style * Bold style
* @var integer * @var integer
*/ */
public $_bold; var $_bold;
/** /**
* Bit specifiying if the font is italic. * Bit specifiying if the font is italic.
* @var integer * @var integer
*/ */
public $_italic; var $_italic;
/** /**
* Index to the cell's color * Index to the cell's color
* @var integer * @var integer
*/ */
public $_color; var $_color;
/** /**
* The text underline property * The text underline property
* @var integer * @var integer
*/ */
public $_underline; var $_underline;
/** /**
* Bit specifiying if the font has strikeout. * Bit specifiying if the font has strikeout.
* @var integer * @var integer
*/ */
public $_font_strikeout; var $_font_strikeout;
/** /**
* Bit specifiying if the font has outline. * Bit specifiying if the font has outline.
* @var integer * @var integer
*/ */
public $_font_outline; var $_font_outline;
/** /**
* Bit specifiying if the font has shadow. * Bit specifiying if the font has shadow.
* @var integer * @var integer
*/ */
public $_font_shadow; var $_font_shadow;
/** /**
* 2 bytes specifiying the script type for the font. * 2 bytes specifiying the script type for the font.
* @var integer * @var integer
*/ */
public $_font_script; var $_font_script;
/** /**
* Byte specifiying the font family. * Byte specifiying the font family.
* @var integer * @var integer
*/ */
public $_font_family; var $_font_family;
/** /**
* Byte specifiying the font charset. * Byte specifiying the font charset.
* @var integer * @var integer
*/ */
public $_font_charset; var $_font_charset;
/** /**
* An index (2 bytes) to a FORMAT record (number format). * An index (2 bytes) to a FORMAT record (number format).
* @var integer * @var integer
*/ */
public $_num_format; var $_num_format;
/** /**
* Bit specifying if formulas are hidden. * Bit specifying if formulas are hidden.
* @var integer * @var integer
*/ */
public $_hidden; var $_hidden;
/** /**
* Bit specifying if the cell is locked. * Bit specifying if the cell is locked.
* @var integer * @var integer
*/ */
public $_locked; var $_locked;
/** /**
* The three bits specifying the text horizontal alignment. * The three bits specifying the text horizontal alignment.
* @var integer * @var integer
*/ */
public $_text_h_align; var $_text_h_align;
/** /**
* Bit specifying if the text is wrapped at the right border. * Bit specifying if the text is wrapped at the right border.
* @var integer * @var integer
*/ */
public $_text_wrap; var $_text_wrap;
/** /**
* The three bits specifying the text vertical alignment. * The three bits specifying the text vertical alignment.
* @var integer * @var integer
*/ */
public $_text_v_align; var $_text_v_align;
/** /**
* 1 bit, apparently not used. * 1 bit, apparently not used.
* @var integer * @var integer
*/ */
public $_text_justlast; var $_text_justlast;
/** /**
* The two bits specifying the text rotation. * The two bits specifying the text rotation.
* @var integer * @var integer
*/ */
public $_rotation; var $_rotation;
/** /**
* The cell's foreground color. * The cell's foreground color.
* @var integer * @var integer
*/ */
public $_fg_color; var $_fg_color;
/** /**
* The cell's background color. * The cell's background color.
* @var integer * @var integer
*/ */
public $_bg_color; var $_bg_color;
/** /**
* The cell's background fill pattern. * The cell's background fill pattern.
* @var integer * @var integer
*/ */
public $_pattern; var $_pattern;
/** /**
* Style of the bottom border of the cell * Style of the bottom border of the cell
* @var integer * @var integer
*/ */
public $_bottom; var $_bottom;
/** /**
* Color of the bottom border of the cell. * Color of the bottom border of the cell.
* @var integer * @var integer
*/ */
public $_bottom_color; var $_bottom_color;
/** /**
* Style of the top border of the cell * Style of the top border of the cell
* @var integer * @var integer
*/ */
public $_top; var $_top;
/** /**
* Color of the top border of the cell. * Color of the top border of the cell.
* @var integer * @var integer
*/ */
public $_top_color; var $_top_color;
/** /**
* Style of the left border of the cell * Style of the left border of the cell
* @var integer * @var integer
*/ */
public $_left; var $_left;
/** /**
* Color of the left border of the cell. * Color of the left border of the cell.
* @var integer * @var integer
*/ */
public $_left_color; var $_left_color;
/** /**
* Style of the right border of the cell * Style of the right border of the cell
* @var integer * @var integer
*/ */
public $_right; var $_right;
/** /**
* Color of the right border of the cell. * Color of the right border of the cell.
* @var integer * @var integer
*/ */
public $_right_color; var $_right_color;
/** /**
* Constructor * Constructor
* *
* @access private * @access private
* @param integer $BIFF_version
* @param integer $index the XF index for the format. * @param integer $index the XF index for the format.
* @param array $properties array with properties to be set on initialization. * @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->_xf_index = $index;
$this->_BIFF_version = $BIFF_version; $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'). * @param string $style The type of the XF record ('style' or 'cell').
* @return string The XF record * @return string The XF record
*/ */
public function getXf($style) function getXf($style)
{ {
// Set the type of the XF record and some of the attributes. // Set the type of the XF record and some of the attributes.
if ($style == 'style') { if ($style == 'style') {
@ -449,7 +444,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR
* *
* @return string The FONT record * @return string The FONT record
*/ */
public function getFont() function getFont()
{ {
$dyHeight = $this->_size * 20; // Height of font (1/20 of a point) $dyHeight = $this->_size * 20; // Height of font (1/20 of a point)
$icv = $this->_color; // Index to color palette $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. * 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 * 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 * 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 * @return string A key for this font
*/ */
public function getFontKey() function getFontKey()
{ {
$key = "$this->_font_name$this->_size"; $key = "$this->_font_name$this->_size";
$key .= "$this->_font_script$this->_underline"; $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 * @return integer The index for the XF record
*/ */
public function getXfIndex() function getXfIndex()
{ {
return($this->_xf_index); 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. * @param string $name_color name of the color (i.e.: 'blue', 'red', etc..). Optional.
* @return integer The color index * @return integer The color index
*/ */
protected function _getColor($name_color = '') function _getColor($name_color = '')
{ {
$colors = array( $colors = array(
'aqua' => 0x07, 'aqua' => 0x07,
@ -588,7 +583,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR
* @access public * @access public
* @param string $location alignment for the cell ('left', 'right', etc...). * @param string $location alignment for the cell ('left', 'right', etc...).
*/ */
public function setAlign($location) function setAlign($location)
{ {
if (preg_match("/\d/",$location)) { if (preg_match("/\d/",$location)) {
return; // Ignore numbers return; // Ignore numbers
@ -646,7 +641,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR
* @access public * @access public
* @param string $location alignment for the cell ('left', 'right', etc...). * @param string $location alignment for the cell ('left', 'right', etc...).
*/ */
public function setHAlign($location) function setHAlign($location)
{ {
if (preg_match("/\d/",$location)) { if (preg_match("/\d/",$location)) {
return; // Ignore numbers return; // Ignore numbers
@ -686,7 +681,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR
* @access public * @access public
* @param string $location alignment for the cell ('top', 'vleft', 'vright', etc...). * @param string $location alignment for the cell ('top', 'vleft', 'vright', etc...).
*/ */
public function setVAlign($location) function setVAlign($location)
{ {
if (preg_match("/\d/",$location)) { if (preg_match("/\d/",$location)) {
return; // Ignore numbers return; // Ignore numbers
@ -719,7 +714,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR
* *
* @access public * @access public
*/ */
public function setMerge() function setMerge()
{ {
$this->setAlign('merge'); $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. 1 maps to 700 (bold text). Valid range is: 100-1000.
It's Optional, default is 1 (bold). It's Optional, default is 1 (bold).
*/ */
public function setBold($weight = 1) function setBold($weight = 1)
{ {
if ($weight == 1) { if ($weight == 1) {
$weight = 0x2BC; // Bold text $weight = 0x2BC; // Bold text
@ -762,7 +757,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR
* @access public * @access public
* @param integer $style style of the cell border. 1 => thin, 2 => thick. * @param integer $style style of the cell border. 1 => thin, 2 => thick.
*/ */
public function setBottom($style) function setBottom($style)
{ {
$this->_bottom = $style; $this->_bottom = $style;
} }
@ -773,7 +768,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR
* @access public * @access public
* @param integer $style style of the cell top border. 1 => thin, 2 => thick. * @param integer $style style of the cell top border. 1 => thin, 2 => thick.
*/ */
public function setTop($style) function setTop($style)
{ {
$this->_top = $style; $this->_top = $style;
} }
@ -784,7 +779,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR
* @access public * @access public
* @param integer $style style of the cell left border. 1 => thin, 2 => thick. * @param integer $style style of the cell left border. 1 => thin, 2 => thick.
*/ */
public function setLeft($style) function setLeft($style)
{ {
$this->_left = $style; $this->_left = $style;
} }
@ -795,7 +790,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR
* @access public * @access public
* @param integer $style style of the cell right border. 1 => thin, 2 => thick. * @param integer $style style of the cell right border. 1 => thin, 2 => thick.
*/ */
public function setRight($style) function setRight($style)
{ {
$this->_right = $style; $this->_right = $style;
} }
@ -807,7 +802,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR
* @access public * @access public
* @param integer $style style to apply for all cell borders. 1 => thin, 2 => thick. * @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->setBottom($style);
$this->setTop($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'), * @param mixed $color The color we are setting. Either a string (like 'blue'),
* or an integer (range is [8...63]). * or an integer (range is [8...63]).
*/ */
public function setBorderColor($color) function setBorderColor($color)
{ {
$this->setBottomColor($color); $this->setBottomColor($color);
$this->setTopColor($color); $this->setTopColor($color);
@ -841,7 +836,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR
* @access public * @access public
* @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]). * @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); $value = $this->_getColor($color);
$this->_bottom_color = $value; $this->_bottom_color = $value;
@ -853,7 +848,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR
* @access public * @access public
* @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]). * @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); $value = $this->_getColor($color);
$this->_top_color = $value; $this->_top_color = $value;
@ -865,7 +860,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR
* @access public * @access public
* @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]). * @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); $value = $this->_getColor($color);
$this->_left_color = $value; $this->_left_color = $value;
@ -877,7 +872,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR
* @access public * @access public
* @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]). * @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); $value = $this->_getColor($color);
$this->_right_color = $value; $this->_right_color = $value;
@ -890,7 +885,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR
* @access public * @access public
* @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]). * @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); $value = $this->_getColor($color);
$this->_fg_color = $value; $this->_fg_color = $value;
@ -905,7 +900,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR
* @access public * @access public
* @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]). * @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); $value = $this->_getColor($color);
$this->_bg_color = $value; $this->_bg_color = $value;
@ -920,7 +915,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR
* @access public * @access public
* @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]). * @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); $value = $this->_getColor($color);
$this->_color = $value; $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, * @param integer $arg Optional. Defaults to 1. Meaningful values are: 0-18,
* 0 meaning no background. * 0 meaning no background.
*/ */
public function setPattern($arg = 1) function setPattern($arg = 1)
{ {
$this->_pattern = $arg; $this->_pattern = $arg;
} }
@ -945,7 +940,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR
* @param integer $underline The value for underline. Possible values are: * @param integer $underline The value for underline. Possible values are:
* 1 => underline, 2 => double underline. * 1 => underline, 2 => double underline.
*/ */
public function setUnderline($underline) function setUnderline($underline)
{ {
$this->_underline = $underline; $this->_underline = $underline;
} }
@ -955,7 +950,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR
* *
* @access public * @access public
*/ */
public function setItalic() function setItalic()
{ {
$this->_italic = 1; $this->_italic = 1;
} }
@ -966,7 +961,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR
* @access public * @access public
* @param integer $size The font size (in pixels I think). * @param integer $size The font size (in pixels I think).
*/ */
public function setSize($size) function setSize($size)
{ {
$this->_size = $size; $this->_size = $size;
} }
@ -976,7 +971,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR
* *
* @access public * @access public
*/ */
public function setTextWrap() function setTextWrap()
{ {
$this->_text_wrap = 1; $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 * @param integer $angle The rotation angle for the text (clockwise). Possible
values are: 0, 90, 270 and -1 for stacking top-to-bottom. values are: 0, 90, 270 and -1 for stacking top-to-bottom.
*/ */
public function setTextRotation($angle) function setTextRotation($angle)
{ {
switch ($angle) switch ($angle)
{ {
@ -1032,7 +1027,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR
* @access public * @access public
* @param integer $num_format The numeric format. * @param integer $num_format The numeric format.
*/ */
public function setNumFormat($num_format) function setNumFormat($num_format)
{ {
$this->_num_format = $num_format; $this->_num_format = $num_format;
} }
@ -1042,7 +1037,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR
* *
* @access public * @access public
*/ */
public function setStrikeOut() function setStrikeOut()
{ {
$this->_font_strikeout = 1; $this->_font_strikeout = 1;
} }
@ -1052,7 +1047,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR
* *
* @access public * @access public
*/ */
public function setOutLine() function setOutLine()
{ {
$this->_font_outline = 1; $this->_font_outline = 1;
} }
@ -1062,7 +1057,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR
* *
* @access public * @access public
*/ */
public function setShadow() function setShadow()
{ {
$this->_font_shadow = 1; $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: * @param integer $script The value for script type. Possible values are:
* 1 => superscript, 2 => subscript. * 1 => superscript, 2 => subscript.
*/ */
public function setScript($script) function setScript($script)
{ {
$this->_font_script = $script; $this->_font_script = $script;
} }
@ -1084,7 +1079,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR
* *
* @access public * @access public
*/ */
public function setLocked() function setLocked()
{ {
$this->_locked = 1; $this->_locked = 1;
} }
@ -1094,7 +1089,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR
* *
* @access public * @access public
*/ */
public function setUnLocked() function setUnLocked()
{ {
$this->_locked = 0; $this->_locked = 0;
} }
@ -1103,10 +1098,10 @@ class Spreadsheet_Excel_Writer_Format extends PEAR
* Sets the font family name. * Sets the font family name.
* *
* @access public * @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'. * 'Times New Roman', 'Arial', 'Courier'.
*/ */
public function setFontFamily($font_family) function setFontFamily($font_family)
{ {
$this->_font_name = $font_family; $this->_font_name = $font_family;
} }

View File

@ -25,77 +25,79 @@
/** /**
* @const SPREADSHEET_EXCEL_WRITER_ADD token identifier for character "+" * @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 "-" * @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 "*" * @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 "/" * @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 "(" * @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 ")" * @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 "," * @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 ";" * @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 ">" * @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 "<" * @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 "<=" * @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 ">=" * @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 "=" * @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 "<>" * @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 "&" * * @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 * Class for parsing Excel formulas
@ -107,73 +109,67 @@ define('SPREADSHEET_EXCEL_WRITER_CONCAT', '&');
class Spreadsheet_Excel_Writer_Parser extends PEAR 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 * The index of the character we are currently looking at
* @var integer * @var integer
*/ */
public $_current_char; var $_current_char;
/** /**
* The token we are working on. * The token we are working on.
* @var string * @var string
*/ */
public $_current_token; var $_current_token;
/** /**
* The formula to parse * The formula to parse
* @var string * @var string
*/ */
public $_formula; var $_formula;
/**
* @var array
*/
public $_functions;
/** /**
* The character ahead of the current char * The character ahead of the current char
* @var string * @var string
*/ */
public $_lookahead; var $_lookahead;
/** /**
* The parse tree to be generated * The parse tree to be generated
* @var string * @var string
*/ */
public $_parse_tree; var $_parse_tree;
/** /**
* The byte order. 1 => big endian, 0 => little endian. * The byte order. 1 => big endian, 0 => little endian.
* @var integer * @var integer
*/ */
public $_byte_order; var $_byte_order;
/** /**
* Array of external sheets * Array of external sheets
* @var array * @var array
*/ */
public $_ext_sheets; var $_ext_sheets;
/** /**
* Array of sheet references in the form of REF structures * Array of sheet references in the form of REF structures
* @var array * @var array
*/ */
public $_references; var $_references;
/**
* The BIFF version for the workbook
* @var integer
*/
var $_BIFF_version;
/** /**
* The class constructor * The class constructor
* *
* @param integer $byte_order The byte order (Little endian or Big endian) of the architecture * @param integer $byte_order The byte order (Little endian or Big endian) of the architecture
* (optional). 1 => big endian, 0 (default) little endian. (optional). 1 => big endian, 0 (default) little endian.
* @param integer $biff_version
*/ */
public function __construct($byte_order, $biff_version) function Spreadsheet_Excel_Writer_Parser($byte_order, $biff_version)
{ {
$this->_current_char = 0; $this->_current_char = 0;
$this->_BIFF_version = $biff_version; $this->_BIFF_version = $biff_version;
@ -192,7 +188,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR
* *
* @access private * @access private
*/ */
protected function _initializeHashes() function _initializeHashes()
{ {
// The Excel ptg indices // The Excel ptg indices
$this->ptg = array( $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 * @return mixed the converted token on success. PEAR_Error if the token
* is not recognized * is not recognized
*/ */
protected function _convert($token) function _convert($token)
{ {
if (preg_match("/^\"[^\"]{0,255}\"$/", $token)) { if (preg_match("/^\"[^\"]{0,255}\"$/", $token)) {
return $this->_convertString($token); return $this->_convertString($token);
@ -603,9 +599,8 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR
* *
* @access private * @access private
* @param mixed $num an integer or double for conversion to its ptg value * @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 // Integer in the range 0..2**16-1
if ((preg_match("/^\d+$/", $num)) and ($num <= 65535)) { 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 * @return mixed the converted token on success. PEAR_Error if the string
* is longer than 255 characters. * is longer than 255 characters.
*/ */
protected function _convertString($string) function _convertString($string)
{ {
// chop away beggining and ending quotes // chop away beggining and ending quotes
$string = substr($string, 1, strlen($string) - 2); $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. * @param integer $num_args The number of arguments the function receives.
* @return string The packed ptg for the function * @return string The packed ptg for the function
*/ */
protected function _convertFunction($token, $num_args) function _convertFunction($token, $num_args)
{ {
$args = $this->_functions[$token][1]; $args = $this->_functions[$token][1];
$volatile = $this->_functions[$token][3]; $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. * Convert an Excel range such as A1:D4 to a ptgRefV.
* *
* @access private * @access private
* @param string $range An Excel range in the A1:A2 or A1..A2 format. * @param string $range An Excel range in the A1:A2 or A1..A2 format.
* @param int $class */
* @return array|string function _convertRange2d($range, $class=0)
*/
protected function _convertRange2d($range, $class=0)
{ {
// TODO: possible class value 0,1,2 check Formula.pm // 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. * @param string $token An Excel range in the Sheet1!A1:A2 format.
* @return mixed The packed ptgArea3d token on success, PEAR_Error on failure. * @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. $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 * @param string $cell An Excel cell reference
* @return string The cell in packed() format with the corresponding ptg * @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. $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 * @param string $cell An Excel cell reference
* @return mixed The packed ptgRef3d token on success, PEAR_Error on failure. * @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. $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 * @param string $ext_ref The name of the external reference
* @return string The reference index in packed() format * @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 leading ' if any.
$ext_ref = preg_replace("/'$/", '', $ext_ref); // Remove trailing ' 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, * @return mixed The reference index in packed() format on success,
* PEAR_Error on failure * 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 leading ' if any.
$ext_ref = preg_replace("/'$/", '', $ext_ref); // Remove trailing ' 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 * @access private
* @return integer The sheet index, -1 if the sheet was not found * @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])) { if (!isset($this->_ext_sheets[$sheet_name])) {
return -1; return -1;
@ -988,7 +981,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR
* @param string $name The name of the worksheet being added * @param string $name The name of the worksheet being added
* @param integer $index The index 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; $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 * @param string $cell The Excel cell reference to be packed
* @return array Array containing the row and column in packed() format * @return array Array containing the row and column in packed() format
*/ */
protected function _cellToPackedRowcol($cell) function _cellToPackedRowcol($cell)
{ {
$cell = strtoupper($cell); $cell = strtoupper($cell);
list($row, $col, $row_rel, $col_rel) = $this->_cellToRowcol($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 * @param string $range The Excel range to be packed
* @return array Array containing (row1,col1,row2,col2) in packed() format * @return array Array containing (row1,col1,row2,col2) in packed() format
*/ */
protected function _rangeToPackedRange($range) function _rangeToPackedRange($range)
{ {
preg_match('/(\$)?(\d+)\:(\$)?(\d+)/', $range, $match); preg_match('/(\$)?(\d+)\:(\$)?(\d+)/', $range, $match);
// return absolute rows if there is a $ in the ref // 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. * @param string $cell The Excel cell reference in A1 format.
* @return array * @return array
*/ */
protected function _cellToRowcol($cell) function _cellToRowcol($cell)
{ {
preg_match('/(\$)?([A-I]?[A-Z])(\$)?(\d+)/',$cell,$match); preg_match('/(\$)?([A-I]?[A-Z])(\$)?(\d+)/',$cell,$match);
// return absolute column if there is a $ in the ref // return absolute column if there is a $ in the ref
@ -1112,7 +1105,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR
* *
* @access private * @access private
*/ */
protected function _advance() function _advance()
{ {
$i = $this->_current_char; $i = $this->_current_char;
$formula_length = strlen($this->_formula); $formula_length = strlen($this->_formula);
@ -1162,7 +1155,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR
* @param mixed $token The token to check. * @param mixed $token The token to check.
* @return mixed The checked token or false on failure * @return mixed The checked token or false on failure
*/ */
protected function _match($token) function _match($token)
{ {
switch($token) { switch($token) {
case SPREADSHEET_EXCEL_WRITER_ADD: case SPREADSHEET_EXCEL_WRITER_ADD:
@ -1293,7 +1286,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR
* sign (=). * sign (=).
* @return mixed true on success, PEAR_Error on failure * @return mixed true on success, PEAR_Error on failure
*/ */
public function parse($formula) function parse($formula)
{ {
$this->_current_char = 0; $this->_current_char = 0;
$this->_formula = $formula; $this->_formula = $formula;
@ -1313,7 +1306,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR
* @access private * @access private
* @return mixed The parsed ptg'd tree on success, PEAR_Error on failure * @return mixed The parsed ptg'd tree on success, PEAR_Error on failure
*/ */
protected function _condition() function _condition()
{ {
$result = $this->_expression(); $result = $this->_expression();
if (PEAR::isError($result)) { if (PEAR::isError($result)) {
@ -1381,7 +1374,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR
* @access private * @access private
* @return mixed The parsed ptg'd tree on success, PEAR_Error on failure * @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 it's a string return a string node
if (preg_match("/^\"[^\"]{0,255}\"$/", $this->_current_token)) { if (preg_match("/^\"[^\"]{0,255}\"$/", $this->_current_token)) {
@ -1429,7 +1422,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR
* @see _fact() * @see _fact()
* @return array The parsed ptg'd tree * @return array The parsed ptg'd tree
*/ */
protected function _parenthesizedExpression() function _parenthesizedExpression()
{ {
$result = $this->_createTree('ptgParen', $this->_expression(), ''); $result = $this->_createTree('ptgParen', $this->_expression(), '');
return $result; return $result;
@ -1442,7 +1435,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR
* @access private * @access private
* @return mixed The parsed ptg'd tree on success, PEAR_Error on failure * @return mixed The parsed ptg'd tree on success, PEAR_Error on failure
*/ */
protected function _term() function _term()
{ {
$result = $this->_fact(); $result = $this->_fact();
if (PEAR::isError($result)) { if (PEAR::isError($result)) {
@ -1481,7 +1474,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR
* @access private * @access private
* @return mixed The parsed ptg'd tree on success, PEAR_Error on failure * @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) { if ($this->_current_token == SPREADSHEET_EXCEL_WRITER_OPEN) {
$this->_advance(); // eat the "(" $this->_advance(); // eat the "("
@ -1559,7 +1552,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR
* @access private * @access private
* @return mixed The parsed ptg'd tree on success, PEAR_Error on failure * @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 $num_args = 0; // number of arguments received
$function = strtoupper($this->_current_token); $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. * @param mixed $right The right array (sub-tree) or a final node.
* @return array A tree * @return array A tree
*/ */
protected function _createTree($value, $left, $right) function _createTree($value, $left, $right)
{ {
return array('value' => $value, 'left' => $left, 'right' => $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. * @param array $tree The optional tree to convert.
* @return string The tree in reverse polish notation * @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 $polish = ""; // the string we are going to return
if (empty($tree)) { // If it's the first call use _parse_tree if (empty($tree)) { // If it's the first call use _parse_tree

View File

@ -22,19 +22,21 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
//require_once('PEAR.php');
// Possible operator types // Possible operator types
/* /*
FIXME: change prefixes FIXME: change prefixes
*/ */
define('OP_BETWEEN', 0x00); define("OP_BETWEEN", 0x00);
define('OP_NOTBETWEEN', 0x01); define("OP_NOTBETWEEN", 0x01);
define('OP_EQUAL', 0x02); define("OP_EQUAL", 0x02);
define('OP_NOTEQUAL', 0x03); define("OP_NOTEQUAL", 0x03);
define('OP_GT', 0x04); define("OP_GT", 0x04);
define('OP_LT', 0x05); define("OP_LT", 0x05);
define('OP_GTE', 0x06); define("OP_GTE", 0x06);
define('OP_LTE', 0x07); define("OP_LTE", 0x07);
/** /**
* Baseclass for generating Excel DV records (validations) * Baseclass for generating Excel DV records (validations)
@ -45,27 +47,27 @@ define('OP_LTE', 0x07);
*/ */
class Spreadsheet_Excel_Writer_Validator class Spreadsheet_Excel_Writer_Validator
{ {
public $_type; var $_type;
public $_style; var $_style;
public $_fixedList; var $_fixedList;
public $_blank; var $_blank;
public $_incell; var $_incell;
public $_showprompt; var $_showprompt;
public $_showerror; var $_showerror;
public $_title_prompt; var $_title_prompt;
public $_descr_prompt; var $_descr_prompt;
public $_title_error; var $_title_error;
public $_descr_error; var $_descr_error;
public $_operator; var $_operator;
public $_formula1; var $_formula1;
public $_formula2; var $_formula2;
/** /**
* The parser from the workbook. Used to parse validation formulas also * The parser from the workbook. Used to parse validation formulas also
* @var Spreadsheet_Excel_Writer_Parser * @var Spreadsheet_Excel_Writer_Parser
*/ */
public $_parser; var $_parser;
public function __construct($parser) function Spreadsheet_Excel_Writer_Validator(&$parser)
{ {
$this->_parser = $parser; $this->_parser = $parser;
$this->_type = 0x01; // FIXME: add method for setting datatype $this->_type = 0x01; // FIXME: add method for setting datatype
@ -84,41 +86,41 @@ class Spreadsheet_Excel_Writer_Validator
$this->_formula2 = ''; $this->_formula2 = '';
} }
public function setPrompt($promptTitle = "\x00", $promptDescription = "\x00", $showPrompt = true) function setPrompt($promptTitle = "\x00", $promptDescription = "\x00", $showPrompt = true)
{ {
$this->_showprompt = $showPrompt; $this->_showprompt = $showPrompt;
$this->_title_prompt = $promptTitle; $this->_title_prompt = $promptTitle;
$this->_descr_prompt = $promptDescription; $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->_showerror = $showError;
$this->_title_error = $errorTitle; $this->_title_error = $errorTitle;
$this->_descr_error = $errorDescription; $this->_descr_error = $errorDescription;
} }
public function allowBlank() function allowBlank()
{ {
$this->_blank = true; $this->_blank = true;
} }
public function onInvalidStop() function onInvalidStop()
{ {
$this->_style = 0x00; $this->_style = 0x00;
} }
public function onInvalidWarn() function onInvalidWarn()
{ {
$this->_style = 0x01; $this->_style = 0x01;
} }
public function onInvalidInfo() function onInvalidInfo()
{ {
$this->_style = 0x02; $this->_style = 0x02;
} }
public function setFormula1($formula) function setFormula1($formula)
{ {
// Parse the formula using the parser in Parser.php // Parse the formula using the parser in Parser.php
$error = $this->_parser->parse($formula); $error = $this->_parser->parse($formula);
@ -133,7 +135,7 @@ class Spreadsheet_Excel_Writer_Validator
return true; return true;
} }
public function setFormula2($formula) function setFormula2($formula)
{ {
// Parse the formula using the parser in Parser.php // Parse the formula using the parser in Parser.php
$error = $this->_parser->parse($formula); $error = $this->_parser->parse($formula);
@ -148,7 +150,7 @@ class Spreadsheet_Excel_Writer_Validator
return true; return true;
} }
public function _getOptions() function _getOptions()
{ {
$options = $this->_type; $options = $this->_type;
$options |= $this->_style << 3; $options |= $this->_style << 3;
@ -172,7 +174,7 @@ class Spreadsheet_Excel_Writer_Validator
return $options; return $options;
} }
public function _getData() function _getData()
{ {
$title_prompt_len = strlen($this->_title_prompt); $title_prompt_len = strlen($this->_title_prompt);
$descr_prompt_len = strlen($this->_descr_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 /*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(); parent::Spreadsheet_Excel_Writer_Validation();
$this->_type = 0x03; $this->_type = 0x03;
} }
public function setList($source, $incell = true) function setList($source, $incell = true)
{ {
$this->_incell = $incell; $this->_incell = $incell;
$this->_fixedList = true; $this->_fixedList = true;
@ -212,13 +214,13 @@ class Spreadsheet_Excel_Writer_Validator
$this->_formula1 = pack("CCC", 0x17, strlen($source), 0x0c) . $source; $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->_incell = $incell;
//$this->_formula1 = ...; //$this->_formula1 = ...;
} }
public function setCol($col, $row1, $row2, $incell = true) function setCol($col, $row1, $row2, $incell = true)
{ {
$this->_incell = $incell; $this->_incell = $incell;
//$this->_formula1 = ...; //$this->_formula1 = ...;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff