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.lock
composer.phar

View File

@ -31,7 +31,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
require_once __DIR__ . '/Writer/Workbook.php';
require_once 'PEAR.php';
require_once 'Spreadsheet/Excel/Writer/Workbook.php';
/**
* Class for writing Excel Spreadsheets. This class should change COMPLETELY.
@ -46,12 +47,13 @@ class Spreadsheet_Excel_Writer extends Spreadsheet_Excel_Writer_Workbook
/**
* The constructor. It just creates a Workbook
*
* @param string $fileName The optional filename for the Workbook.
* @param string $filename The optional filename for the Workbook.
* @return Spreadsheet_Excel_Writer_Workbook The Workbook created
*/
public function __construct($fileName = '')
function Spreadsheet_Excel_Writer($filename = '')
{
$this->fileName = $fileName;
parent::__construct($fileName);
$this->_filename = $filename;
$this->Spreadsheet_Excel_Writer_Workbook($filename);
}
/**
@ -60,13 +62,13 @@ class Spreadsheet_Excel_Writer extends Spreadsheet_Excel_Writer_Workbook
* @param string $filename The filename to use for HTTP headers
* @access public
*/
public function send($filename)
function send($filename)
{
header('Content-type: application/vnd.ms-excel');
header('Content-Disposition: attachment; filename="' . $filename .'"');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0,pre-check=0');
header('Pragma: public');
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=\"$filename\"");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
header("Pragma: public");
}
/**
@ -76,17 +78,17 @@ class Spreadsheet_Excel_Writer extends Spreadsheet_Excel_Writer_Workbook
* @access public
* @static
* @param integer $row Row for the cell to convert (0-indexed).
* @param integer $column Column for the cell to convert (0-indexed).
* @param integer $col Column for the cell to convert (0-indexed).
* @return string The cell identifier in A1 format
*/
public function rowcolToCell($row, $column)
function rowcolToCell($row, $col)
{
if ($column > 255) { //maximum column value exceeded
return new PEAR_Error('Maximum column value exceeded: ' . $column);
if ($col > 255) { //maximum column value exceeded
return new PEAR_Error("Maximum column value exceeded: $col");
}
$int = (int)($column / 26);
$frac = $column % 26;
$int = (int)($col / 26);
$frac = $col % 26;
$chr1 = '';
if ($int > 0) {
@ -94,8 +96,9 @@ class Spreadsheet_Excel_Writer extends Spreadsheet_Excel_Writer_Workbook
}
$chr2 = chr(ord('A') + $frac);
++$row;
$row++;
return $chr1 . $chr2 . $row;
}
}
?>

View File

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

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff