Merge pull request #8 from sanmai/fixtures
Fix errors, add tests with fixtrues
This commit is contained in:
commit
c91cd95ffa
|
|
@ -1,5 +1,3 @@
|
||||||
# ide related
|
|
||||||
.idea
|
|
||||||
# composer related
|
# composer related
|
||||||
composer.lock
|
composer.lock
|
||||||
composer.phar
|
composer.phar
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,9 @@
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once __DIR__ . '/Writer/Workbook.php';
|
if (!class_exists('Spreadsheet_Excel_Writer_Workbook')) {
|
||||||
|
require_once 'Spreadsheet/Excel/Writer/Workbook.php';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class for writing Excel Spreadsheets. This class should change COMPLETELY.
|
* Class for writing Excel Spreadsheets. This class should change COMPLETELY.
|
||||||
|
|
@ -46,12 +48,13 @@ class Spreadsheet_Excel_Writer extends Spreadsheet_Excel_Writer_Workbook
|
||||||
/**
|
/**
|
||||||
* The constructor. It just creates a Workbook
|
* The constructor. It just creates a Workbook
|
||||||
*
|
*
|
||||||
* @param string $fileName The optional filename for the Workbook.
|
* @param string $filename The optional filename for the Workbook.
|
||||||
|
* @return Spreadsheet_Excel_Writer_Workbook The Workbook created
|
||||||
*/
|
*/
|
||||||
public function __construct($fileName = '')
|
public function __construct($filename = '')
|
||||||
{
|
{
|
||||||
$this->fileName = $fileName;
|
$this->_filename = $filename;
|
||||||
parent::__construct($fileName);
|
parent::__construct($filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -62,11 +65,12 @@ class Spreadsheet_Excel_Writer extends Spreadsheet_Excel_Writer_Workbook
|
||||||
*/
|
*/
|
||||||
public function send($filename)
|
public function send($filename)
|
||||||
{
|
{
|
||||||
header('Content-type: application/vnd.ms-excel');
|
$filename = addslashes($filename);
|
||||||
header('Content-Disposition: attachment; filename="' . $filename .'"');
|
header("Content-type: application/vnd.ms-excel");
|
||||||
header('Expires: 0');
|
header("Content-Disposition: attachment; filename=\"$filename\"");
|
||||||
header('Cache-Control: must-revalidate, post-check=0,pre-check=0');
|
header("Expires: 0");
|
||||||
header('Pragma: public');
|
header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
|
||||||
|
header("Pragma: public");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -76,26 +80,26 @@ class Spreadsheet_Excel_Writer extends Spreadsheet_Excel_Writer_Workbook
|
||||||
* @access public
|
* @access public
|
||||||
* @static
|
* @static
|
||||||
* @param integer $row Row for the cell to convert (0-indexed).
|
* @param integer $row Row for the cell to convert (0-indexed).
|
||||||
* @param integer $column Column for the cell to convert (0-indexed).
|
* @param integer $col Column for the cell to convert (0-indexed).
|
||||||
* @return string The cell identifier in A1 format
|
* @return string The cell identifier in A1 format
|
||||||
*/
|
*/
|
||||||
public function rowcolToCell($row, $column)
|
function rowcolToCell($row, $col)
|
||||||
{
|
{
|
||||||
if ($column > 255) { //maximum column value exceeded
|
if ($col > 255) { //maximum column value exceeded
|
||||||
return new PEAR_Error('Maximum column value exceeded: ' . $column);
|
return new PEAR_Error("Maximum column value exceeded: $col");
|
||||||
}
|
}
|
||||||
|
|
||||||
$int = (int)($column / 26);
|
$int = (int)($col / 26);
|
||||||
$frac = $column % 26;
|
$frac = $col % 26;
|
||||||
$chr1 = '';
|
$chr1 = '';
|
||||||
|
|
||||||
if ($int > 0) {
|
if ($int > 0) {
|
||||||
$chr1 = chr(ord('A') + $int - 1);
|
$chr1 = chr(ord('A') + $int - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
$chr2 = chr(ord('A') + $frac);
|
$chr2 = chr(ord('A') + $frac);
|
||||||
++$row;
|
$row++;
|
||||||
|
|
||||||
return $chr1 . $chr2 . $row;
|
return $chr1 . $chr2 . $row;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -32,6 +32,10 @@
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
if (!class_exists('PEAR')) {
|
||||||
|
require_once 'PEAR.php';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class for writing Excel BIFF records.
|
* Class for writing Excel BIFF records.
|
||||||
*
|
*
|
||||||
|
|
@ -55,44 +59,44 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR
|
||||||
* The BIFF/Excel version (5).
|
* The BIFF/Excel version (5).
|
||||||
* @var integer
|
* @var integer
|
||||||
*/
|
*/
|
||||||
public $BIFF_version = 0x0500;
|
public $_BIFF_version = 0x0500;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The byte order of this architecture. 0 => little endian, 1 => big endian
|
* The byte order of this architecture. 0 => little endian, 1 => big endian
|
||||||
* @var integer
|
* @var integer
|
||||||
*/
|
*/
|
||||||
public $byteOrder;
|
public $_byte_order;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The string containing the data of the BIFF stream
|
* The string containing the data of the BIFF stream
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $data;
|
public $_data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The size of the data in bytes. Should be the same as strlen($this->data)
|
* The size of the data in bytes. Should be the same as strlen($this->_data)
|
||||||
* @var integer
|
* @var integer
|
||||||
*/
|
*/
|
||||||
public $dataSize;
|
public $_datasize;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The maximun length for a BIFF record. See addContinue()
|
* The maximun length for a BIFF record. See _addContinue()
|
||||||
* @var integer
|
* @var integer
|
||||||
* @see addContinue()
|
* @see _addContinue()
|
||||||
*/
|
*/
|
||||||
public $limit;
|
public $_limit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The temporary dir for storing the OLE file
|
* The temporary dir for storing the OLE file
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $temporaryDirectory;
|
public $_tmp_dir;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The temporary file for storing the OLE file
|
* The temporary file for storing the OLE file
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $temporaryFile;
|
public $_tmp_file;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
|
|
@ -101,13 +105,13 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->byteOrder = '';
|
$this->_byte_order = '';
|
||||||
$this->data = '';
|
$this->_data = '';
|
||||||
$this->dataSize = 0;
|
$this->_datasize = 0;
|
||||||
$this->limit = 2080;
|
$this->_limit = 2080;
|
||||||
$this->temporaryDirectory = '';
|
$this->_tmp_dir = '';
|
||||||
// Set the byte order
|
// Set the byte order
|
||||||
$this->setByteOrder();
|
$this->_setByteOrder();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -116,55 +120,51 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
protected function setByteOrder()
|
protected function _setByteOrder()
|
||||||
{
|
{
|
||||||
// Check if "pack" gives the required IEEE 64bit float
|
// Check if "pack" gives the required IEEE 64bit float
|
||||||
$testString = pack('d', 1.2345);
|
$teststr = pack("d", 1.2345);
|
||||||
$number = pack('C8', 0x8D, 0x97, 0x6E, 0x12, 0x83, 0xC0, 0xF3, 0x3F);
|
$number = pack("C8", 0x8D, 0x97, 0x6E, 0x12, 0x83, 0xC0, 0xF3, 0x3F);
|
||||||
|
if ($number == $teststr) {
|
||||||
if ($number == $testString) {
|
|
||||||
$byte_order = 0; // Little Endian
|
$byte_order = 0; // Little Endian
|
||||||
} elseif ($number == strrev($testString)){
|
} elseif ($number == strrev($teststr)){
|
||||||
$byte_order = 1; // Big Endian
|
$byte_order = 1; // Big Endian
|
||||||
} else {
|
} else {
|
||||||
// Give up. I'll fix this in a later version.
|
// Give up. I'll fix this in a later version.
|
||||||
return $this->raiseError('Required floating point format ' .
|
return $this->raiseError("Required floating point format ".
|
||||||
'not supported on this platform.');
|
"not supported on this platform.");
|
||||||
}
|
}
|
||||||
|
$this->_byte_order = $byte_order;
|
||||||
$this->byteOrder = $byte_order;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* General storage function
|
* General storage public function
|
||||||
*
|
*
|
||||||
* @param string $data binary data to prepend
|
* @param string $data binary data to prepend
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
protected 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->data = $data . $this->data;
|
$this->_datasize += strlen($data);
|
||||||
$this->dataSize += strlen($data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* General storage function
|
* General storage public function
|
||||||
*
|
*
|
||||||
* @param string $data binary data to append
|
* @param string $data binary data to append
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
protected 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->data = $this->data . $data;
|
$this->_datasize += strlen($data);
|
||||||
$this->dataSize += strlen($data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -175,28 +175,28 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR
|
||||||
* 0x0010 Worksheet.
|
* 0x0010 Worksheet.
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
protected 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -204,12 +204,12 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
protected 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -217,23 +217,23 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR
|
||||||
* Excel 97 the limit is 8228 bytes. Records that are longer than these limits
|
* Excel 97 the limit is 8228 bytes. Records that are longer than these limits
|
||||||
* must be split up into CONTINUE blocks.
|
* must be split up into CONTINUE blocks.
|
||||||
*
|
*
|
||||||
* This function takes a long BIFF record and inserts CONTINUE records as
|
* This public function takes a long BIFF record and inserts CONTINUE records as
|
||||||
* necessary.
|
* necessary.
|
||||||
*
|
*
|
||||||
* @param string $data The original binary data to be written
|
* @param string $data The original binary data to be written
|
||||||
* @return string A very convenient string of continue blocks
|
* @return string A very convenient string of continue blocks
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
protected function addContinue($data)
|
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);
|
||||||
|
|
@ -243,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);
|
||||||
|
|
||||||
|
|
@ -257,13 +257,12 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR
|
||||||
* @param string $dir The dir to be used as temp dir
|
* @param string $dir The dir to be used as temp dir
|
||||||
* @return true if given dir is valid, false otherwise
|
* @return true if given dir is valid, false otherwise
|
||||||
*/
|
*/
|
||||||
protected function setTempDir($dir)
|
public function setTempDir($dir)
|
||||||
{
|
{
|
||||||
if (is_dir($dir)) {
|
if (is_dir($dir)) {
|
||||||
$this->temporaryDirectory = $dir;
|
$this->_tmp_dir = $dir;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -32,6 +32,10 @@
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
if (!class_exists('PEAR')) {
|
||||||
|
require_once 'PEAR.php';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class for generating Excel XF records (formats)
|
* Class for generating Excel XF records (formats)
|
||||||
*
|
*
|
||||||
|
|
@ -42,24 +46,18 @@
|
||||||
|
|
||||||
class Spreadsheet_Excel_Writer_Format extends PEAR
|
class Spreadsheet_Excel_Writer_Format extends PEAR
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* The BIFF version for the workbook
|
|
||||||
* @var integer
|
|
||||||
*/
|
|
||||||
public $_BIFF_version;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Index to the FONT record.
|
|
||||||
* @var integer
|
|
||||||
*/
|
|
||||||
public $font_index;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The index given by the workbook when creating a new format.
|
* The index given by the workbook when creating a new format.
|
||||||
* @var integer
|
* @var integer
|
||||||
*/
|
*/
|
||||||
public $_xf_index;
|
public $_xf_index;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Index to the FONT record.
|
||||||
|
* @var integer
|
||||||
|
*/
|
||||||
|
public $font_index;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The font name (ASCII).
|
* The font name (ASCII).
|
||||||
* @var string
|
* @var string
|
||||||
|
|
@ -250,7 +248,6 @@ class Spreadsheet_Excel_Writer_Format extends PEAR
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param integer $BIFF_version
|
|
||||||
* @param integer $index the XF index for the format.
|
* @param integer $index the XF index for the format.
|
||||||
* @param array $properties array with properties to be set on initialization.
|
* @param array $properties array with properties to be set on initialization.
|
||||||
*/
|
*/
|
||||||
|
|
@ -497,7 +494,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
|
||||||
|
|
@ -651,9 +648,9 @@ class Spreadsheet_Excel_Writer_Format extends PEAR
|
||||||
if (preg_match("/\d/",$location)) {
|
if (preg_match("/\d/",$location)) {
|
||||||
return; // Ignore numbers
|
return; // Ignore numbers
|
||||||
}
|
}
|
||||||
|
|
||||||
$location = strtolower($location);
|
$location = strtolower($location);
|
||||||
|
|
||||||
if ($location == 'left') {
|
if ($location == 'left') {
|
||||||
$this->_text_h_align = 1;
|
$this->_text_h_align = 1;
|
||||||
}
|
}
|
||||||
|
|
@ -691,9 +688,9 @@ class Spreadsheet_Excel_Writer_Format extends PEAR
|
||||||
if (preg_match("/\d/",$location)) {
|
if (preg_match("/\d/",$location)) {
|
||||||
return; // Ignore numbers
|
return; // Ignore numbers
|
||||||
}
|
}
|
||||||
|
|
||||||
$location = strtolower($location);
|
$location = strtolower($location);
|
||||||
|
|
||||||
if ($location == 'top') {
|
if ($location == 'top') {
|
||||||
$this->_text_v_align = 0;
|
$this->_text_v_align = 0;
|
||||||
}
|
}
|
||||||
|
|
@ -1103,12 +1100,11 @@ class Spreadsheet_Excel_Writer_Format extends PEAR
|
||||||
* Sets the font family name.
|
* Sets the font family name.
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param string $font_family The font family name. Possible values are:
|
* @param string $fontfamily The font family name. Possible values are:
|
||||||
* 'Times New Roman', 'Arial', 'Courier'.
|
* 'Times New Roman', 'Arial', 'Courier'.
|
||||||
*/
|
*/
|
||||||
public function setFontFamily($font_family)
|
public function setFontFamily($font_family)
|
||||||
{
|
{
|
||||||
$this->_font_name = $font_family;
|
$this->_font_name = $font_family;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
@ -25,77 +25,81 @@
|
||||||
/**
|
/**
|
||||||
* @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', "&");
|
||||||
|
|
||||||
|
if (!class_exists('PEAR')) {
|
||||||
|
require_once 'PEAR.php';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class for parsing Excel formulas
|
* Class for parsing Excel formulas
|
||||||
|
|
@ -107,12 +111,6 @@ define('SPREADSHEET_EXCEL_WRITER_CONCAT', '&');
|
||||||
|
|
||||||
class Spreadsheet_Excel_Writer_Parser extends PEAR
|
class Spreadsheet_Excel_Writer_Parser extends PEAR
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* The BIFF version for the workbook
|
|
||||||
* @var integer
|
|
||||||
*/
|
|
||||||
public $_BIFF_version;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The index of the character we are currently looking at
|
* The index of the character we are currently looking at
|
||||||
* @var integer
|
* @var integer
|
||||||
|
|
@ -131,11 +129,6 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR
|
||||||
*/
|
*/
|
||||||
public $_formula;
|
public $_formula;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
public $_functions;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The character ahead of the current char
|
* The character ahead of the current char
|
||||||
* @var string
|
* @var string
|
||||||
|
|
@ -166,12 +159,17 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR
|
||||||
*/
|
*/
|
||||||
public $_references;
|
public $_references;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The BIFF version for the workbook
|
||||||
|
* @var integer
|
||||||
|
*/
|
||||||
|
public $_BIFF_version;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The class constructor
|
* The class constructor
|
||||||
*
|
*
|
||||||
* @param integer $byte_order The byte order (Little endian or Big endian) of the architecture
|
* @param integer $byte_order The byte order (Little endian or Big endian) of the architecture
|
||||||
* (optional). 1 => big endian, 0 (default) little endian.
|
(optional). 1 => big endian, 0 (default) little endian.
|
||||||
* @param integer $biff_version
|
|
||||||
*/
|
*/
|
||||||
public function __construct($byte_order, $biff_version)
|
public function __construct($byte_order, $biff_version)
|
||||||
{
|
{
|
||||||
|
|
@ -181,14 +179,14 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR
|
||||||
$this->_formula = ''; // The formula to parse.
|
$this->_formula = ''; // The formula to parse.
|
||||||
$this->_lookahead = ''; // The character ahead of the current char.
|
$this->_lookahead = ''; // The character ahead of the current char.
|
||||||
$this->_parse_tree = ''; // The parse tree to be generated.
|
$this->_parse_tree = ''; // The parse tree to be generated.
|
||||||
$this->_initializeHashes(); // Initialize the hashes: ptg's and function's ptg's
|
$this->_initializeHashes(); // Initialize the hashes: ptg's and public function's ptg's
|
||||||
$this->_byte_order = $byte_order; // Little Endian or Big Endian
|
$this->_byte_order = $byte_order; // Little Endian or Big Endian
|
||||||
$this->_ext_sheets = array();
|
$this->_ext_sheets = array();
|
||||||
$this->_references = array();
|
$this->_references = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the ptg and function hashes.
|
* Initialize the ptg and public function hashes.
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
|
|
@ -296,18 +294,18 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR
|
||||||
// Thanks to Michael Meeks and Gnumeric for the initial arg values.
|
// Thanks to Michael Meeks and Gnumeric for the initial arg values.
|
||||||
//
|
//
|
||||||
// The following hash was generated by "function_locale.pl" in the distro.
|
// The following hash was generated by "function_locale.pl" in the distro.
|
||||||
// Refer to function_locale.pl for non-English function names.
|
// Refer to function_locale.pl for non-English public function names.
|
||||||
//
|
//
|
||||||
// The array elements are as follow:
|
// The array elements are as follow:
|
||||||
// ptg: The Excel function ptg code.
|
// ptg: The Excel public function ptg code.
|
||||||
// args: The number of arguments that the function takes:
|
// args: The number of arguments that the public function takes:
|
||||||
// >=0 is a fixed number of arguments.
|
// >=0 is a fixed number of arguments.
|
||||||
// -1 is a variable number of arguments.
|
// -1 is a variable number of arguments.
|
||||||
// class: The reference, value or array class of the function args.
|
// class: The reference, value or array class of the public function args.
|
||||||
// vol: The function is volatile.
|
// vol: The public function is volatile.
|
||||||
//
|
//
|
||||||
$this->_functions = array(
|
$this->_functions = array(
|
||||||
// function ptg args class vol
|
// public function ptg args class vol
|
||||||
'COUNT' => array( 0, -1, 0, 0 ),
|
'COUNT' => array( 0, -1, 0, 0 ),
|
||||||
'IF' => array( 1, -1, 1, 0 ),
|
'IF' => array( 1, -1, 1, 0 ),
|
||||||
'ISNA' => array( 2, 1, 1, 0 ),
|
'ISNA' => array( 2, 1, 1, 0 ),
|
||||||
|
|
@ -603,7 +601,6 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param mixed $num an integer or double for conversion to its ptg value
|
* @param mixed $num an integer or double for conversion to its ptg value
|
||||||
* @return string
|
|
||||||
*/
|
*/
|
||||||
protected function _convertNumber($num)
|
protected function _convertNumber($num)
|
||||||
{
|
{
|
||||||
|
|
@ -643,13 +640,13 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a function to a ptgFunc or ptgFuncVarV depending on the number of
|
* Convert a public function to a ptgFunc or ptgFuncVarV depending on the number of
|
||||||
* args that it takes.
|
* args that it takes.
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param string $token The name of the function for convertion to ptg value.
|
* @param string $token The name of the public function for convertion to ptg value.
|
||||||
* @param integer $num_args The number of arguments the function receives.
|
* @param integer $num_args The number of arguments the public function receives.
|
||||||
* @return string The packed ptg for the function
|
* @return string The packed ptg for the public function
|
||||||
*/
|
*/
|
||||||
protected function _convertFunction($token, $num_args)
|
protected function _convertFunction($token, $num_args)
|
||||||
{
|
{
|
||||||
|
|
@ -667,13 +664,11 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert an Excel range such as A1:D4 to a ptgRefV.
|
* Convert an Excel range such as A1:D4 to a ptgRefV.
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param string $range An Excel range in the A1:A2 or A1..A2 format.
|
* @param string $range An Excel range in the A1:A2 or A1..A2 format.
|
||||||
* @param int $class
|
*/
|
||||||
* @return array|string
|
|
||||||
*/
|
|
||||||
protected function _convertRange2d($range, $class=0)
|
protected function _convertRange2d($range, $class=0)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
@ -1220,7 +1215,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR
|
||||||
default:
|
default:
|
||||||
// if it's a reference
|
// if it's a reference
|
||||||
if (preg_match('/^\$?[A-Ia-i]?[A-Za-z]\$?[0-9]+$/',$token) and
|
if (preg_match('/^\$?[A-Ia-i]?[A-Za-z]\$?[0-9]+$/',$token) and
|
||||||
!preg_match("/[0-9]/",$this->_lookahead) and
|
!preg_match("/[0-9]/",$this->_lookahead) and
|
||||||
($this->_lookahead != ':') and ($this->_lookahead != '.') and
|
($this->_lookahead != ':') and ($this->_lookahead != '.') and
|
||||||
($this->_lookahead != '!'))
|
($this->_lookahead != '!'))
|
||||||
{
|
{
|
||||||
|
|
@ -1241,13 +1236,13 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR
|
||||||
return $token;
|
return $token;
|
||||||
}
|
}
|
||||||
// if it's a range (A1:A2)
|
// if it's a range (A1:A2)
|
||||||
elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+:(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$token) and
|
elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+:(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$token) and
|
||||||
!preg_match("/[0-9]/",$this->_lookahead))
|
!preg_match("/[0-9]/",$this->_lookahead))
|
||||||
{
|
{
|
||||||
return $token;
|
return $token;
|
||||||
}
|
}
|
||||||
// if it's a range (A1..A2)
|
// if it's a range (A1..A2)
|
||||||
elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+\.\.(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$token) and
|
elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+\.\.(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$token) and
|
||||||
!preg_match("/[0-9]/",$this->_lookahead))
|
!preg_match("/[0-9]/",$this->_lookahead))
|
||||||
{
|
{
|
||||||
return $token;
|
return $token;
|
||||||
|
|
@ -1265,7 +1260,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR
|
||||||
return $token;
|
return $token;
|
||||||
}
|
}
|
||||||
// If it's a number (check that it's not a sheet name or range)
|
// If it's a number (check that it's not a sheet name or range)
|
||||||
elseif (is_numeric($token) and
|
elseif (is_numeric($token) and
|
||||||
(!is_numeric($token.$this->_lookahead) or ($this->_lookahead == '')) and
|
(!is_numeric($token.$this->_lookahead) or ($this->_lookahead == '')) and
|
||||||
($this->_lookahead != '!') and ($this->_lookahead != ':'))
|
($this->_lookahead != '!') and ($this->_lookahead != ':'))
|
||||||
{
|
{
|
||||||
|
|
@ -1276,7 +1271,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR
|
||||||
{
|
{
|
||||||
return $token;
|
return $token;
|
||||||
}
|
}
|
||||||
// if it's a function call
|
// if it's a public function call
|
||||||
elseif (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/i",$token) and ($this->_lookahead == "("))
|
elseif (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/i",$token) and ($this->_lookahead == "("))
|
||||||
{
|
{
|
||||||
return $token;
|
return $token;
|
||||||
|
|
@ -1422,7 +1417,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function just introduces a ptgParen element in the tree, so that Excel
|
* This public function just introduces a ptgParen element in the tree, so that Excel
|
||||||
* doesn't get confused when working with a parenthesized formula afterwards.
|
* doesn't get confused when working with a parenthesized formula afterwards.
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
|
|
@ -1514,7 +1509,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
// if it's a range
|
// if it's a range
|
||||||
elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+:(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$this->_current_token) or
|
elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+:(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$this->_current_token) or
|
||||||
preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+\.\.(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$this->_current_token))
|
preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+\.\.(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$this->_current_token))
|
||||||
{
|
{
|
||||||
$result = $this->_current_token;
|
$result = $this->_current_token;
|
||||||
|
|
@ -1541,7 +1536,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR
|
||||||
$this->_advance();
|
$this->_advance();
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
// if it's a function call
|
// if it's a public function call
|
||||||
elseif (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/i",$this->_current_token))
|
elseif (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/i",$this->_current_token))
|
||||||
{
|
{
|
||||||
$result = $this->_func();
|
$result = $this->_func();
|
||||||
|
|
@ -1553,7 +1548,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* It parses a function call. It assumes the following rule:
|
* It parses a public function call. It assumes the following rule:
|
||||||
* Func -> ( Expr [,Expr]* )
|
* Func -> ( Expr [,Expr]* )
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
|
|
@ -1575,7 +1570,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR
|
||||||
$this->_advance(); // eat the "," or ";"
|
$this->_advance(); // eat the "," or ";"
|
||||||
} else {
|
} else {
|
||||||
return $this->raiseError("Syntax error: comma expected in ".
|
return $this->raiseError("Syntax error: comma expected in ".
|
||||||
"function $function, arg #{$num_args}");
|
"public function $function, arg #{$num_args}");
|
||||||
}
|
}
|
||||||
$result2 = $this->_condition();
|
$result2 = $this->_condition();
|
||||||
if (PEAR::isError($result2)) {
|
if (PEAR::isError($result2)) {
|
||||||
|
|
@ -1597,7 +1592,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR
|
||||||
$args = $this->_functions[$function][1];
|
$args = $this->_functions[$function][1];
|
||||||
// If fixed number of args eg. TIME($i,$j,$k). Check that the number of args is valid.
|
// If fixed number of args eg. TIME($i,$j,$k). Check that the number of args is valid.
|
||||||
if (($args >= 0) and ($args != $num_args)) {
|
if (($args >= 0) and ($args != $num_args)) {
|
||||||
return $this->raiseError("Incorrect number of arguments in function $function() ");
|
return $this->raiseError("Incorrect number of arguments in public function $function() ");
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->_createTree($function, $result, $num_args);
|
$result = $this->_createTree($function, $result, $num_args);
|
||||||
|
|
@ -1679,14 +1674,14 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR
|
||||||
}
|
}
|
||||||
$polish .= $converted_tree;
|
$polish .= $converted_tree;
|
||||||
}
|
}
|
||||||
// if it's a function convert it here (so we can set it's arguments)
|
// if it's a public function convert it here (so we can set it's arguments)
|
||||||
if (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/",$tree['value']) and
|
if (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/",$tree['value']) and
|
||||||
!preg_match('/^([A-Ia-i]?[A-Za-z])(\d+)$/',$tree['value']) and
|
!preg_match('/^([A-Ia-i]?[A-Za-z])(\d+)$/',$tree['value']) and
|
||||||
!preg_match("/^[A-Ia-i]?[A-Za-z](\d+)\.\.[A-Ia-i]?[A-Za-z](\d+)$/",$tree['value']) and
|
!preg_match("/^[A-Ia-i]?[A-Za-z](\d+)\.\.[A-Ia-i]?[A-Za-z](\d+)$/",$tree['value']) and
|
||||||
!is_numeric($tree['value']) and
|
!is_numeric($tree['value']) and
|
||||||
!isset($this->ptg[$tree['value']]))
|
!isset($this->ptg[$tree['value']]))
|
||||||
{
|
{
|
||||||
// left subtree for a function is always an array.
|
// left subtree for a public function is always an array.
|
||||||
if ($tree['left'] != '') {
|
if ($tree['left'] != '') {
|
||||||
$left_tree = $this->toReversePolish($tree['left']);
|
$left_tree = $this->toReversePolish($tree['left']);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1706,5 +1701,4 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR
|
||||||
$polish .= $converted_tree;
|
$polish .= $converted_tree;
|
||||||
return $polish;
|
return $polish;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
@ -22,19 +22,21 @@
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
//require_once('PEAR.php');
|
||||||
|
|
||||||
// Possible operator types
|
// Possible operator types
|
||||||
|
|
||||||
/*
|
/*
|
||||||
FIXME: change prefixes
|
FIXME: change prefixes
|
||||||
*/
|
*/
|
||||||
define('OP_BETWEEN', 0x00);
|
define("OP_BETWEEN", 0x00);
|
||||||
define('OP_NOTBETWEEN', 0x01);
|
define("OP_NOTBETWEEN", 0x01);
|
||||||
define('OP_EQUAL', 0x02);
|
define("OP_EQUAL", 0x02);
|
||||||
define('OP_NOTEQUAL', 0x03);
|
define("OP_NOTEQUAL", 0x03);
|
||||||
define('OP_GT', 0x04);
|
define("OP_GT", 0x04);
|
||||||
define('OP_LT', 0x05);
|
define("OP_LT", 0x05);
|
||||||
define('OP_GTE', 0x06);
|
define("OP_GTE", 0x06);
|
||||||
define('OP_LTE', 0x07);
|
define("OP_LTE", 0x07);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Baseclass for generating Excel DV records (validations)
|
* Baseclass for generating Excel DV records (validations)
|
||||||
|
|
@ -148,7 +150,7 @@ class Spreadsheet_Excel_Writer_Validator
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function _getOptions()
|
protected function _getOptions()
|
||||||
{
|
{
|
||||||
$options = $this->_type;
|
$options = $this->_type;
|
||||||
$options |= $this->_style << 3;
|
$options |= $this->_style << 3;
|
||||||
|
|
@ -172,7 +174,7 @@ class Spreadsheet_Excel_Writer_Validator
|
||||||
return $options;
|
return $options;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function _getData()
|
protected 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);
|
||||||
|
|
@ -223,6 +225,4 @@ class Spreadsheet_Excel_Writer_Validator
|
||||||
$this->_incell = $incell;
|
$this->_incell = $incell;
|
||||||
//$this->_formula1 = ...;
|
//$this->_formula1 = ...;
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
?>
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -32,8 +32,10 @@
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once __DIR__ . '/Parser.php';
|
if (!class_exists('Spreadsheet_Excel_Writer_BIFFwriter')) {
|
||||||
require_once __DIR__ . '/BIFFwriter.php';
|
require_once 'Spreadsheet/Excel/Writer/Parser.php';
|
||||||
|
require_once 'Spreadsheet/Excel/Writer/BIFFwriter.php';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class for generating Excel Spreadsheets
|
* Class for generating Excel Spreadsheets
|
||||||
|
|
@ -373,49 +375,43 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
*/
|
*/
|
||||||
public $_input_encoding;
|
public $_input_encoding;
|
||||||
|
|
||||||
public $activesheet;
|
|
||||||
|
|
||||||
public $firstsheet;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param string $name The name of the new worksheet
|
* @param string $name The name of the new worksheet
|
||||||
* @param integer $index The index of the new worksheet
|
* @param integer $index The index of the new worksheet
|
||||||
* @param mixed $activeSheet The current activesheet of the workbook we belong to
|
* @param mixed $activesheet The current activesheet of the workbook we belong to
|
||||||
* @param mixed $firstSheet The first worksheet in the workbook we belong to
|
* @param mixed $firstsheet The first worksheet in the workbook we belong to
|
||||||
|
* @param int &$str_total Reference to the total number of strings in the workbook
|
||||||
|
* @param int &$str_unique Reference to the number of unique strings in the workbook
|
||||||
|
* @param array &$str_table Reference to the array containing all the unique strings in the workbook
|
||||||
* @param mixed $url_format The default format for hyperlinks
|
* @param mixed $url_format The default format for hyperlinks
|
||||||
* @param mixed $parser The formula parser created for the Workbook
|
* @param mixed $parser The formula parser created for the Workbook
|
||||||
* @param string $tmp_dir The path to the directory for temporary files
|
* @param string $tmp_dir The path to the directory for temporary files
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct($BIFF_version, $name,
|
||||||
$BIFF_version,
|
$index, $activesheet,
|
||||||
$name,
|
$firstsheet, &$str_total,
|
||||||
$index,
|
&$str_unique, &$str_table,
|
||||||
$activeSheet,
|
$url_format, $parser,
|
||||||
$firstSheet,
|
$tmp_dir)
|
||||||
$str_total,
|
|
||||||
$str_unique,
|
|
||||||
$str_table,
|
|
||||||
$url_format,
|
|
||||||
$parser,
|
|
||||||
$tmp_dir
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
// It needs to call its parent's constructor explicitly
|
// It needs to call its parent's constructor explicitly
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
$this->BIFF_version = $BIFF_version;
|
$this->_BIFF_version = $BIFF_version;
|
||||||
$rowmax = 65536; // 16384 in Excel 5
|
$rowmax = 65536; // 16384 in Excel 5
|
||||||
$colmax = 256;
|
$colmax = 256;
|
||||||
|
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
$this->index = $index;
|
$this->index = $index;
|
||||||
$this->activesheet = $activeSheet;
|
$this->activesheet = $activesheet;
|
||||||
$this->firstsheet = $firstSheet;
|
$this->firstsheet = $firstsheet;
|
||||||
$this->_str_total = $str_total;
|
// _str_total _str_unique _str_table - are actual references
|
||||||
$this->_str_unique = $str_unique;
|
// everything breaks if they're not
|
||||||
$this->_str_table = $str_table;
|
$this->_str_total = &$str_total;
|
||||||
|
$this->_str_unique = &$str_unique;
|
||||||
|
$this->_str_table = &$str_table;
|
||||||
$this->_url_format = $url_format;
|
$this->_url_format = $url_format;
|
||||||
$this->_parser = $parser;
|
$this->_parser = $parser;
|
||||||
|
|
||||||
|
|
@ -492,9 +488,9 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
$this->_input_encoding = '';
|
$this->_input_encoding = '';
|
||||||
|
|
||||||
$this->_dv = array();
|
$this->_dv = array();
|
||||||
|
|
||||||
$this->temporaryDirectory = $tmp_dir;
|
$this->_tmp_dir = $tmp_dir;
|
||||||
$this->temporaryFile = '';
|
$this->_tmp_file = '';
|
||||||
|
|
||||||
$this->_initialize();
|
$this->_initialize();
|
||||||
}
|
}
|
||||||
|
|
@ -512,20 +508,20 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->temporaryDirectory === '' && ini_get('open_basedir') === true) {
|
if ($this->_tmp_dir === '' && ini_get('open_basedir') === true) {
|
||||||
// open_basedir restriction in effect - store data in memory
|
// open_basedir restriction in effect - store data in memory
|
||||||
// ToDo: Let the error actually have an effect somewhere
|
// ToDo: Let the error actually have an effect somewhere
|
||||||
$this->_using_tmpfile = false;
|
$this->_using_tmpfile = false;
|
||||||
return new PEAR_Error('Temp file could not be opened since open_basedir restriction in effect - please use setTmpDir() - using memory storage instead');
|
return new PEAR_Error('Temp file could not be opened since open_basedir restriction in effect - please use setTmpDir() - using memory storage instead');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open tmp file for storing Worksheet data
|
// Open tmp file for storing Worksheet data
|
||||||
if ($this->temporaryDirectory === '') {
|
if ($this->_tmp_dir === '') {
|
||||||
$fh = tmpfile();
|
$fh = tmpfile();
|
||||||
} else {
|
} else {
|
||||||
// For people with open base dir restriction
|
// For people with open base dir restriction
|
||||||
$this->temporaryFile = tempnam($this->temporaryDirectory, 'Spreadsheet_Excel_Writer');
|
$this->_tmp_file = tempnam($this->_tmp_dir, "Spreadsheet_Excel_Writer");
|
||||||
$fh = @fopen($this->temporaryFile, 'w+b');
|
$fh = @fopen($this->_tmp_file, "w+b");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($fh === false) {
|
if ($fh === false) {
|
||||||
|
|
@ -604,7 +600,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
$this->_storeGridset();
|
$this->_storeGridset();
|
||||||
|
|
||||||
// Prepend GUTS
|
// Prepend GUTS
|
||||||
if ($this->BIFF_version == 0x0500) {
|
if ($this->_BIFF_version == 0x0500) {
|
||||||
$this->_storeGuts();
|
$this->_storeGuts();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -615,7 +611,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
$this->_storePrintHeaders();
|
$this->_storePrintHeaders();
|
||||||
|
|
||||||
// Prepend EXTERNSHEET references
|
// Prepend EXTERNSHEET references
|
||||||
if ($this->BIFF_version == 0x0500) {
|
if ($this->_BIFF_version == 0x0500) {
|
||||||
for ($i = $num_sheets; $i > 0; $i--) {
|
for ($i = $num_sheets; $i > 0; $i--) {
|
||||||
$sheetname = $sheetnames[$i-1];
|
$sheetname = $sheetnames[$i-1];
|
||||||
$this->_storeExternsheet($sheetname);
|
$this->_storeExternsheet($sheetname);
|
||||||
|
|
@ -623,7 +619,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepend the EXTERNCOUNT of external references.
|
// Prepend the EXTERNCOUNT of external references.
|
||||||
if ($this->BIFF_version == 0x0500) {
|
if ($this->_BIFF_version == 0x0500) {
|
||||||
$this->_storeExterncount($num_sheets);
|
$this->_storeExterncount($num_sheets);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -637,7 +633,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepend the BOF record
|
// Prepend the BOF record
|
||||||
$this->storeBof(0x0010);
|
$this->_storeBof(0x0010);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* End of prepend. Read upwards from here.
|
* End of prepend. Read upwards from here.
|
||||||
|
|
@ -652,18 +648,18 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
$this->_storeSelection($this->_selection);
|
$this->_storeSelection($this->_selection);
|
||||||
$this->_storeMergedCells();
|
$this->_storeMergedCells();
|
||||||
/* TODO: add data validity */
|
/* TODO: add data validity */
|
||||||
/*if ($this->BIFF_version == 0x0600) {
|
/*if ($this->_BIFF_version == 0x0600) {
|
||||||
$this->_storeDataValidity();
|
$this->_storeDataValidity();
|
||||||
}*/
|
}*/
|
||||||
$this->storeEof();
|
$this->_storeEof();
|
||||||
|
|
||||||
if ( $this->temporaryFile != '' ) {
|
if ( $this->_tmp_file != '' ) {
|
||||||
if ( $this->_filehandle ) {
|
if ( $this->_filehandle ) {
|
||||||
fclose($this->_filehandle);
|
fclose($this->_filehandle);
|
||||||
$this->_filehandle = '';
|
$this->_filehandle = '';
|
||||||
}
|
}
|
||||||
@unlink($this->temporaryFile);
|
@unlink($this->_tmp_file);
|
||||||
$this->temporaryFile = '';
|
$this->_tmp_file = '';
|
||||||
$this->_using_tmpfile = true;
|
$this->_using_tmpfile = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -691,9 +687,9 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
$buffer = 4096;
|
$buffer = 4096;
|
||||||
|
|
||||||
// Return data stored in memory
|
// Return data stored in memory
|
||||||
if (isset($this->data)) {
|
if (isset($this->_data)) {
|
||||||
$tmp = $this->data;
|
$tmp = $this->_data;
|
||||||
unset($this->data);
|
unset($this->_data);
|
||||||
$fh = $this->_filehandle;
|
$fh = $this->_filehandle;
|
||||||
if ($this->_using_tmpfile) {
|
if ($this->_using_tmpfile) {
|
||||||
fseek($fh, 0);
|
fseek($fh, 0);
|
||||||
|
|
@ -726,7 +722,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$max_record_ranges = floor(($this->limit - 6) / 8);
|
$max_record_ranges = floor(($this->_limit - 6) / 8);
|
||||||
if($this->_merged_cells_counter >= $max_record_ranges)
|
if($this->_merged_cells_counter >= $max_record_ranges)
|
||||||
{
|
{
|
||||||
$this->_merged_cells_record++;
|
$this->_merged_cells_record++;
|
||||||
|
|
@ -801,39 +797,39 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
* @param integer $level The optional outline level
|
* @param integer $level The optional outline level
|
||||||
*/
|
*/
|
||||||
public function setColumn($firstcol, $lastcol, $width, $format = null, $hidden = 0, $level = 0)
|
public function setColumn($firstcol, $lastcol, $width, $format = null, $hidden = 0, $level = 0)
|
||||||
{ // added by Dan Lynn <dan@spiderweblabs.com) on 2006-12-06
|
{ // added by Dan Lynn <dan@spiderweblabs.com) on 2006-12-06
|
||||||
// look for any ranges this might overlap and remove, size or split where necessary
|
// look for any ranges this might overlap and remove, size or split where necessary
|
||||||
foreach ($this->_colinfo as $key => $colinfo)
|
foreach ($this->_colinfo as $key => $colinfo)
|
||||||
{
|
{
|
||||||
$existing_start = $colinfo[0]; $existing_end = $colinfo[1];
|
$existing_start = $colinfo[0]; $existing_end = $colinfo[1];
|
||||||
// if the new range starts within another range
|
// if the new range starts within another range
|
||||||
if ($firstcol > $existing_start && $firstcol < $existing_end)
|
if ($firstcol > $existing_start && $firstcol < $existing_end)
|
||||||
{ // trim the existing range to the beginning of the new range
|
{ // trim the existing range to the beginning of the new range
|
||||||
$this->_colinfo[$key][1] = $firstcol - 1;
|
$this->_colinfo[$key][1] = $firstcol - 1;
|
||||||
// if the new range lies WITHIN the existing range
|
// if the new range lies WITHIN the existing range
|
||||||
if ($lastcol < $existing_end)
|
if ($lastcol < $existing_end)
|
||||||
{ // split the existing range by adding a range after our new range
|
{ // split the existing range by adding a range after our new range
|
||||||
$this->_colinfo[] = array($lastcol+1, $existing_end, $colinfo[2], &$colinfo[3], $colinfo[4], $colinfo[5]);
|
$this->_colinfo[] = array($lastcol+1, $existing_end, $colinfo[2], /* format */ $colinfo[3], $colinfo[4], $colinfo[5]);
|
||||||
}
|
}
|
||||||
} // if the new range ends inside an existing range
|
} // if the new range ends inside an existing range
|
||||||
elseif ($lastcol > $existing_start && $lastcol < $existing_end)
|
elseif ($lastcol > $existing_start && $lastcol < $existing_end)
|
||||||
{ // trim the existing range to the end of the new range
|
{ // trim the existing range to the end of the new range
|
||||||
$this->_colinfo[$key][0] = $lastcol + 1;
|
$this->_colinfo[$key][0] = $lastcol + 1;
|
||||||
} // if the new range completely overlaps the existing range
|
} // if the new range completely overlaps the existing range
|
||||||
elseif ($firstcol <= $existing_start && $lastcol >= $existing_end)
|
elseif ($firstcol <= $existing_start && $lastcol >= $existing_end)
|
||||||
{
|
{
|
||||||
unset($this->_colinfo[$key]);
|
unset($this->_colinfo[$key]);
|
||||||
}
|
}
|
||||||
} // added by Dan Lynn <dan@spiderweblabs.com) on 2006-12-06
|
} // added by Dan Lynn <dan@spiderweblabs.com) on 2006-12-06
|
||||||
// regenerate keys
|
// regenerate keys
|
||||||
$this->_colinfo = array_values($this->_colinfo);
|
$this->_colinfo = array_values($this->_colinfo);
|
||||||
$this->_colinfo[] = array($firstcol, $lastcol, $width, &$format, $hidden, $level);
|
$this->_colinfo[] = array($firstcol, $lastcol, $width, $format, $hidden, $level);
|
||||||
// Set width to zero if column is hidden
|
// Set width to zero if column is hidden
|
||||||
$width = ($hidden) ? 0 : $width;
|
$width = ($hidden) ? 0 : $width;
|
||||||
for ($col = $firstcol; $col <= $lastcol; $col++)
|
for ($col = $firstcol; $col <= $lastcol; $col++)
|
||||||
{
|
{
|
||||||
$this->col_sizes[$col] = $width;
|
$this->col_sizes[$col] = $width;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -1192,7 +1188,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
{
|
{
|
||||||
// Confine the scale to Excel's range
|
// Confine the scale to Excel's range
|
||||||
if ($scale < 10 || $scale > 400) {
|
if ($scale < 10 || $scale > 400) {
|
||||||
$this->raiseError('Zoom factor ' . $scale . ' outside range: 10 <= zoom <= 400');
|
$this->raiseError("Zoom factor $scale outside range: 10 <= zoom <= 400");
|
||||||
$scale = 100;
|
$scale = 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1349,13 +1345,13 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
{
|
{
|
||||||
if ($this->_using_tmpfile) {
|
if ($this->_using_tmpfile) {
|
||||||
// Add CONTINUE records if necessary
|
// Add CONTINUE records if necessary
|
||||||
if (strlen($data) > $this->limit) {
|
if (strlen($data) > $this->_limit) {
|
||||||
$data = $this->addContinue($data);
|
$data = $this->_addContinue($data);
|
||||||
}
|
}
|
||||||
fwrite($this->_filehandle, $data);
|
fwrite($this->_filehandle, $data);
|
||||||
$this->dataSize += strlen($data);
|
$this->_datasize += strlen($data);
|
||||||
} else {
|
} else {
|
||||||
parent::append($data);
|
parent::_append($data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1541,7 +1537,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
$header = pack("vv", $record, $length);
|
$header = pack("vv", $record, $length);
|
||||||
$data = pack("vvv", $row, $col, $xf);
|
$data = pack("vvv", $row, $col, $xf);
|
||||||
$xl_double = pack("d", $num);
|
$xl_double = pack("d", $num);
|
||||||
if ($this->byteOrder) { // if it's Big Endian
|
if ($this->_byte_order) { // if it's Big Endian
|
||||||
$xl_double = strrev($xl_double);
|
$xl_double = strrev($xl_double);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1566,7 +1562,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
*/
|
*/
|
||||||
public function writeString($row, $col, $str, $format = null)
|
public function writeString($row, $col, $str, $format = null)
|
||||||
{
|
{
|
||||||
if ($this->BIFF_version == 0x0600) {
|
if ($this->_BIFF_version == 0x0600) {
|
||||||
return $this->writeStringBIFF8($row, $col, $str, $format);
|
return $this->writeStringBIFF8($row, $col, $str, $format);
|
||||||
}
|
}
|
||||||
$strlen = strlen($str);
|
$strlen = strlen($str);
|
||||||
|
|
@ -1927,7 +1923,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the more general form of writeUrl(). It allows a hyperlink to be
|
* This is the more general form of writeUrl(). It allows a hyperlink to be
|
||||||
* written to a range of cells. This function also decides the type of hyperlink
|
* written to a range of cells. This public function also decides the type of hyperlink
|
||||||
* to be written. These are either, Web (http, ftp, mailto), Internal
|
* to be written. These are either, Web (http, ftp, mailto), Internal
|
||||||
* (Sheet1!A1) or external ('c:\temp\foo.xls#Sheet1!A1').
|
* (Sheet1!A1) or external ('c:\temp\foo.xls#Sheet1!A1').
|
||||||
*
|
*
|
||||||
|
|
@ -2106,19 +2102,19 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
if (preg_match('[^external:\\\\]', $url)) {
|
if (preg_match('[^external:\\\\]', $url)) {
|
||||||
return; //($this->_writeUrlExternal_net($row1, $col1, $row2, $col2, $url, $str, $format));
|
return; //($this->_writeUrlExternal_net($row1, $col1, $row2, $col2, $url, $str, $format));
|
||||||
}
|
}
|
||||||
|
|
||||||
$record = 0x01B8; // Record identifier
|
$record = 0x01B8; // Record identifier
|
||||||
$length = 0x00000; // Bytes to follow
|
$length = 0x00000; // Bytes to follow
|
||||||
|
|
||||||
if (!$format) {
|
if (!$format) {
|
||||||
$format = $this->_url_format;
|
$format = $this->_url_format;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Strip URL type and change Unix dir separator to Dos style (if needed)
|
// Strip URL type and change Unix dir separator to Dos style (if needed)
|
||||||
//
|
//
|
||||||
$url = preg_replace('/^external:/', '', $url);
|
$url = preg_replace('/^external:/', '', $url);
|
||||||
$url = preg_replace('/\//', "\\", $url);
|
$url = preg_replace('/\//', "\\", $url);
|
||||||
|
|
||||||
// Write the visible label
|
// Write the visible label
|
||||||
if ($str == '') {
|
if ($str == '') {
|
||||||
$str = preg_replace('/\#/', ' - ', $url);
|
$str = preg_replace('/\#/', ' - ', $url);
|
||||||
|
|
@ -2127,12 +2123,12 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
if (($str_error == -2) or ($str_error == -3)) {
|
if (($str_error == -2) or ($str_error == -3)) {
|
||||||
return $str_error;
|
return $str_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine if the link is relative or absolute:
|
// Determine if the link is relative or absolute:
|
||||||
// relative if link contains no dir separator, "somefile.xls"
|
// relative if link contains no dir separator, "somefile.xls"
|
||||||
// relative if link starts with up-dir, "..\..\somefile.xls"
|
// relative if link starts with up-dir, "..\..\somefile.xls"
|
||||||
// otherwise, absolute
|
// otherwise, absolute
|
||||||
|
|
||||||
$absolute = 0x02; // Bit mask
|
$absolute = 0x02; // Bit mask
|
||||||
if (!preg_match("/\\\/", $url)) {
|
if (!preg_match("/\\\/", $url)) {
|
||||||
$absolute = 0x00;
|
$absolute = 0x00;
|
||||||
|
|
@ -2141,7 +2137,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
$absolute = 0x00;
|
$absolute = 0x00;
|
||||||
}
|
}
|
||||||
$link_type = 0x01 | $absolute;
|
$link_type = 0x01 | $absolute;
|
||||||
|
|
||||||
// Determine if the link contains a sheet reference and change some of the
|
// Determine if the link contains a sheet reference and change some of the
|
||||||
// parameters accordingly.
|
// parameters accordingly.
|
||||||
// Split the dir name and sheet name (if it exists)
|
// Split the dir name and sheet name (if it exists)
|
||||||
|
|
@ -2150,7 +2146,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
} else {
|
} else {
|
||||||
$dir_long = $url;
|
$dir_long = $url;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($sheet)) {
|
if (isset($sheet)) {
|
||||||
$link_type |= 0x08;
|
$link_type |= 0x08;
|
||||||
$sheet_len = pack("V", strlen($sheet) + 0x01);
|
$sheet_len = pack("V", strlen($sheet) + 0x01);
|
||||||
|
|
@ -2166,32 +2162,32 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Pack the link type
|
// Pack the link type
|
||||||
$link_type = pack("V", $link_type);
|
$link_type = pack("V", $link_type);
|
||||||
|
|
||||||
// Calculate the up-level dir count e.g.. (..\..\..\ == 3)
|
// Calculate the up-level dir count e.g.. (..\..\..\ == 3)
|
||||||
$up_count = preg_match_all("/\.\.\\\/", $dir_long, $useless);
|
$up_count = preg_match_all("/\.\.\\\/", $dir_long, $useless);
|
||||||
$up_count = pack("v", $up_count);
|
$up_count = pack("v", $up_count);
|
||||||
|
|
||||||
// Store the short dos dir name (null terminated)
|
// Store the short dos dir name (null terminated)
|
||||||
$dir_short = preg_replace("/\.\.\\\/", '', $dir_long) . "\0";
|
$dir_short = preg_replace("/\.\.\\\/", '', $dir_long) . "\0";
|
||||||
|
|
||||||
// Store the long dir name as a wchar string (non-null terminated)
|
// Store the long dir name as a wchar string (non-null terminated)
|
||||||
//$dir_long = join("\0", split('', $dir_long));
|
//$dir_long = join("\0", split('', $dir_long));
|
||||||
$dir_long = $dir_long . "\0";
|
$dir_long = $dir_long . "\0";
|
||||||
|
|
||||||
// Pack the lengths of the dir strings
|
// Pack the lengths of the dir strings
|
||||||
$dir_short_len = pack("V", strlen($dir_short) );
|
$dir_short_len = pack("V", strlen($dir_short) );
|
||||||
$dir_long_len = pack("V", strlen($dir_long) );
|
$dir_long_len = pack("V", strlen($dir_long) );
|
||||||
$stream_len = pack("V", 0);//strlen($dir_long) + 0x06);
|
$stream_len = pack("V", 0);//strlen($dir_long) + 0x06);
|
||||||
|
|
||||||
// Pack the undocumented parts of the hyperlink stream
|
// Pack the undocumented parts of the hyperlink stream
|
||||||
$unknown1 = pack("H*",'D0C9EA79F9BACE118C8200AA004BA90B02000000' );
|
$unknown1 = pack("H*",'D0C9EA79F9BACE118C8200AA004BA90B02000000' );
|
||||||
$unknown2 = pack("H*",'0303000000000000C000000000000046' );
|
$unknown2 = pack("H*",'0303000000000000C000000000000046' );
|
||||||
$unknown3 = pack("H*",'FFFFADDE000000000000000000000000000000000000000');
|
$unknown3 = pack("H*",'FFFFADDE000000000000000000000000000000000000000');
|
||||||
$unknown4 = pack("v", 0x03 );
|
$unknown4 = pack("v", 0x03 );
|
||||||
|
|
||||||
// Pack the main data stream
|
// Pack the main data stream
|
||||||
$data = pack("vvvv", $row1, $row2, $col1, $col2) .
|
$data = pack("vvvv", $row1, $row2, $col1, $col2) .
|
||||||
$unknown1 .
|
$unknown1 .
|
||||||
|
|
@ -2207,11 +2203,11 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
$dir_long .
|
$dir_long .
|
||||||
$sheet_len .
|
$sheet_len .
|
||||||
$sheet ;*/
|
$sheet ;*/
|
||||||
|
|
||||||
// Pack the header data
|
// Pack the header data
|
||||||
$length = strlen($data);
|
$length = strlen($data);
|
||||||
$header = pack("vv", $record, $length);
|
$header = pack("vv", $record, $length);
|
||||||
|
|
||||||
// Write the packed data
|
// Write the packed data
|
||||||
$this->_append($header. $data);
|
$this->_append($header. $data);
|
||||||
return($str_error);
|
return($str_error);
|
||||||
|
|
@ -2291,17 +2287,17 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
$col_max = $this->_dim_colmax + 1; // Last column plus 1
|
$col_max = $this->_dim_colmax + 1; // Last column plus 1
|
||||||
$reserved = 0x0000; // Reserved by Excel
|
$reserved = 0x0000; // Reserved by Excel
|
||||||
|
|
||||||
if ($this->BIFF_version == 0x0500) {
|
if ($this->_BIFF_version == 0x0500) {
|
||||||
$length = 0x000A; // Number of bytes to follow
|
$length = 0x000A; // Number of bytes to follow
|
||||||
$data = pack("vvvvv", $row_min, $row_max,
|
$data = pack("vvvvv", $row_min, $row_max,
|
||||||
$col_min, $col_max, $reserved);
|
$col_min, $col_max, $reserved);
|
||||||
} elseif ($this->BIFF_version == 0x0600) {
|
} elseif ($this->_BIFF_version == 0x0600) {
|
||||||
$length = 0x000E;
|
$length = 0x000E;
|
||||||
$data = pack("VVvvv", $row_min, $row_max,
|
$data = pack("VVvvv", $row_min, $row_max,
|
||||||
$col_min, $col_max, $reserved);
|
$col_min, $col_max, $reserved);
|
||||||
}
|
}
|
||||||
$header = pack("vv", $record, $length);
|
$header = pack("vv", $record, $length);
|
||||||
$this->prepend($header.$data);
|
$this->_prepend($header.$data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -2312,9 +2308,9 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
protected function _storeWindow2()
|
protected function _storeWindow2()
|
||||||
{
|
{
|
||||||
$record = 0x023E; // Record identifier
|
$record = 0x023E; // Record identifier
|
||||||
if ($this->BIFF_version == 0x0500) {
|
if ($this->_BIFF_version == 0x0500) {
|
||||||
$length = 0x000A; // Number of bytes to follow
|
$length = 0x000A; // Number of bytes to follow
|
||||||
} elseif ($this->BIFF_version == 0x0600) {
|
} elseif ($this->_BIFF_version == 0x0600) {
|
||||||
$length = 0x0012;
|
$length = 0x0012;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2351,10 +2347,10 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
$header = pack("vv", $record, $length);
|
$header = pack("vv", $record, $length);
|
||||||
$data = pack("vvv", $grbit, $rwTop, $colLeft);
|
$data = pack("vvv", $grbit, $rwTop, $colLeft);
|
||||||
// FIXME !!!
|
// FIXME !!!
|
||||||
if ($this->BIFF_version == 0x0500) {
|
if ($this->_BIFF_version == 0x0500) {
|
||||||
$rgbHdr = 0x00000000; // Row/column heading and gridline color
|
$rgbHdr = 0x00000000; // Row/column heading and gridline color
|
||||||
$data .= pack("V", $rgbHdr);
|
$data .= pack("V", $rgbHdr);
|
||||||
} elseif ($this->BIFF_version == 0x0600) {
|
} elseif ($this->_BIFF_version == 0x0600) {
|
||||||
$rgbHdr = 0x0040; // Row/column heading and gridline color index
|
$rgbHdr = 0x0040; // Row/column heading and gridline color index
|
||||||
$zoom_factor_page_break = 0x0000;
|
$zoom_factor_page_break = 0x0000;
|
||||||
$zoom_factor_normal = 0x0000;
|
$zoom_factor_normal = 0x0000;
|
||||||
|
|
@ -2376,7 +2372,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
|
|
||||||
$header = pack("vv", $record, $length);
|
$header = pack("vv", $record, $length);
|
||||||
$data = pack("v", $colwidth);
|
$data = pack("v", $colwidth);
|
||||||
$this->prepend($header . $data);
|
$this->_prepend($header . $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -2437,7 +2433,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
$header = pack("vv", $record, $length);
|
$header = pack("vv", $record, $length);
|
||||||
$data = pack("vvvvvC", $colFirst, $colLast, $coldx,
|
$data = pack("vvvvvC", $colFirst, $colLast, $coldx,
|
||||||
$ixfe, $grbit, $reserved);
|
$ixfe, $grbit, $reserved);
|
||||||
$this->prepend($header.$data);
|
$this->_prepend($header.$data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -2497,10 +2493,10 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
$record = 0x00E5;
|
$record = 0x00E5;
|
||||||
foreach($this->_merged_ranges as $ranges)
|
foreach($this->_merged_ranges as $ranges)
|
||||||
{
|
{
|
||||||
$length = 2 + count($ranges) * 8;
|
$length = 2 + count($ranges) * 8;
|
||||||
$header = pack('vv', $record, $length);
|
$header = pack('vv', $record, $length);
|
||||||
$data = pack('v', count($ranges));
|
$data = pack('v', count($ranges));
|
||||||
foreach ($ranges as $range)
|
foreach ($ranges as $range)
|
||||||
$data .= pack('vvvv', $range[0], $range[2], $range[1], $range[3]);
|
$data .= pack('vvvv', $range[0], $range[2], $range[1], $range[3]);
|
||||||
$string = $header.$data;
|
$string = $header.$data;
|
||||||
$this->_append($string, true);
|
$this->_append($string, true);
|
||||||
|
|
@ -2527,7 +2523,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
|
|
||||||
$header = pack("vv", $record, $length);
|
$header = pack("vv", $record, $length);
|
||||||
$data = pack("v", $count);
|
$data = pack("v", $count);
|
||||||
$this->prepend($header . $data);
|
$this->_prepend($header . $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -2559,7 +2555,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
|
|
||||||
$header = pack("vv", $record, $length);
|
$header = pack("vv", $record, $length);
|
||||||
$data = pack("CC", $cch, $rgch);
|
$data = pack("CC", $cch, $rgch);
|
||||||
$this->prepend($header . $data . $sheetname);
|
$this->_prepend($header . $data . $sheetname);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -2685,7 +2681,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
|
|
||||||
$numHdr = pack("d", $numHdr);
|
$numHdr = pack("d", $numHdr);
|
||||||
$numFtr = pack("d", $numFtr);
|
$numFtr = pack("d", $numFtr);
|
||||||
if ($this->byteOrder) { // if it's Big Endian
|
if ($this->_byte_order) { // if it's Big Endian
|
||||||
$numHdr = strrev($numHdr);
|
$numHdr = strrev($numHdr);
|
||||||
$numFtr = strrev($numFtr);
|
$numFtr = strrev($numFtr);
|
||||||
}
|
}
|
||||||
|
|
@ -2701,7 +2697,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
$iVRes);
|
$iVRes);
|
||||||
$data2 = $numHdr.$numFtr;
|
$data2 = $numHdr.$numFtr;
|
||||||
$data3 = pack("v", $iCopies);
|
$data3 = pack("v", $iCopies);
|
||||||
$this->prepend($header . $data1 . $data2 . $data3);
|
$this->_prepend($header . $data1 . $data2 . $data3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -2715,7 +2711,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
|
|
||||||
$str = $this->_header; // header string
|
$str = $this->_header; // header string
|
||||||
$cch = strlen($str); // Length of header string
|
$cch = strlen($str); // Length of header string
|
||||||
if ($this->BIFF_version == 0x0600) {
|
if ($this->_BIFF_version == 0x0600) {
|
||||||
$encoding = 0x0; // TODO: Unicode support
|
$encoding = 0x0; // TODO: Unicode support
|
||||||
$length = 3 + $cch; // Bytes to follow
|
$length = 3 + $cch; // Bytes to follow
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -2723,13 +2719,13 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
}
|
}
|
||||||
|
|
||||||
$header = pack("vv", $record, $length);
|
$header = pack("vv", $record, $length);
|
||||||
if ($this->BIFF_version == 0x0600) {
|
if ($this->_BIFF_version == 0x0600) {
|
||||||
$data = pack("vC", $cch, $encoding);
|
$data = pack("vC", $cch, $encoding);
|
||||||
} else {
|
} else {
|
||||||
$data = pack("C", $cch);
|
$data = pack("C", $cch);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->prepend($header.$data.$str);
|
$this->_prepend($header.$data.$str);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -2743,7 +2739,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
|
|
||||||
$str = $this->_footer; // Footer string
|
$str = $this->_footer; // Footer string
|
||||||
$cch = strlen($str); // Length of footer string
|
$cch = strlen($str); // Length of footer string
|
||||||
if ($this->BIFF_version == 0x0600) {
|
if ($this->_BIFF_version == 0x0600) {
|
||||||
$encoding = 0x0; // TODO: Unicode support
|
$encoding = 0x0; // TODO: Unicode support
|
||||||
$length = 3 + $cch; // Bytes to follow
|
$length = 3 + $cch; // Bytes to follow
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -2751,13 +2747,13 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
}
|
}
|
||||||
|
|
||||||
$header = pack("vv", $record, $length);
|
$header = pack("vv", $record, $length);
|
||||||
if ($this->BIFF_version == 0x0600) {
|
if ($this->_BIFF_version == 0x0600) {
|
||||||
$data = pack("vC", $cch, $encoding);
|
$data = pack("vC", $cch, $encoding);
|
||||||
} else {
|
} else {
|
||||||
$data = pack("C", $cch);
|
$data = pack("C", $cch);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->prepend($header . $data . $str);
|
$this->_prepend($header . $data . $str);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -2775,7 +2771,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
$header = pack("vv", $record, $length);
|
$header = pack("vv", $record, $length);
|
||||||
$data = pack("v", $fHCenter);
|
$data = pack("v", $fHCenter);
|
||||||
|
|
||||||
$this->prepend($header.$data);
|
$this->_prepend($header.$data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -2792,7 +2788,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
|
|
||||||
$header = pack("vv", $record, $length);
|
$header = pack("vv", $record, $length);
|
||||||
$data = pack("v", $fVCenter);
|
$data = pack("v", $fVCenter);
|
||||||
$this->prepend($header . $data);
|
$this->_prepend($header . $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -2809,11 +2805,11 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
|
|
||||||
$header = pack("vv", $record, $length);
|
$header = pack("vv", $record, $length);
|
||||||
$data = pack("d", $margin);
|
$data = pack("d", $margin);
|
||||||
if ($this->byteOrder) { // if it's Big Endian
|
if ($this->_byte_order) { // if it's Big Endian
|
||||||
$data = strrev($data);
|
$data = strrev($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->prepend($header . $data);
|
$this->_prepend($header . $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -2830,11 +2826,11 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
|
|
||||||
$header = pack("vv", $record, $length);
|
$header = pack("vv", $record, $length);
|
||||||
$data = pack("d", $margin);
|
$data = pack("d", $margin);
|
||||||
if ($this->byteOrder) { // if it's Big Endian
|
if ($this->_byte_order) { // if it's Big Endian
|
||||||
$data = strrev($data);
|
$data = strrev($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->prepend($header . $data);
|
$this->_prepend($header . $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -2851,11 +2847,11 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
|
|
||||||
$header = pack("vv", $record, $length);
|
$header = pack("vv", $record, $length);
|
||||||
$data = pack("d", $margin);
|
$data = pack("d", $margin);
|
||||||
if ($this->byteOrder) { // if it's Big Endian
|
if ($this->_byte_order) { // if it's Big Endian
|
||||||
$data = strrev($data);
|
$data = strrev($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->prepend($header . $data);
|
$this->_prepend($header . $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -2872,11 +2868,11 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
|
|
||||||
$header = pack("vv", $record, $length);
|
$header = pack("vv", $record, $length);
|
||||||
$data = pack("d", $margin);
|
$data = pack("d", $margin);
|
||||||
if ($this->byteOrder) { // if it's Big Endian
|
if ($this->_byte_order) { // if it's Big Endian
|
||||||
$data = strrev($data);
|
$data = strrev($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->prepend($header . $data);
|
$this->_prepend($header . $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -2926,7 +2922,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
|
|
||||||
$header = pack("vv", $record, $length);
|
$header = pack("vv", $record, $length);
|
||||||
$data = pack("v", $fPrintRwCol);
|
$data = pack("v", $fPrintRwCol);
|
||||||
$this->prepend($header . $data);
|
$this->_prepend($header . $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -2944,7 +2940,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
|
|
||||||
$header = pack("vv", $record, $length);
|
$header = pack("vv", $record, $length);
|
||||||
$data = pack("v", $fPrintGrid);
|
$data = pack("v", $fPrintGrid);
|
||||||
$this->prepend($header . $data);
|
$this->_prepend($header . $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -2962,7 +2958,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
|
|
||||||
$header = pack("vv", $record, $length);
|
$header = pack("vv", $record, $length);
|
||||||
$data = pack("v", $fGridSet);
|
$data = pack("v", $fGridSet);
|
||||||
$this->prepend($header . $data);
|
$this->_prepend($header . $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -3008,7 +3004,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
$header = pack("vv", $record, $length);
|
$header = pack("vv", $record, $length);
|
||||||
$data = pack("vvvv", $dxRwGut, $dxColGut, $row_level, $col_level);
|
$data = pack("vvvv", $dxRwGut, $dxColGut, $row_level, $col_level);
|
||||||
|
|
||||||
$this->prepend($header.$data);
|
$this->_prepend($header.$data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -3052,7 +3048,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
|
|
||||||
$header = pack("vv", $record, $length);
|
$header = pack("vv", $record, $length);
|
||||||
$data = pack("v", $grbit);
|
$data = pack("v", $grbit);
|
||||||
$this->prepend($header . $data);
|
$this->_prepend($header . $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -3076,7 +3072,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
|
|
||||||
$record = 0x001b; // Record identifier
|
$record = 0x001b; // Record identifier
|
||||||
$cbrk = count($breaks); // Number of page breaks
|
$cbrk = count($breaks); // Number of page breaks
|
||||||
if ($this->BIFF_version == 0x0600) {
|
if ($this->_BIFF_version == 0x0600) {
|
||||||
$length = 2 + 6*$cbrk; // Bytes to follow
|
$length = 2 + 6*$cbrk; // Bytes to follow
|
||||||
} else {
|
} else {
|
||||||
$length = 2 + 2*$cbrk; // Bytes to follow
|
$length = 2 + 2*$cbrk; // Bytes to follow
|
||||||
|
|
@ -3087,14 +3083,14 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
|
|
||||||
// Append each page break
|
// Append each page break
|
||||||
foreach ($breaks as $break) {
|
foreach ($breaks as $break) {
|
||||||
if ($this->BIFF_version == 0x0600) {
|
if ($this->_BIFF_version == 0x0600) {
|
||||||
$data .= pack("vvv", $break, 0x0000, 0x00ff);
|
$data .= pack("vvv", $break, 0x0000, 0x00ff);
|
||||||
} else {
|
} else {
|
||||||
$data .= pack("v", $break);
|
$data .= pack("v", $break);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->prepend($header.$data);
|
$this->_prepend($header.$data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -3122,7 +3118,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
|
|
||||||
$record = 0x001a; // Record identifier
|
$record = 0x001a; // Record identifier
|
||||||
$cbrk = count($breaks); // Number of page breaks
|
$cbrk = count($breaks); // Number of page breaks
|
||||||
if ($this->BIFF_version == 0x0600) {
|
if ($this->_BIFF_version == 0x0600) {
|
||||||
$length = 2 + 6*$cbrk; // Bytes to follow
|
$length = 2 + 6*$cbrk; // Bytes to follow
|
||||||
} else {
|
} else {
|
||||||
$length = 2 + 2*$cbrk; // Bytes to follow
|
$length = 2 + 2*$cbrk; // Bytes to follow
|
||||||
|
|
@ -3133,14 +3129,14 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
|
|
||||||
// Append each page break
|
// Append each page break
|
||||||
foreach ($breaks as $break) {
|
foreach ($breaks as $break) {
|
||||||
if ($this->BIFF_version == 0x0600) {
|
if ($this->_BIFF_version == 0x0600) {
|
||||||
$data .= pack("vvv", $break, 0x0000, 0xffff);
|
$data .= pack("vvv", $break, 0x0000, 0xffff);
|
||||||
} else {
|
} else {
|
||||||
$data .= pack("v", $break);
|
$data .= pack("v", $break);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->prepend($header . $data);
|
$this->_prepend($header . $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -3163,7 +3159,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
$header = pack("vv", $record, $length);
|
$header = pack("vv", $record, $length);
|
||||||
$data = pack("v", $fLock);
|
$data = pack("v", $fLock);
|
||||||
|
|
||||||
$this->prepend($header.$data);
|
$this->_prepend($header.$data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -3186,7 +3182,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
$header = pack("vv", $record, $length);
|
$header = pack("vv", $record, $length);
|
||||||
$data = pack("v", $wPassword);
|
$data = pack("v", $wPassword);
|
||||||
|
|
||||||
$this->prepend($header . $data);
|
$this->_prepend($header . $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -3254,7 +3250,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
* The width and height of the cells are also variable and have to be taken into
|
* The width and height of the cells are also variable and have to be taken into
|
||||||
* account.
|
* account.
|
||||||
* The values of $col_start and $row_start are passed in from the calling
|
* The values of $col_start and $row_start are passed in from the calling
|
||||||
* function. The values of $col_end and $row_end are calculated by subtracting
|
* public function. The values of $col_end and $row_end are calculated by subtracting
|
||||||
* the width and height of the bitmap from the width and height of the
|
* the width and height of the bitmap from the width and height of the
|
||||||
* underlying cells.
|
* underlying cells.
|
||||||
* The vertices are expressed as a percentage of the underlying cell width as
|
* The vertices are expressed as a percentage of the underlying cell width as
|
||||||
|
|
@ -3608,5 +3604,4 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
||||||
$this->_append($header . $dv);
|
$this->_append($header . $dv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
@ -23,8 +23,12 @@
|
||||||
],
|
],
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-0": {
|
"psr-0": {
|
||||||
"Spreadsheet": "./",
|
"Spreadsheet": ""
|
||||||
"Test": "./test"
|
}
|
||||||
|
},
|
||||||
|
"autoload-dev": {
|
||||||
|
"psr-0": {
|
||||||
|
"Test": "test"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"description": "More info available on: http://pear.php.net/package/Spreadsheet_Excel_Writer",
|
"description": "More info available on: http://pear.php.net/package/Spreadsheet_Excel_Writer",
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<phpunit bootstrap="test/bootstrap.php"
|
<phpunit bootstrap="vendor/autoload.php"
|
||||||
cacheTokens="false"
|
cacheTokens="false"
|
||||||
colors="true"
|
colors="true"
|
||||||
convertErrorsToExceptions="true"
|
convertErrorsToExceptions="true"
|
||||||
|
|
@ -14,4 +14,15 @@
|
||||||
<directory>test/</directory>
|
<directory>test/</directory>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
</testsuites>
|
</testsuites>
|
||||||
|
|
||||||
|
<filter>
|
||||||
|
<whitelist>
|
||||||
|
<directory suffix=".php">Spreadsheet/</directory>
|
||||||
|
</whitelist>
|
||||||
|
</filter>
|
||||||
|
|
||||||
|
<logging>
|
||||||
|
<log type="coverage-clover" target="build/logs/clover.xml"/>
|
||||||
|
<log type="coverage-text" target="php://stdout"/>
|
||||||
|
</logging>
|
||||||
</phpunit>
|
</phpunit>
|
||||||
|
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author stev leibelt <artodeto@bazzline.net>
|
|
||||||
* @since 2016-01-17
|
|
||||||
*/
|
|
||||||
class Test_Spreadsheet_Excel_WriterTestCase extends PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param string $fileName
|
|
||||||
* @return Spreadsheet_Excel_Writer_Workbook
|
|
||||||
*/
|
|
||||||
protected function getNewWorkbook($fileName = 'my_workbook')
|
|
||||||
{
|
|
||||||
return new Spreadsheet_Excel_Writer_Workbook($fileName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author stev leibelt <artodeto@bazzline.net>
|
|
||||||
* @since 2016-01-17
|
|
||||||
*/
|
|
||||||
class Test_Spreadsheet_Excel_Writer_WorkbookTest extends Test_Spreadsheet_Excel_WriterTestCase
|
|
||||||
{
|
|
||||||
public function testSetVersion()
|
|
||||||
{
|
|
||||||
$workbook = $this->getNewWorkbook();
|
|
||||||
|
|
||||||
$workbook->setVersion(8);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,75 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author stev leibelt <artodeto@bazzline.net>
|
||||||
|
* @since 2016-01-17
|
||||||
|
*/
|
||||||
|
class Test_Spreadsheet_Excel_Writer_WorkbookTest extends Test_Spreadsheet_Excel_WriterTestCase
|
||||||
|
{
|
||||||
|
public function testSetVersion()
|
||||||
|
{
|
||||||
|
$workbook = $this->getNewWorkbook();
|
||||||
|
|
||||||
|
$before = get_object_vars($workbook);
|
||||||
|
|
||||||
|
$workbook->setVersion(1);
|
||||||
|
|
||||||
|
$this->assertEquals($before, get_object_vars($workbook), "Version 1 should not change internal state");
|
||||||
|
|
||||||
|
$workbook->setVersion(8);
|
||||||
|
|
||||||
|
$this->assertNotEquals($before, get_object_vars($workbook), "Version 8 should change internal state");
|
||||||
|
|
||||||
|
return $workbook;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @depends testSetVersion
|
||||||
|
*/
|
||||||
|
public function testWriteSingleCell(Spreadsheet_Excel_Writer $workbook)
|
||||||
|
{
|
||||||
|
$sheet = $workbook->addWorksheet("Example");
|
||||||
|
$sheet->write(0, 0, "Example");
|
||||||
|
|
||||||
|
$this->assertSameAsInFixture('example.xls', $workbook);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testWriteWithFormat()
|
||||||
|
{
|
||||||
|
$workbook = $this->getNewWorkbook();
|
||||||
|
$workbook->setVersion(8);
|
||||||
|
|
||||||
|
$format = $workbook->addFormat();
|
||||||
|
$format->setFontFamily('Helvetica');
|
||||||
|
$format->setSize(16);
|
||||||
|
$format->setVAlign('vcenter');
|
||||||
|
$format->setBorder(1);
|
||||||
|
|
||||||
|
$sheet = $workbook->addWorksheet('Example report');
|
||||||
|
$sheet->setInputEncoding('utf-8');
|
||||||
|
|
||||||
|
$sheet->setColumn(0, 10, 35);
|
||||||
|
|
||||||
|
$sheet->writeString(0, 0, "Test string", $format);
|
||||||
|
$sheet->setRow(0, 40);
|
||||||
|
|
||||||
|
$sheet->writeString(1, 0, "こんにちわ");
|
||||||
|
|
||||||
|
$this->assertSameAsInFixture('with_format.xls', $workbook);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testWithDefaultVersion()
|
||||||
|
{
|
||||||
|
$workbook = $this->getNewWorkbook();
|
||||||
|
|
||||||
|
$sheet = $workbook->addWorksheet("Example");
|
||||||
|
|
||||||
|
for ($i = 0; $i < 10; $i++) {
|
||||||
|
for ($j = 0; $j < 10; $j++) {
|
||||||
|
$sheet->write($i, $j, "Row $i $j");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->assertSameAsInFixture('example2.xls', $workbook);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,55 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author stev leibelt <artodeto@bazzline.net>
|
||||||
|
* @since 2016-01-17
|
||||||
|
*/
|
||||||
|
class Test_Spreadsheet_Excel_WriterTestCase extends PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
const FIXTURES_PATH = 'test/fixture/';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $filename
|
||||||
|
* @return Spreadsheet_Excel_Writer
|
||||||
|
*/
|
||||||
|
protected function getNewWorkbook($filename = '')
|
||||||
|
{
|
||||||
|
// we're writing to the standard output by defaulr
|
||||||
|
return new Spreadsheet_Excel_Writer($filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function assertSameAsInFixture($filename, Spreadsheet_Excel_Writer $workbook)
|
||||||
|
{
|
||||||
|
$this->assertEmpty($workbook->_filename, "Testing with fixtures works only for standard output");
|
||||||
|
|
||||||
|
// we have to fix timestamp for fixtures to work
|
||||||
|
$workbook->_timestamp = 1000000000; // somewhere in 2001
|
||||||
|
|
||||||
|
ob_start();
|
||||||
|
$workbook->close();
|
||||||
|
$data = ob_get_clean();
|
||||||
|
|
||||||
|
$fullPath = self::FIXTURES_PATH.$filename;
|
||||||
|
|
||||||
|
if ($this->shouldUpdateFixtures()) {
|
||||||
|
file_put_contents($fullPath, $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_file($fullPath)) {
|
||||||
|
$this->fail("Fixture $filename not found");
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: should we save data for future analysis?
|
||||||
|
//file_put_contents("{$fullPath}.work", $data);
|
||||||
|
|
||||||
|
$this->assertEquals(file_get_contents($fullPath), $data, "Output differs for $filename");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* We should update golden files
|
||||||
|
*/
|
||||||
|
private function shouldUpdateFixtures()
|
||||||
|
{
|
||||||
|
return isset($_SERVER['GOLDEN']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
require_once __DIR__ . '/../vendor/autoload.php';
|
|
||||||
require_once __DIR__ . '/Test/Spreadsheet/Excel/Writer/Test_Spreadsheet_Excel_WriterTestCase.php'; //@todo fix this
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue