updated require_once status, replaced var with either public or protected visibility. also prefixed functions with eher public or protected (if method name starts with _ it will be protected). also updated composer.json

This commit is contained in:
stevleibelt 2016-01-07 23:01:38 +01:00
parent bb1117383e
commit b3be543ba3
9 changed files with 1050 additions and 981 deletions

2
.gitignore vendored
View File

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

View File

@ -31,8 +31,7 @@
* 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'; require_once __DIR__ . '/Writer/Workbook.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.
@ -47,13 +46,12 @@ 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
*/ */
function Spreadsheet_Excel_Writer($filename = '') public function __construct($fileName = '')
{ {
$this->_filename = $filename; $this->fileName = $fileName;
$this->Spreadsheet_Excel_Writer_Workbook($filename); parent::__construct($fileName);
} }
/** /**
@ -62,13 +60,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
*/ */
function send($filename) public 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');
} }
/** /**
@ -78,17 +76,17 @@ 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 $col Column for the cell to convert (0-indexed). * @param integer $column Column for the cell to convert (0-indexed).
* @return string The cell identifier in A1 format * @return string The cell identifier in A1 format
*/ */
function rowcolToCell($row, $col) public function rowcolToCell($row, $column)
{ {
if ($col > 255) { //maximum column value exceeded if ($column > 255) { //maximum column value exceeded
return new PEAR_Error("Maximum column value exceeded: $col"); return new PEAR_Error('Maximum column value exceeded: ' . $column);
} }
$int = (int)($col / 26); $int = (int)($column / 26);
$frac = $col % 26; $frac = $column % 26;
$chr1 = ''; $chr1 = '';
if ($int > 0) { if ($int > 0) {
@ -96,9 +94,8 @@ class Spreadsheet_Excel_Writer extends Spreadsheet_Excel_Writer_Workbook
} }
$chr2 = chr(ord('A') + $frac); $chr2 = chr(ord('A') + $frac);
$row++; ++$row;
return $chr1 . $chr2 . $row; return $chr1 . $chr2 . $row;
} }
} }
?>

View File

@ -32,8 +32,6 @@
* 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.
* *
@ -57,59 +55,59 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR
* The BIFF/Excel version (5). * The BIFF/Excel version (5).
* @var integer * @var integer
*/ */
var $_BIFF_version = 0x0500; protected $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
*/ */
var $_byte_order; protected $byteOrder;
/** /**
* The string containing the data of the BIFF stream * The string containing the data of the BIFF stream
* @var string * @var string
*/ */
var $_data; protected $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
*/ */
var $_datasize; protected $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()
*/ */
var $_limit; protected $limit;
/** /**
* The temporary dir for storing the OLE file * The temporary dir for storing the OLE file
* @var string * @var string
*/ */
var $_tmp_dir; protected $temporaryDirectory;
/** /**
* The temporary file for storing the OLE file * The temporary file for storing the OLE file
* @var string * @var string
*/ */
var $_tmp_file; protected $temporaryFile;
/** /**
* Constructor * Constructor
* *
* @access public * @access public
*/ */
function Spreadsheet_Excel_Writer_BIFFwriter() public function __construct()
{ {
$this->_byte_order = ''; $this->byteOrder = '';
$this->_data = ''; $this->data = '';
$this->_datasize = 0; $this->dataSize = 0;
$this->_limit = 2080; $this->limit = 2080;
$this->_tmp_dir = ''; $this->temporaryDirectory = '';
// Set the byte order // Set the byte order
$this->_setByteOrder(); $this->setByteOrder();
} }
/** /**
@ -118,21 +116,23 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR
* *
* @access private * @access private
*/ */
function _setByteOrder() protected function setByteOrder()
{ {
// Check if "pack" gives the required IEEE 64bit float // Check if "pack" gives the required IEEE 64bit float
$teststr = pack("d", 1.2345); $testString = 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($teststr)){ } elseif ($number == strrev($testString)){
$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,13 +141,14 @@ 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
*/ */
function _prepend($data) protected 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->_datasize += strlen($data); $this->data = $data . $this->data;
$this->dataSize += strlen($data);
} }
/** /**
@ -156,13 +157,14 @@ 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
*/ */
function _append($data) protected 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->_datasize += strlen($data); $this->data = $this->data . $data;
$this->dataSize += strlen($data);
} }
/** /**
@ -173,28 +175,28 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR
* 0x0010 Worksheet. * 0x0010 Worksheet.
* @access private * @access private
*/ */
function _storeBof($type) protected 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);
} }
/** /**
@ -202,12 +204,12 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR
* *
* @access private * @access private
*/ */
function _storeEof() protected 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);
} }
/** /**
@ -222,16 +224,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
*/ */
function _addContinue($data) protected 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);
@ -241,7 +243,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);
@ -255,13 +257,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
*/ */
function setTempDir($dir) protected function setTempDir($dir)
{ {
if (is_dir($dir)) { if (is_dir($dir)) {
$this->_tmp_dir = $dir; $this->temporaryDirectory = $dir;
return true; return true;
} }
return false; return false;
} }
} }
?>

View File

@ -32,8 +32,6 @@
* 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)
* *
@ -48,199 +46,199 @@ class Spreadsheet_Excel_Writer_Format extends PEAR
* 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
*/ */
var $_xf_index; protected $_xf_index;
/** /**
* Index to the FONT record. * Index to the FONT record.
* @var integer * @var integer
*/ */
var $font_index; public $font_index;
/** /**
* The font name (ASCII). * The font name (ASCII).
* @var string * @var string
*/ */
var $_font_name; protected $_font_name;
/** /**
* Height of font (1/20 of a point) * Height of font (1/20 of a point)
* @var integer * @var integer
*/ */
var $_size; protected $_size;
/** /**
* Bold style * Bold style
* @var integer * @var integer
*/ */
var $_bold; protected $_bold;
/** /**
* Bit specifiying if the font is italic. * Bit specifiying if the font is italic.
* @var integer * @var integer
*/ */
var $_italic; protected $_italic;
/** /**
* Index to the cell's color * Index to the cell's color
* @var integer * @var integer
*/ */
var $_color; protected $_color;
/** /**
* The text underline property * The text underline property
* @var integer * @var integer
*/ */
var $_underline; protected $_underline;
/** /**
* Bit specifiying if the font has strikeout. * Bit specifiying if the font has strikeout.
* @var integer * @var integer
*/ */
var $_font_strikeout; protected $_font_strikeout;
/** /**
* Bit specifiying if the font has outline. * Bit specifiying if the font has outline.
* @var integer * @var integer
*/ */
var $_font_outline; protected $_font_outline;
/** /**
* Bit specifiying if the font has shadow. * Bit specifiying if the font has shadow.
* @var integer * @var integer
*/ */
var $_font_shadow; protected $_font_shadow;
/** /**
* 2 bytes specifiying the script type for the font. * 2 bytes specifiying the script type for the font.
* @var integer * @var integer
*/ */
var $_font_script; protected $_font_script;
/** /**
* Byte specifiying the font family. * Byte specifiying the font family.
* @var integer * @var integer
*/ */
var $_font_family; protected $_font_family;
/** /**
* Byte specifiying the font charset. * Byte specifiying the font charset.
* @var integer * @var integer
*/ */
var $_font_charset; protected $_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
*/ */
var $_num_format; protected $_num_format;
/** /**
* Bit specifying if formulas are hidden. * Bit specifying if formulas are hidden.
* @var integer * @var integer
*/ */
var $_hidden; protected $_hidden;
/** /**
* Bit specifying if the cell is locked. * Bit specifying if the cell is locked.
* @var integer * @var integer
*/ */
var $_locked; protected $_locked;
/** /**
* The three bits specifying the text horizontal alignment. * The three bits specifying the text horizontal alignment.
* @var integer * @var integer
*/ */
var $_text_h_align; protected $_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
*/ */
var $_text_wrap; protected $_text_wrap;
/** /**
* The three bits specifying the text vertical alignment. * The three bits specifying the text vertical alignment.
* @var integer * @var integer
*/ */
var $_text_v_align; protected $_text_v_align;
/** /**
* 1 bit, apparently not used. * 1 bit, apparently not used.
* @var integer * @var integer
*/ */
var $_text_justlast; protected $_text_justlast;
/** /**
* The two bits specifying the text rotation. * The two bits specifying the text rotation.
* @var integer * @var integer
*/ */
var $_rotation; protected $_rotation;
/** /**
* The cell's foreground color. * The cell's foreground color.
* @var integer * @var integer
*/ */
var $_fg_color; protected $_fg_color;
/** /**
* The cell's background color. * The cell's background color.
* @var integer * @var integer
*/ */
var $_bg_color; protected $_bg_color;
/** /**
* The cell's background fill pattern. * The cell's background fill pattern.
* @var integer * @var integer
*/ */
var $_pattern; protected $_pattern;
/** /**
* Style of the bottom border of the cell * Style of the bottom border of the cell
* @var integer * @var integer
*/ */
var $_bottom; protected $_bottom;
/** /**
* Color of the bottom border of the cell. * Color of the bottom border of the cell.
* @var integer * @var integer
*/ */
var $_bottom_color; protected $_bottom_color;
/** /**
* Style of the top border of the cell * Style of the top border of the cell
* @var integer * @var integer
*/ */
var $_top; protected $_top;
/** /**
* Color of the top border of the cell. * Color of the top border of the cell.
* @var integer * @var integer
*/ */
var $_top_color; protected $_top_color;
/** /**
* Style of the left border of the cell * Style of the left border of the cell
* @var integer * @var integer
*/ */
var $_left; protected $_left;
/** /**
* Color of the left border of the cell. * Color of the left border of the cell.
* @var integer * @var integer
*/ */
var $_left_color; protected $_left_color;
/** /**
* Style of the right border of the cell * Style of the right border of the cell
* @var integer * @var integer
*/ */
var $_right; protected $_right;
/** /**
* Color of the right border of the cell. * Color of the right border of the cell.
* @var integer * @var integer
*/ */
var $_right_color; protected $_right_color;
/** /**
* Constructor * Constructor
@ -249,7 +247,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR
* @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.
*/ */
function Spreadsheet_Excel_Writer_Format($BIFF_version, $index = 0, $properties = array()) public function __construct($BIFF_version, $index = 0, $properties = array())
{ {
$this->_xf_index = $index; $this->_xf_index = $index;
$this->_BIFF_version = $BIFF_version; $this->_BIFF_version = $BIFF_version;
@ -312,7 +310,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
*/ */
function getXf($style) public 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') {
@ -444,7 +442,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR
* *
* @return string The FONT record * @return string The FONT record
*/ */
function getFont() public 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
@ -492,7 +490,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
@ -500,7 +498,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR
* *
* @return string A key for this font * @return string A key for this font
*/ */
function getFontKey() public 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";
@ -516,7 +514,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR
* *
* @return integer The index for the XF record * @return integer The index for the XF record
*/ */
function getXfIndex() public function getXfIndex()
{ {
return($this->_xf_index); return($this->_xf_index);
} }
@ -530,7 +528,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
*/ */
function _getColor($name_color = '') protected function _getColor($name_color = '')
{ {
$colors = array( $colors = array(
'aqua' => 0x07, 'aqua' => 0x07,
@ -583,7 +581,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...).
*/ */
function setAlign($location) public function setAlign($location)
{ {
if (preg_match("/\d/",$location)) { if (preg_match("/\d/",$location)) {
return; // Ignore numbers return; // Ignore numbers
@ -641,7 +639,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...).
*/ */
function setHAlign($location) public function setHAlign($location)
{ {
if (preg_match("/\d/",$location)) { if (preg_match("/\d/",$location)) {
return; // Ignore numbers return; // Ignore numbers
@ -681,7 +679,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...).
*/ */
function setVAlign($location) public function setVAlign($location)
{ {
if (preg_match("/\d/",$location)) { if (preg_match("/\d/",$location)) {
return; // Ignore numbers return; // Ignore numbers
@ -714,7 +712,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR
* *
* @access public * @access public
*/ */
function setMerge() public function setMerge()
{ {
$this->setAlign('merge'); $this->setAlign('merge');
} }
@ -729,7 +727,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).
*/ */
function setBold($weight = 1) public function setBold($weight = 1)
{ {
if ($weight == 1) { if ($weight == 1) {
$weight = 0x2BC; // Bold text $weight = 0x2BC; // Bold text
@ -757,7 +755,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.
*/ */
function setBottom($style) public function setBottom($style)
{ {
$this->_bottom = $style; $this->_bottom = $style;
} }
@ -768,7 +766,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.
*/ */
function setTop($style) public function setTop($style)
{ {
$this->_top = $style; $this->_top = $style;
} }
@ -779,7 +777,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.
*/ */
function setLeft($style) public function setLeft($style)
{ {
$this->_left = $style; $this->_left = $style;
} }
@ -790,7 +788,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.
*/ */
function setRight($style) public function setRight($style)
{ {
$this->_right = $style; $this->_right = $style;
} }
@ -802,7 +800,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.
*/ */
function setBorder($style) public function setBorder($style)
{ {
$this->setBottom($style); $this->setBottom($style);
$this->setTop($style); $this->setTop($style);
@ -822,7 +820,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]).
*/ */
function setBorderColor($color) public function setBorderColor($color)
{ {
$this->setBottomColor($color); $this->setBottomColor($color);
$this->setTopColor($color); $this->setTopColor($color);
@ -836,7 +834,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]).
*/ */
function setBottomColor($color) public function setBottomColor($color)
{ {
$value = $this->_getColor($color); $value = $this->_getColor($color);
$this->_bottom_color = $value; $this->_bottom_color = $value;
@ -848,7 +846,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]).
*/ */
function setTopColor($color) public function setTopColor($color)
{ {
$value = $this->_getColor($color); $value = $this->_getColor($color);
$this->_top_color = $value; $this->_top_color = $value;
@ -860,7 +858,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]).
*/ */
function setLeftColor($color) public function setLeftColor($color)
{ {
$value = $this->_getColor($color); $value = $this->_getColor($color);
$this->_left_color = $value; $this->_left_color = $value;
@ -872,7 +870,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]).
*/ */
function setRightColor($color) public function setRightColor($color)
{ {
$value = $this->_getColor($color); $value = $this->_getColor($color);
$this->_right_color = $value; $this->_right_color = $value;
@ -885,7 +883,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]).
*/ */
function setFgColor($color) public function setFgColor($color)
{ {
$value = $this->_getColor($color); $value = $this->_getColor($color);
$this->_fg_color = $value; $this->_fg_color = $value;
@ -900,7 +898,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]).
*/ */
function setBgColor($color) public function setBgColor($color)
{ {
$value = $this->_getColor($color); $value = $this->_getColor($color);
$this->_bg_color = $value; $this->_bg_color = $value;
@ -915,7 +913,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]).
*/ */
function setColor($color) public function setColor($color)
{ {
$value = $this->_getColor($color); $value = $this->_getColor($color);
$this->_color = $value; $this->_color = $value;
@ -928,7 +926,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.
*/ */
function setPattern($arg = 1) public function setPattern($arg = 1)
{ {
$this->_pattern = $arg; $this->_pattern = $arg;
} }
@ -940,7 +938,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.
*/ */
function setUnderline($underline) public function setUnderline($underline)
{ {
$this->_underline = $underline; $this->_underline = $underline;
} }
@ -950,7 +948,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR
* *
* @access public * @access public
*/ */
function setItalic() public function setItalic()
{ {
$this->_italic = 1; $this->_italic = 1;
} }
@ -961,7 +959,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).
*/ */
function setSize($size) public function setSize($size)
{ {
$this->_size = $size; $this->_size = $size;
} }
@ -971,7 +969,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR
* *
* @access public * @access public
*/ */
function setTextWrap() public function setTextWrap()
{ {
$this->_text_wrap = 1; $this->_text_wrap = 1;
} }
@ -983,7 +981,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.
*/ */
function setTextRotation($angle) public function setTextRotation($angle)
{ {
switch ($angle) switch ($angle)
{ {
@ -1027,7 +1025,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.
*/ */
function setNumFormat($num_format) public function setNumFormat($num_format)
{ {
$this->_num_format = $num_format; $this->_num_format = $num_format;
} }
@ -1037,7 +1035,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR
* *
* @access public * @access public
*/ */
function setStrikeOut() public function setStrikeOut()
{ {
$this->_font_strikeout = 1; $this->_font_strikeout = 1;
} }
@ -1047,7 +1045,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR
* *
* @access public * @access public
*/ */
function setOutLine() public function setOutLine()
{ {
$this->_font_outline = 1; $this->_font_outline = 1;
} }
@ -1057,7 +1055,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR
* *
* @access public * @access public
*/ */
function setShadow() public function setShadow()
{ {
$this->_font_shadow = 1; $this->_font_shadow = 1;
} }
@ -1069,7 +1067,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.
*/ */
function setScript($script) public function setScript($script)
{ {
$this->_font_script = $script; $this->_font_script = $script;
} }
@ -1079,7 +1077,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR
* *
* @access public * @access public
*/ */
function setLocked() public function setLocked()
{ {
$this->_locked = 1; $this->_locked = 1;
} }
@ -1089,7 +1087,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR
* *
* @access public * @access public
*/ */
function setUnLocked() public function setUnLocked()
{ {
$this->_locked = 0; $this->_locked = 0;
} }
@ -1101,7 +1099,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR
* @param string $fontfamily 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'.
*/ */
function setFontFamily($font_family) public function setFontFamily($font_family)
{ {
$this->_font_name = $font_family; $this->_font_name = $font_family;
} }

View File

@ -25,79 +25,77 @@
/** /**
* @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
@ -113,55 +111,55 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR
* The index of the character we are currently looking at * The index of the character we are currently looking at
* @var integer * @var integer
*/ */
var $_current_char; protected $_current_char;
/** /**
* The token we are working on. * The token we are working on.
* @var string * @var string
*/ */
var $_current_token; protected $_current_token;
/** /**
* The formula to parse * The formula to parse
* @var string * @var string
*/ */
var $_formula; protected $_formula;
/** /**
* The character ahead of the current char * The character ahead of the current char
* @var string * @var string
*/ */
var $_lookahead; protected $_lookahead;
/** /**
* The parse tree to be generated * The parse tree to be generated
* @var string * @var string
*/ */
var $_parse_tree; protected $_parse_tree;
/** /**
* The byte order. 1 => big endian, 0 => little endian. * The byte order. 1 => big endian, 0 => little endian.
* @var integer * @var integer
*/ */
var $_byte_order; protected $_byte_order;
/** /**
* Array of external sheets * Array of external sheets
* @var array * @var array
*/ */
var $_ext_sheets; protected $_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
*/ */
var $_references; protected $_references;
/** /**
* The BIFF version for the workbook * The BIFF version for the workbook
* @var integer * @var integer
*/ */
var $_BIFF_version; protected $_BIFF_version;
/** /**
* The class constructor * The class constructor
@ -169,7 +167,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR
* @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.
*/ */
function Spreadsheet_Excel_Writer_Parser($byte_order, $biff_version) public function __construct($byte_order, $biff_version)
{ {
$this->_current_char = 0; $this->_current_char = 0;
$this->_BIFF_version = $biff_version; $this->_BIFF_version = $biff_version;
@ -188,7 +186,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR
* *
* @access private * @access private
*/ */
function _initializeHashes() protected function _initializeHashes()
{ {
// The Excel ptg indices // The Excel ptg indices
$this->ptg = array( $this->ptg = array(
@ -540,7 +538,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
*/ */
function _convert($token) protected function _convert($token)
{ {
if (preg_match("/^\"[^\"]{0,255}\"$/", $token)) { if (preg_match("/^\"[^\"]{0,255}\"$/", $token)) {
return $this->_convertString($token); return $this->_convertString($token);
@ -600,7 +598,7 @@ 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
*/ */
function _convertNumber($num) protected 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)) {
@ -621,7 +619,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.
*/ */
function _convertString($string) protected 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);
@ -646,7 +644,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
*/ */
function _convertFunction($token, $num_args) protected 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,7 +665,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR
* @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.
*/ */
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
@ -716,7 +714,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.
*/ */
function _convertRange3d($token) protected function _convertRange3d($token)
{ {
$class = 2; // as far as I know, this is magick. $class = 2; // as far as I know, this is magick.
@ -780,7 +778,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
*/ */
function _convertRef2d($cell) protected function _convertRef2d($cell)
{ {
$class = 2; // as far as I know, this is magick. $class = 2; // as far as I know, this is magick.
@ -813,7 +811,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.
*/ */
function _convertRef3d($cell) protected function _convertRef3d($cell)
{ {
$class = 2; // as far as I know, this is magick. $class = 2; // as far as I know, this is magick.
@ -858,7 +856,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
*/ */
function _packExtRef($ext_ref) protected function _packExtRef($ext_ref)
{ {
$ext_ref = preg_replace("/^'/", '', $ext_ref); // Remove leading ' if any. $ext_ref = preg_replace("/^'/", '', $ext_ref); // Remove leading ' if any.
$ext_ref = preg_replace("/'$/", '', $ext_ref); // Remove trailing ' if any. $ext_ref = preg_replace("/'$/", '', $ext_ref); // Remove trailing ' if any.
@ -904,7 +902,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
*/ */
function _getRefIndex($ext_ref) protected function _getRefIndex($ext_ref)
{ {
$ext_ref = preg_replace("/^'/", '', $ext_ref); // Remove leading ' if any. $ext_ref = preg_replace("/^'/", '', $ext_ref); // Remove leading ' if any.
$ext_ref = preg_replace("/'$/", '', $ext_ref); // Remove trailing ' if any. $ext_ref = preg_replace("/'$/", '', $ext_ref); // Remove trailing ' if any.
@ -962,7 +960,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
*/ */
function _getSheetIndex($sheet_name) protected function _getSheetIndex($sheet_name)
{ {
if (!isset($this->_ext_sheets[$sheet_name])) { if (!isset($this->_ext_sheets[$sheet_name])) {
return -1; return -1;
@ -981,7 +979,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
*/ */
function setExtSheet($name, $index) public function setExtSheet($name, $index)
{ {
$this->_ext_sheets[$name] = $index; $this->_ext_sheets[$name] = $index;
} }
@ -993,7 +991,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
*/ */
function _cellToPackedRowcol($cell) protected 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);
@ -1028,7 +1026,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
*/ */
function _rangeToPackedRange($range) protected 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
@ -1075,7 +1073,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
*/ */
function _cellToRowcol($cell) protected 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
@ -1105,7 +1103,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR
* *
* @access private * @access private
*/ */
function _advance() protected function _advance()
{ {
$i = $this->_current_char; $i = $this->_current_char;
$formula_length = strlen($this->_formula); $formula_length = strlen($this->_formula);
@ -1155,7 +1153,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
*/ */
function _match($token) protected function _match($token)
{ {
switch($token) { switch($token) {
case SPREADSHEET_EXCEL_WRITER_ADD: case SPREADSHEET_EXCEL_WRITER_ADD:
@ -1286,7 +1284,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
*/ */
function parse($formula) public function parse($formula)
{ {
$this->_current_char = 0; $this->_current_char = 0;
$this->_formula = $formula; $this->_formula = $formula;
@ -1306,7 +1304,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
*/ */
function _condition() protected function _condition()
{ {
$result = $this->_expression(); $result = $this->_expression();
if (PEAR::isError($result)) { if (PEAR::isError($result)) {
@ -1374,7 +1372,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
*/ */
function _expression() protected 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)) {
@ -1422,7 +1420,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
*/ */
function _parenthesizedExpression() protected function _parenthesizedExpression()
{ {
$result = $this->_createTree('ptgParen', $this->_expression(), ''); $result = $this->_createTree('ptgParen', $this->_expression(), '');
return $result; return $result;
@ -1435,7 +1433,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
*/ */
function _term() protected function _term()
{ {
$result = $this->_fact(); $result = $this->_fact();
if (PEAR::isError($result)) { if (PEAR::isError($result)) {
@ -1474,7 +1472,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
*/ */
function _fact() protected 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 "("
@ -1552,7 +1550,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
*/ */
function _func() protected 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);
@ -1608,7 +1606,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
*/ */
function _createTree($value, $left, $right) protected function _createTree($value, $left, $right)
{ {
return array('value' => $value, 'left' => $left, 'right' => $right); return array('value' => $value, 'left' => $left, 'right' => $right);
} }
@ -1640,7 +1638,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
*/ */
function toReversePolish($tree = array()) public 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,21 +22,19 @@
* 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)
@ -47,27 +45,27 @@ define("OP_LTE", 0x07);
*/ */
class Spreadsheet_Excel_Writer_Validator class Spreadsheet_Excel_Writer_Validator
{ {
var $_type; protected $_type;
var $_style; protected $_style;
var $_fixedList; protected $_fixedList;
var $_blank; protected $_blank;
var $_incell; protected $_incell;
var $_showprompt; protected $_showprompt;
var $_showerror; protected $_showerror;
var $_title_prompt; protected $_title_prompt;
var $_descr_prompt; protected $_descr_prompt;
var $_title_error; protected $_title_error;
var $_descr_error; protected $_descr_error;
var $_operator; protected $_operator;
var $_formula1; protected $_formula1;
var $_formula2; protected $_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
*/ */
var $_parser; protected $_parser;
function Spreadsheet_Excel_Writer_Validator(&$parser) public function __construct($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
@ -86,41 +84,41 @@ class Spreadsheet_Excel_Writer_Validator
$this->_formula2 = ''; $this->_formula2 = '';
} }
function setPrompt($promptTitle = "\x00", $promptDescription = "\x00", $showPrompt = true) public 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;
} }
function setError($errorTitle = "\x00", $errorDescription = "\x00", $showError = true) public 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;
} }
function allowBlank() public function allowBlank()
{ {
$this->_blank = true; $this->_blank = true;
} }
function onInvalidStop() public function onInvalidStop()
{ {
$this->_style = 0x00; $this->_style = 0x00;
} }
function onInvalidWarn() public function onInvalidWarn()
{ {
$this->_style = 0x01; $this->_style = 0x01;
} }
function onInvalidInfo() public function onInvalidInfo()
{ {
$this->_style = 0x02; $this->_style = 0x02;
} }
function setFormula1($formula) public 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);
@ -135,7 +133,7 @@ class Spreadsheet_Excel_Writer_Validator
return true; return true;
} }
function setFormula2($formula) public 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);
@ -150,7 +148,7 @@ class Spreadsheet_Excel_Writer_Validator
return true; return true;
} }
function _getOptions() public function _getOptions()
{ {
$options = $this->_type; $options = $this->_type;
$options |= $this->_style << 3; $options |= $this->_style << 3;
@ -174,7 +172,7 @@ class Spreadsheet_Excel_Writer_Validator
return $options; return $options;
} }
function _getData() public 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);
@ -199,13 +197,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
{ {
function Spreadsheet_Excel_Writer_Validation_list() public function Spreadsheet_Excel_Writer_Validation_list()
{ {
parent::Spreadsheet_Excel_Writer_Validation(); parent::Spreadsheet_Excel_Writer_Validation();
$this->_type = 0x03; $this->_type = 0x03;
} }
function setList($source, $incell = true) public function setList($source, $incell = true)
{ {
$this->_incell = $incell; $this->_incell = $incell;
$this->_fixedList = true; $this->_fixedList = true;
@ -214,13 +212,13 @@ class Spreadsheet_Excel_Writer_Validator
$this->_formula1 = pack("CCC", 0x17, strlen($source), 0x0c) . $source; $this->_formula1 = pack("CCC", 0x17, strlen($source), 0x0c) . $source;
} }
function setRow($row, $col1, $col2, $incell = true) public function setRow($row, $col1, $col2, $incell = true)
{ {
$this->_incell = $incell; $this->_incell = $incell;
//$this->_formula1 = ...; //$this->_formula1 = ...;
} }
function setCol($col, $row1, $row2, $incell = true) public 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

View File

@ -31,6 +31,7 @@
"./" "./"
], ],
"license": "LGPL", "license": "LGPL",
"minimum-stability": "dev",
"name": "pear/spreadsheet_excel_writer", "name": "pear/spreadsheet_excel_writer",
"support": { "support": {
"issues": "http://pear.php.net/bugs/search.php?cmd=display&package_name[]=Spreadsheet_Excel_Writer", "issues": "http://pear.php.net/bugs/search.php?cmd=display&package_name[]=Spreadsheet_Excel_Writer",
@ -38,8 +39,9 @@
}, },
"type": "library", "type": "library",
"require": { "require": {
"pear/pear_exception": "*", "pear/pear": "*",
"pear/ole": "*" "pear/ole": "*",
"php": ">=5.3.3"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "*" "phpunit/phpunit": "*"