Merge branch 'psr2' into develop

This commit is contained in:
MarkBaker 2015-05-22 23:32:07 +01:00
commit 4c0434d608
11 changed files with 1029 additions and 1067 deletions

View File

@ -43,7 +43,7 @@ class PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE
* *
* @var PHPExcel_Shared_Escher_DggContainer_BstoreContainer * @var PHPExcel_Shared_Escher_DggContainer_BstoreContainer
*/ */
private $_parent; private $parent;
/** /**
* The BLIP (Big Large Image or Picture) * The BLIP (Big Large Image or Picture)
@ -66,7 +66,7 @@ class PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE
*/ */
public function setParent($parent) public function setParent($parent)
{ {
$this->_parent = $parent; $this->parent = $parent;
} }
/** /**

View File

@ -73,7 +73,7 @@ class PHPExcel_Writer_Excel2007_Comments extends PHPExcel_Writer_Excel2007_Write
// Loop through comments // Loop through comments
$objWriter->startElement('commentList'); $objWriter->startElement('commentList');
foreach ($comments as $key => $value) { foreach ($comments as $key => $value) {
$this->_writeComment($objWriter, $key, $value, $authors); $this->writeComment($objWriter, $key, $value, $authors);
} }
$objWriter->endElement(); $objWriter->endElement();
@ -92,7 +92,7 @@ class PHPExcel_Writer_Excel2007_Comments extends PHPExcel_Writer_Excel2007_Write
* @param array $pAuthors Array of authors * @param array $pAuthors Array of authors
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
public function _writeComment(PHPExcel_Shared_XMLWriter $objWriter = null, $pCellReference = 'A1', PHPExcel_Comment $pComment = null, $pAuthors = null) private function writeComment(PHPExcel_Shared_XMLWriter $objWriter = null, $pCellReference = 'A1', PHPExcel_Comment $pComment = null, $pAuthors = null)
{ {
// comment // comment
$objWriter->startElement('comment'); $objWriter->startElement('comment');
@ -170,7 +170,7 @@ class PHPExcel_Writer_Excel2007_Comments extends PHPExcel_Writer_Excel2007_Write
// Loop through comments // Loop through comments
foreach ($comments as $key => $value) { foreach ($comments as $key => $value) {
$this->_writeVMLComment($objWriter, $key, $value); $this->writeVMLComment($objWriter, $key, $value);
} }
$objWriter->endElement(); $objWriter->endElement();
@ -187,7 +187,7 @@ class PHPExcel_Writer_Excel2007_Comments extends PHPExcel_Writer_Excel2007_Write
* @param PHPExcel_Comment $pComment Comment * @param PHPExcel_Comment $pComment Comment
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
public function _writeVMLComment(PHPExcel_Shared_XMLWriter $objWriter = null, $pCellReference = 'A1', PHPExcel_Comment $pComment = null) private function writeVMLComment(PHPExcel_Shared_XMLWriter $objWriter = null, $pCellReference = 'A1', PHPExcel_Comment $pComment = null)
{ {
// Metadata // Metadata
list($column, $row) = PHPExcel_Cell::coordinateFromString($pCellReference); list($column, $row) = PHPExcel_Cell::coordinateFromString($pCellReference);

View File

@ -58,7 +58,7 @@ class PHPExcel_Writer_Excel2007_Drawing extends PHPExcel_Writer_Excel2007_Writer
$i = 1; $i = 1;
$iterator = $pWorksheet->getDrawingCollection()->getIterator(); $iterator = $pWorksheet->getDrawingCollection()->getIterator();
while ($iterator->valid()) { while ($iterator->valid()) {
$this->_writeDrawing($objWriter, $iterator->current(), $i); $this->writeDrawing($objWriter, $iterator->current(), $i);
$iterator->next(); $iterator->next();
++$i; ++$i;
@ -69,7 +69,7 @@ class PHPExcel_Writer_Excel2007_Drawing extends PHPExcel_Writer_Excel2007_Writer
// Loop through charts and write the chart position // Loop through charts and write the chart position
if ($chartCount > 0) { if ($chartCount > 0) {
for ($c = 0; $c < $chartCount; ++$c) { for ($c = 0; $c < $chartCount; ++$c) {
$this->_writeChart($objWriter, $pWorksheet->getChartByIndex($c), $c+$i); $this->writeChart($objWriter, $pWorksheet->getChartByIndex($c), $c+$i);
} }
} }
} }
@ -88,7 +88,7 @@ class PHPExcel_Writer_Excel2007_Drawing extends PHPExcel_Writer_Excel2007_Writer
* @param int $pRelationId * @param int $pRelationId
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
public function _writeChart(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Chart $pChart = null, $pRelationId = -1) public function writeChart(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Chart $pChart = null, $pRelationId = -1)
{ {
$tl = $pChart->getTopLeftPosition(); $tl = $pChart->getTopLeftPosition();
$tl['colRow'] = PHPExcel_Cell::coordinateFromString($tl['cell']); $tl['colRow'] = PHPExcel_Cell::coordinateFromString($tl['cell']);
@ -160,7 +160,7 @@ class PHPExcel_Writer_Excel2007_Drawing extends PHPExcel_Writer_Excel2007_Writer
* @param int $pRelationId * @param int $pRelationId
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
public function _writeDrawing(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet_BaseDrawing $pDrawing = null, $pRelationId = -1) public function writeDrawing(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet_BaseDrawing $pDrawing = null, $pRelationId = -1)
{ {
if ($pRelationId >= 0) { if ($pRelationId >= 0) {
// xdr:oneCellAnchor // xdr:oneCellAnchor
@ -508,7 +508,7 @@ class PHPExcel_Writer_Excel2007_Drawing extends PHPExcel_Writer_Excel2007_Writer
// Loop through images // Loop through images
foreach ($images as $key => $value) { foreach ($images as $key => $value) {
$this->_writeVMLHeaderFooterImage($objWriter, $key, $value); $this->writeVMLHeaderFooterImage($objWriter, $key, $value);
} }
$objWriter->endElement(); $objWriter->endElement();
@ -525,7 +525,7 @@ class PHPExcel_Writer_Excel2007_Drawing extends PHPExcel_Writer_Excel2007_Writer
* @param PHPExcel_Worksheet_HeaderFooterDrawing $pImage Image * @param PHPExcel_Worksheet_HeaderFooterDrawing $pImage Image
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
public function _writeVMLHeaderFooterImage(PHPExcel_Shared_XMLWriter $objWriter = null, $pReference = '', PHPExcel_Worksheet_HeaderFooterDrawing $pImage = null) private function writeVMLHeaderFooterImage(PHPExcel_Shared_XMLWriter $objWriter = null, $pReference = '', PHPExcel_Worksheet_HeaderFooterDrawing $pImage = null)
{ {
// Calculate object id // Calculate object id
preg_match('{(\d+)}', md5($pReference), $m); preg_match('{(\d+)}', md5($pReference), $m);

View File

@ -123,12 +123,12 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
$this->colors = array(); $this->colors = array();
// Initialise workbook writer // Initialise workbook writer
$this->_writerWorkbook = new PHPExcel_Writer_Excel5_Workbook($this->phpExcel, $this->strTotal, $this->strUnique, $this->strTable, $this->colors, $this->parser); $this->writerWorkbook = new PHPExcel_Writer_Excel5_Workbook($this->phpExcel, $this->strTotal, $this->strUnique, $this->strTable, $this->colors, $this->parser);
// Initialise worksheet writers // Initialise worksheet writers
$countSheets = $this->phpExcel->getSheetCount(); $countSheets = $this->phpExcel->getSheetCount();
for ($i = 0; $i < $countSheets; ++$i) { for ($i = 0; $i < $countSheets; ++$i) {
$this->_writerWorksheets[$i] = new PHPExcel_Writer_Excel5_Worksheet($this->strTotal, $this->strUnique, $this->strTable, $this->colors, $this->parser, $this->preCalculateFormulas, $this->phpExcel->getSheet($i)); $this->writerWorksheets[$i] = new PHPExcel_Writer_Excel5_Worksheet($this->strTotal, $this->strUnique, $this->strTable, $this->colors, $this->parser, $this->preCalculateFormulas, $this->phpExcel->getSheet($i));
} }
// build Escher objects. Escher objects for workbooks needs to be build before Escher object for workbook. // build Escher objects. Escher objects for workbooks needs to be build before Escher object for workbook.
@ -139,25 +139,25 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
// for now, we use the first cellXf instead of cellStyleXf // for now, we use the first cellXf instead of cellStyleXf
$cellXfCollection = $this->phpExcel->getCellXfCollection(); $cellXfCollection = $this->phpExcel->getCellXfCollection();
for ($i = 0; $i < 15; ++$i) { for ($i = 0; $i < 15; ++$i) {
$this->_writerWorkbook->addXfWriter($cellXfCollection[0], true); $this->writerWorkbook->addXfWriter($cellXfCollection[0], true);
} }
// add all the cell Xfs // add all the cell Xfs
foreach ($this->phpExcel->getCellXfCollection() as $style) { foreach ($this->phpExcel->getCellXfCollection() as $style) {
$this->_writerWorkbook->addXfWriter($style, false); $this->writerWorkbook->addXfWriter($style, false);
} }
// add fonts from rich text eleemnts // add fonts from rich text eleemnts
for ($i = 0; $i < $countSheets; ++$i) { for ($i = 0; $i < $countSheets; ++$i) {
foreach ($this->_writerWorksheets[$i]->_phpSheet->getCellCollection() as $cellID) { foreach ($this->writerWorksheets[$i]->_phpSheet->getCellCollection() as $cellID) {
$cell = $this->_writerWorksheets[$i]->_phpSheet->getCell($cellID); $cell = $this->writerWorksheets[$i]->_phpSheet->getCell($cellID);
$cVal = $cell->getValue(); $cVal = $cell->getValue();
if ($cVal instanceof PHPExcel_RichText) { if ($cVal instanceof PHPExcel_RichText) {
$elements = $cVal->getRichTextElements(); $elements = $cVal->getRichTextElements();
foreach ($elements as $element) { foreach ($elements as $element) {
if ($element instanceof PHPExcel_RichText_Run) { if ($element instanceof PHPExcel_RichText_Run) {
$font = $element->getFont(); $font = $element->getFont();
$this->_writerWorksheets[$i]->_fntHashIndex[$font->getHashCode()] = $this->_writerWorkbook->_addFont($font); $this->writerWorksheets[$i]->_fntHashIndex[$font->getHashCode()] = $this->writerWorkbook->addFont($font);
} }
} }
} }
@ -172,16 +172,16 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
// because the byte sizes of these are needed in the global workbook stream // because the byte sizes of these are needed in the global workbook stream
$worksheetSizes = array(); $worksheetSizes = array();
for ($i = 0; $i < $countSheets; ++$i) { for ($i = 0; $i < $countSheets; ++$i) {
$this->_writerWorksheets[$i]->close(); $this->writerWorksheets[$i]->close();
$worksheetSizes[] = $this->_writerWorksheets[$i]->_datasize; $worksheetSizes[] = $this->writerWorksheets[$i]->_datasize;
} }
// add binary data for global workbook stream // add binary data for global workbook stream
$OLE->append($this->_writerWorkbook->writeWorkbook($worksheetSizes)); $OLE->append($this->writerWorkbook->writeWorkbook($worksheetSizes));
// add binary data for sheet streams // add binary data for sheet streams
for ($i = 0; $i < $countSheets; ++$i) { for ($i = 0; $i < $countSheets; ++$i) {
$OLE->append($this->_writerWorksheets[$i]->getData()); $OLE->append($this->writerWorksheets[$i]->getData());
} }
$this->documentSummaryInformation = $this->writeDocumentSummaryInformation(); $this->documentSummaryInformation = $this->writeDocumentSummaryInformation();
@ -391,7 +391,7 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
$dgContainer->setLastSpId($lastSpId); $dgContainer->setLastSpId($lastSpId);
// set the Escher object // set the Escher object
$this->_writerWorksheets[$sheetIndex]->setEscher($escher); $this->writerWorksheets[$sheetIndex]->setEscher($escher);
} }
} }
@ -530,7 +530,7 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
} }
// Set the Escher object // Set the Escher object
$this->_writerWorkbook->setEscher($escher); $this->writerWorkbook->setEscher($escher);
} }
/** /**

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_Writer_Excel5_BIFFwriter
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -58,15 +59,6 @@
// * License along with this library; if not, write to the Free Software // * License along with this library; if not, write to the Free Software
// * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// */ // */
/**
* PHPExcel_Writer_Excel5_BIFFwriter
*
* @category PHPExcel
* @package PHPExcel_Writer_Excel5
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Writer_Excel5_BIFFwriter class PHPExcel_Writer_Excel5_BIFFwriter
{ {
/** /**
@ -88,11 +80,11 @@ class PHPExcel_Writer_Excel5_BIFFwriter
public $_datasize; public $_datasize;
/** /**
* The maximum length for a BIFF record (excluding record header and length field). See _addContinue() * The maximum length for a BIFF record (excluding record header and length field). See addContinue()
* @var integer * @var integer
* @see _addContinue() * @see addContinue()
*/ */
public $_limit = 8224; private $limit = 8224;
/** /**
* Constructor * Constructor
@ -101,7 +93,7 @@ class PHPExcel_Writer_Excel5_BIFFwriter
{ {
$this->_data = ''; $this->_data = '';
$this->_datasize = 0; $this->_datasize = 0;
// $this->_limit = 8224; // $this->limit = 8224;
} }
/** /**
@ -136,25 +128,25 @@ class PHPExcel_Writer_Excel5_BIFFwriter
* @param string $data binary data to append * @param string $data binary data to append
* @access private * @access private
*/ */
public function _append($data) protected function append($data)
{ {
if (strlen($data) - 4 > $this->_limit) { if (strlen($data) - 4 > $this->limit) {
$data = $this->_addContinue($data); $data = $this->addContinue($data);
} }
$this->_data .= $data; $this->_data .= $data;
$this->_datasize += strlen($data); $this->_datasize += strlen($data);
} }
/** /**
* General storage function like _append, but returns string instead of modifying $this->_data * General storage function like append, but returns string instead of modifying $this->_data
* *
* @param string $data binary data to write * @param string $data binary data to write
* @return string * @return string
*/ */
public function writeData($data) public function writeData($data)
{ {
if (strlen($data) - 4 > $this->_limit) { if (strlen($data) - 4 > $this->limit) {
$data = $this->_addContinue($data); $data = $this->addContinue($data);
} }
$this->_datasize += strlen($data); $this->_datasize += strlen($data);
@ -169,7 +161,7 @@ class PHPExcel_Writer_Excel5_BIFFwriter
* 0x0010 Worksheet. * 0x0010 Worksheet.
* @access private * @access private
*/ */
public function _storeBof($type) protected function storeBof($type)
{ {
$record = 0x0809; // Record identifier (BIFF5-BIFF8) $record = 0x0809; // Record identifier (BIFF5-BIFF8)
$length = 0x0010; $length = 0x0010;
@ -184,7 +176,7 @@ class PHPExcel_Writer_Excel5_BIFFwriter
$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->_append($header . $data . $unknown); $this->append($header . $data . $unknown);
} }
/** /**
@ -192,13 +184,13 @@ class PHPExcel_Writer_Excel5_BIFFwriter
* *
* @access private * @access private
*/ */
public 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);
} }
/** /**
@ -226,9 +218,9 @@ class PHPExcel_Writer_Excel5_BIFFwriter
* @return string A very convenient string of continue blocks * @return string A very convenient string of continue blocks
* @access private * @access private
*/ */
public function _addContinue($data) private 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

View File

@ -38,26 +38,26 @@ class PHPExcel_Writer_Excel5_Escher
/** /**
* The object we are writing * The object we are writing
*/ */
private $_object; private $object;
/** /**
* The written binary data * The written binary data
*/ */
private $_data; private $data;
/** /**
* Shape offsets. Positions in binary stream where a new shape record begins * Shape offsets. Positions in binary stream where a new shape record begins
* *
* @var array * @var array
*/ */
private $_spOffsets; private $spOffsets;
/** /**
* Shape types. * Shape types.
* *
* @var array * @var array
*/ */
private $_spTypes; private $spTypes;
/** /**
* Constructor * Constructor
@ -66,7 +66,7 @@ class PHPExcel_Writer_Excel5_Escher
*/ */
public function __construct($object) public function __construct($object)
{ {
$this->_object = $object; $this->object = $object;
} }
/** /**
@ -75,18 +75,18 @@ class PHPExcel_Writer_Excel5_Escher
public function close() public function close()
{ {
// initialize // initialize
$this->_data = ''; $this->data = '';
switch (get_class($this->_object)) { switch (get_class($this->object)) {
case 'PHPExcel_Shared_Escher': case 'PHPExcel_Shared_Escher':
if ($dggContainer = $this->_object->getDggContainer()) { if ($dggContainer = $this->object->getDggContainer()) {
$writer = new PHPExcel_Writer_Excel5_Escher($dggContainer); $writer = new PHPExcel_Writer_Excel5_Escher($dggContainer);
$this->_data = $writer->close(); $this->data = $writer->close();
} elseif ($dgContainer = $this->_object->getDgContainer()) { } elseif ($dgContainer = $this->object->getDgContainer()) {
$writer = new PHPExcel_Writer_Excel5_Escher($dgContainer); $writer = new PHPExcel_Writer_Excel5_Escher($dgContainer);
$this->_data = $writer->close(); $this->data = $writer->close();
$this->_spOffsets = $writer->getSpOffsets(); $this->spOffsets = $writer->getSpOffsets();
$this->_spTypes = $writer->getSpTypes(); $this->spTypes = $writer->getSpTypes();
} }
break; break;
case 'PHPExcel_Shared_Escher_DggContainer': case 'PHPExcel_Shared_Escher_DggContainer':
@ -107,14 +107,14 @@ class PHPExcel_Writer_Excel5_Escher
$dggData = $dggData =
pack( pack(
'VVVV', 'VVVV',
$this->_object->getSpIdMax(), // maximum shape identifier increased by one $this->object->getSpIdMax(), // maximum shape identifier increased by one
$this->_object->getCDgSaved() + 1, // number of file identifier clusters increased by one $this->object->getCDgSaved() + 1, // number of file identifier clusters increased by one
$this->_object->getCSpSaved(), $this->object->getCSpSaved(),
$this->_object->getCDgSaved() // count total number of drawings saved $this->object->getCDgSaved() // count total number of drawings saved
); );
// add file identifier clusters (one per drawing) // add file identifier clusters (one per drawing)
$IDCLs = $this->_object->getIDCLs(); $IDCLs = $this->object->getIDCLs();
foreach ($IDCLs as $dgId => $maxReducedSpId) { foreach ($IDCLs as $dgId => $maxReducedSpId) {
$dggData .= pack('VV', $dgId, $maxReducedSpId + 1); $dggData .= pack('VV', $dgId, $maxReducedSpId + 1);
@ -124,7 +124,7 @@ class PHPExcel_Writer_Excel5_Escher
$innerData .= $header . $dggData; $innerData .= $header . $dggData;
// write the bstoreContainer // write the bstoreContainer
if ($bstoreContainer = $this->_object->getBstoreContainer()) { if ($bstoreContainer = $this->object->getBstoreContainer()) {
$writer = new PHPExcel_Writer_Excel5_Escher($bstoreContainer); $writer = new PHPExcel_Writer_Excel5_Escher($bstoreContainer);
$innerData .= $writer->close(); $innerData .= $writer->close();
} }
@ -140,7 +140,7 @@ class PHPExcel_Writer_Excel5_Escher
$header = pack('vvV', $recVerInstance, $recType, $length); $header = pack('vvV', $recVerInstance, $recType, $length);
$this->_data = $header . $innerData; $this->data = $header . $innerData;
break; break;
case 'PHPExcel_Shared_Escher_DggContainer_BstoreContainer': case 'PHPExcel_Shared_Escher_DggContainer_BstoreContainer':
// this is a container record // this is a container record
@ -149,7 +149,7 @@ class PHPExcel_Writer_Excel5_Escher
$innerData = ''; $innerData = '';
// treat the inner data // treat the inner data
if ($BSECollection = $this->_object->getBSECollection()) { if ($BSECollection = $this->object->getBSECollection()) {
foreach ($BSECollection as $BSE) { foreach ($BSECollection as $BSE) {
$writer = new PHPExcel_Writer_Excel5_Escher($BSE); $writer = new PHPExcel_Writer_Excel5_Escher($BSE);
$innerData .= $writer->close(); $innerData .= $writer->close();
@ -158,7 +158,7 @@ class PHPExcel_Writer_Excel5_Escher
// write the record // write the record
$recVer = 0xF; $recVer = 0xF;
$recInstance = count($this->_object->getBSECollection()); $recInstance = count($this->object->getBSECollection());
$recType = 0xF001; $recType = 0xF001;
$length = strlen($innerData); $length = strlen($innerData);
@ -167,7 +167,7 @@ class PHPExcel_Writer_Excel5_Escher
$header = pack('vvV', $recVerInstance, $recType, $length); $header = pack('vvV', $recVerInstance, $recType, $length);
$this->_data = $header . $innerData; $this->data = $header . $innerData;
break; break;
case 'PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE': case 'PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE':
// this is a semi-container record // this is a semi-container record
@ -176,7 +176,7 @@ class PHPExcel_Writer_Excel5_Escher
$innerData = ''; $innerData = '';
// here we treat the inner data // here we treat the inner data
if ($blip = $this->_object->getBlip()) { if ($blip = $this->object->getBlip()) {
$writer = new PHPExcel_Writer_Excel5_Escher($blip); $writer = new PHPExcel_Writer_Excel5_Escher($blip);
$innerData .= $writer->close(); $innerData .= $writer->close();
} }
@ -184,8 +184,8 @@ class PHPExcel_Writer_Excel5_Escher
// initialize // initialize
$data = ''; $data = '';
$btWin32 = $this->_object->getBlipType(); $btWin32 = $this->object->getBlipType();
$btMacOS = $this->_object->getBlipType(); $btMacOS = $this->object->getBlipType();
$data .= pack('CC', $btWin32, $btMacOS); $data .= pack('CC', $btWin32, $btMacOS);
$rgbUid = pack('VVVV', 0, 0, 0, 0); // todo $rgbUid = pack('VVVV', 0, 0, 0, 0); // todo
@ -205,7 +205,7 @@ class PHPExcel_Writer_Excel5_Escher
// write the record // write the record
$recVer = 0x2; $recVer = 0x2;
$recInstance = $this->_object->getBlipType(); $recInstance = $this->object->getBlipType();
$recType = 0xF007; $recType = 0xF007;
$length = strlen($data); $length = strlen($data);
@ -214,15 +214,15 @@ class PHPExcel_Writer_Excel5_Escher
$header = pack('vvV', $recVerInstance, $recType, $length); $header = pack('vvV', $recVerInstance, $recType, $length);
$this->_data = $header; $this->data = $header;
$this->_data .= $data; $this->data .= $data;
break; break;
case 'PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip': case 'PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip':
// this is an atom record // this is an atom record
// write the record // write the record
switch ($this->_object->getParent()->getBlipType()) { switch ($this->object->getParent()->getBlipType()) {
case PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_JPEG: case PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_JPEG:
// initialize // initialize
$innerData = ''; $innerData = '';
@ -233,7 +233,7 @@ class PHPExcel_Writer_Excel5_Escher
$tag = 0xFF; // todo $tag = 0xFF; // todo
$innerData .= pack('C', $tag); $innerData .= pack('C', $tag);
$innerData .= $this->_object->getData(); $innerData .= $this->object->getData();
$recVer = 0x0; $recVer = 0x0;
$recInstance = 0x46A; $recInstance = 0x46A;
@ -245,9 +245,9 @@ class PHPExcel_Writer_Excel5_Escher
$header = pack('vvV', $recVerInstance, $recType, $length); $header = pack('vvV', $recVerInstance, $recType, $length);
$this->_data = $header; $this->data = $header;
$this->_data .= $innerData; $this->data .= $innerData;
break; break;
case PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG: case PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG:
@ -260,7 +260,7 @@ class PHPExcel_Writer_Excel5_Escher
$tag = 0xFF; // todo $tag = 0xFF; // todo
$innerData .= pack('C', $tag); $innerData .= pack('C', $tag);
$innerData .= $this->_object->getData(); $innerData .= $this->object->getData();
$recVer = 0x0; $recVer = 0x0;
$recInstance = 0x6E0; $recInstance = 0x6E0;
@ -272,9 +272,9 @@ class PHPExcel_Writer_Excel5_Escher
$header = pack('vvV', $recVerInstance, $recType, $length); $header = pack('vvV', $recVerInstance, $recType, $length);
$this->_data = $header; $this->data = $header;
$this->_data .= $innerData; $this->data .= $innerData;
break; break;
} }
break; break;
@ -286,7 +286,7 @@ class PHPExcel_Writer_Excel5_Escher
// write the dg // write the dg
$recVer = 0x0; $recVer = 0x0;
$recInstance = $this->_object->getDgId(); $recInstance = $this->object->getDgId();
$recType = 0xF008; $recType = 0xF008;
$length = 8; $length = 8;
@ -296,12 +296,12 @@ class PHPExcel_Writer_Excel5_Escher
$header = pack('vvV', $recVerInstance, $recType, $length); $header = pack('vvV', $recVerInstance, $recType, $length);
// number of shapes in this drawing (including group shape) // number of shapes in this drawing (including group shape)
$countShapes = count($this->_object->getSpgrContainer()->getChildren()); $countShapes = count($this->object->getSpgrContainer()->getChildren());
$innerData .= $header . pack('VV', $countShapes, $this->_object->getLastSpId()); $innerData .= $header . pack('VV', $countShapes, $this->object->getLastSpId());
//$innerData .= $header . pack('VV', 0, 0); //$innerData .= $header . pack('VV', 0, 0);
// write the spgrContainer // write the spgrContainer
if ($spgrContainer = $this->_object->getSpgrContainer()) { if ($spgrContainer = $this->object->getSpgrContainer()) {
$writer = new PHPExcel_Writer_Excel5_Escher($spgrContainer); $writer = new PHPExcel_Writer_Excel5_Escher($spgrContainer);
$innerData .= $writer->close(); $innerData .= $writer->close();
@ -314,8 +314,8 @@ class PHPExcel_Writer_Excel5_Escher
$spOffset += 24; // add length of dgContainer header data (8 bytes) plus dg data (16 bytes) $spOffset += 24; // add length of dgContainer header data (8 bytes) plus dg data (16 bytes)
} }
$this->_spOffsets = $spOffsets; $this->spOffsets = $spOffsets;
$this->_spTypes = $spTypes; $this->spTypes = $spTypes;
} }
// write the record // write the record
@ -329,7 +329,7 @@ class PHPExcel_Writer_Excel5_Escher
$header = pack('vvV', $recVerInstance, $recType, $length); $header = pack('vvV', $recVerInstance, $recType, $length);
$this->_data = $header . $innerData; $this->data = $header . $innerData;
break; break;
case 'PHPExcel_Shared_Escher_DgContainer_SpgrContainer': case 'PHPExcel_Shared_Escher_DgContainer_SpgrContainer':
// this is a container record // this is a container record
@ -343,7 +343,7 @@ class PHPExcel_Writer_Excel5_Escher
$spTypes = array(); $spTypes = array();
// treat the inner data // treat the inner data
foreach ($this->_object->getChildren() as $spContainer) { foreach ($this->object->getChildren() as $spContainer) {
$writer = new PHPExcel_Writer_Excel5_Escher($spContainer); $writer = new PHPExcel_Writer_Excel5_Escher($spContainer);
$spData = $writer->close(); $spData = $writer->close();
$innerData .= $spData; $innerData .= $spData;
@ -366,9 +366,9 @@ class PHPExcel_Writer_Excel5_Escher
$header = pack('vvV', $recVerInstance, $recType, $length); $header = pack('vvV', $recVerInstance, $recType, $length);
$this->_data = $header . $innerData; $this->data = $header . $innerData;
$this->_spOffsets = $spOffsets; $this->spOffsets = $spOffsets;
$this->_spTypes = $spTypes; $this->spTypes = $spTypes;
break; break;
case 'PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer': case 'PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer':
// initialize // initialize
@ -377,7 +377,7 @@ class PHPExcel_Writer_Excel5_Escher
// build the data // build the data
// write group shape record, if necessary? // write group shape record, if necessary?
if ($this->_object->getSpgr()) { if ($this->object->getSpgr()) {
$recVer = 0x1; $recVer = 0x1;
$recInstance = 0x0000; $recInstance = 0x0000;
$recType = 0xF009; $recType = 0xF009;
@ -390,11 +390,11 @@ class PHPExcel_Writer_Excel5_Escher
$data .= $header . pack('VVVV', 0, 0, 0, 0); $data .= $header . pack('VVVV', 0, 0, 0, 0);
} }
$this->_spTypes[] = ($this->_object->getSpType()); $this->spTypes[] = ($this->object->getSpType());
// write the shape record // write the shape record
$recVer = 0x2; $recVer = 0x2;
$recInstance = $this->_object->getSpType(); // shape type $recInstance = $this->object->getSpType(); // shape type
$recType = 0xF00A; $recType = 0xF00A;
$length = 0x00000008; $length = 0x00000008;
@ -403,17 +403,17 @@ class PHPExcel_Writer_Excel5_Escher
$header = pack('vvV', $recVerInstance, $recType, $length); $header = pack('vvV', $recVerInstance, $recType, $length);
$data .= $header . pack('VV', $this->_object->getSpId(), $this->_object->getSpgr() ? 0x0005 : 0x0A00); $data .= $header . pack('VV', $this->object->getSpId(), $this->object->getSpgr() ? 0x0005 : 0x0A00);
// the options // the options
if ($this->_object->getOPTCollection()) { if ($this->object->getOPTCollection()) {
$optData = ''; $optData = '';
$recVer = 0x3; $recVer = 0x3;
$recInstance = count($this->_object->getOPTCollection()); $recInstance = count($this->object->getOPTCollection());
$recType = 0xF00B; $recType = 0xF00B;
foreach ($this->_object->getOPTCollection() as $property => $value) { foreach ($this->object->getOPTCollection() as $property => $value) {
$optData .= pack('vV', $property, $value); $optData .= pack('vV', $property, $value);
} }
$length = strlen($optData); $length = strlen($optData);
@ -426,7 +426,7 @@ class PHPExcel_Writer_Excel5_Escher
} }
// the client anchor // the client anchor
if ($this->_object->getStartCoordinates()) { if ($this->object->getStartCoordinates()) {
$clientAnchorData = ''; $clientAnchorData = '';
$recVer = 0x0; $recVer = 0x0;
@ -434,28 +434,28 @@ class PHPExcel_Writer_Excel5_Escher
$recType = 0xF010; $recType = 0xF010;
// start coordinates // start coordinates
list($column, $row) = PHPExcel_Cell::coordinateFromString($this->_object->getStartCoordinates()); list($column, $row) = PHPExcel_Cell::coordinateFromString($this->object->getStartCoordinates());
$c1 = PHPExcel_Cell::columnIndexFromString($column) - 1; $c1 = PHPExcel_Cell::columnIndexFromString($column) - 1;
$r1 = $row - 1; $r1 = $row - 1;
// start offsetX // start offsetX
$startOffsetX = $this->_object->getStartOffsetX(); $startOffsetX = $this->object->getStartOffsetX();
// start offsetY // start offsetY
$startOffsetY = $this->_object->getStartOffsetY(); $startOffsetY = $this->object->getStartOffsetY();
// end coordinates // end coordinates
list($column, $row) = PHPExcel_Cell::coordinateFromString($this->_object->getEndCoordinates()); list($column, $row) = PHPExcel_Cell::coordinateFromString($this->object->getEndCoordinates());
$c2 = PHPExcel_Cell::columnIndexFromString($column) - 1; $c2 = PHPExcel_Cell::columnIndexFromString($column) - 1;
$r2 = $row - 1; $r2 = $row - 1;
// end offsetX // end offsetX
$endOffsetX = $this->_object->getEndOffsetX(); $endOffsetX = $this->object->getEndOffsetX();
// end offsetY // end offsetY
$endOffsetY = $this->_object->getEndOffsetY(); $endOffsetY = $this->object->getEndOffsetY();
$clientAnchorData = pack('vvvvvvvvv', $this->_object->getSpFlag(), $c1, $startOffsetX, $r1, $startOffsetY, $c2, $endOffsetX, $r2, $endOffsetY); $clientAnchorData = pack('vvvvvvvvv', $this->object->getSpFlag(), $c1, $startOffsetX, $r1, $startOffsetY, $c2, $endOffsetX, $r2, $endOffsetY);
$length = strlen($clientAnchorData); $length = strlen($clientAnchorData);
@ -467,7 +467,7 @@ class PHPExcel_Writer_Excel5_Escher
} }
// the client data, just empty for now // the client data, just empty for now
if (!$this->_object->getSpgr()) { if (!$this->object->getSpgr()) {
$clientDataData = ''; $clientDataData = '';
$recVer = 0x0; $recVer = 0x0;
@ -494,11 +494,11 @@ class PHPExcel_Writer_Excel5_Escher
$header = pack('vvV', $recVerInstance, $recType, $length); $header = pack('vvV', $recVerInstance, $recType, $length);
$this->_data = $header . $data; $this->data = $header . $data;
break; break;
} }
return $this->_data; return $this->data;
} }
/** /**
@ -508,7 +508,7 @@ class PHPExcel_Writer_Excel5_Escher
*/ */
public function getSpOffsets() public function getSpOffsets()
{ {
return $this->_spOffsets; return $this->spOffsets;
} }
/** /**
@ -518,6 +518,6 @@ class PHPExcel_Writer_Excel5_Escher
*/ */
public function getSpTypes() public function getSpTypes()
{ {
return $this->_spTypes; return $this->spTypes;
} }
} }

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_Writer_Excel5_Font
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -24,15 +25,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/**
* PHPExcel_Writer_Excel5_Font
*
* @category PHPExcel
* @package PHPExcel_Writer_Excel5
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Writer_Excel5_Font class PHPExcel_Writer_Excel5_Font
{ {
/** /**
@ -40,14 +32,14 @@ class PHPExcel_Writer_Excel5_Font
* *
* @var int * @var int
*/ */
private $_colorIndex; private $colorIndex;
/** /**
* Font * Font
* *
* @var PHPExcel_Style_Font * @var PHPExcel_Style_Font
*/ */
private $_font; private $font;
/** /**
* Constructor * Constructor
@ -56,8 +48,8 @@ class PHPExcel_Writer_Excel5_Font
*/ */
public function __construct(PHPExcel_Style_Font $font = null) public function __construct(PHPExcel_Style_Font $font = null)
{ {
$this->_colorIndex = 0x7FFF; $this->colorIndex = 0x7FFF;
$this->_font = $font; $this->font = $font;
} }
/** /**
@ -67,7 +59,7 @@ class PHPExcel_Writer_Excel5_Font
*/ */
public function setColorIndex($colorIndex) public function setColorIndex($colorIndex)
{ {
$this->_colorIndex = $colorIndex; $this->colorIndex = $colorIndex;
} }
/** /**
@ -80,24 +72,24 @@ class PHPExcel_Writer_Excel5_Font
$font_outline = 0; $font_outline = 0;
$font_shadow = 0; $font_shadow = 0;
$icv = $this->_colorIndex; // Index to color palette $icv = $this->colorIndex; // Index to color palette
if ($this->_font->getSuperScript()) { if ($this->font->getSuperScript()) {
$sss = 1; $sss = 1;
} elseif ($this->_font->getSubScript()) { } elseif ($this->font->getSubScript()) {
$sss = 2; $sss = 2;
} else { } else {
$sss = 0; $sss = 0;
} }
$bFamily = 0; // Font family $bFamily = 0; // Font family
$bCharSet = PHPExcel_Shared_Font::getCharsetFromFontName($this->_font->getName()); // Character set $bCharSet = PHPExcel_Shared_Font::getCharsetFromFontName($this->font->getName()); // Character set
$record = 0x31; // Record identifier $record = 0x31; // Record identifier
$reserved = 0x00; // Reserved $reserved = 0x00; // Reserved
$grbit = 0x00; // Font attributes $grbit = 0x00; // Font attributes
if ($this->_font->getItalic()) { if ($this->font->getItalic()) {
$grbit |= 0x02; $grbit |= 0x02;
} }
if ($this->_font->getStrikethrough()) { if ($this->font->getStrikethrough()) {
$grbit |= 0x08; $grbit |= 0x08;
} }
if ($font_outline) { if ($font_outline) {
@ -110,20 +102,20 @@ class PHPExcel_Writer_Excel5_Font
$data = pack( $data = pack(
"vvvvvCCCC", "vvvvvCCCC",
// Fontsize (in twips) // Fontsize (in twips)
$this->_font->getSize() * 20, $this->font->getSize() * 20,
$grbit, $grbit,
// Colour // Colour
$icv, $icv,
// Font weight // Font weight
self::_mapBold($this->_font->getBold()), self::mapBold($this->font->getBold()),
// Superscript/Subscript // Superscript/Subscript
$sss, $sss,
self::_mapUnderline($this->_font->getUnderline()), self::mapUnderline($this->font->getUnderline()),
$bFamily, $bFamily,
$bCharSet, $bCharSet,
$reserved $reserved
); );
$data .= PHPExcel_Shared_String::UTF8toBIFF8UnicodeShort($this->_font->getName()); $data .= PHPExcel_Shared_String::UTF8toBIFF8UnicodeShort($this->font->getName());
$length = strlen($data); $length = strlen($data);
$header = pack("vv", $record, $length); $header = pack("vv", $record, $length);
@ -137,7 +129,7 @@ class PHPExcel_Writer_Excel5_Font
* @param boolean $bold * @param boolean $bold
* @return int * @return int
*/ */
private static function _mapBold($bold) private static function mapBold($bold)
{ {
if ($bold) { if ($bold) {
return 0x2BC; // 700 = Bold font weight return 0x2BC; // 700 = Bold font weight
@ -150,23 +142,24 @@ class PHPExcel_Writer_Excel5_Font
* @static array of int * @static array of int
* *
*/ */
private static $_mapUnderline = array( private static $mapUnderline = array(
PHPExcel_Style_Font::UNDERLINE_NONE => 0x00, PHPExcel_Style_Font::UNDERLINE_NONE => 0x00,
PHPExcel_Style_Font::UNDERLINE_SINGLE => 0x01, PHPExcel_Style_Font::UNDERLINE_SINGLE => 0x01,
PHPExcel_Style_Font::UNDERLINE_DOUBLE => 0x02, PHPExcel_Style_Font::UNDERLINE_DOUBLE => 0x02,
PHPExcel_Style_Font::UNDERLINE_SINGLEACCOUNTING => 0x21, PHPExcel_Style_Font::UNDERLINE_SINGLEACCOUNTING => 0x21,
PHPExcel_Style_Font::UNDERLINE_DOUBLEACCOUNTING => 0x22, PHPExcel_Style_Font::UNDERLINE_DOUBLEACCOUNTING => 0x22,
); );
/** /**
* Map underline * Map underline
* *
* @param string * @param string
* @return int * @return int
*/ */
private static function _mapUnderline($underline) private static function mapUnderline($underline)
{ {
if (isset(self::$_mapUnderline[$underline])) { if (isset(self::$mapUnderline[$underline])) {
return self::$_mapUnderline[$underline]; return self::$mapUnderline[$underline];
} }
return 0x00; return 0x00;
} }

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_Writer_Excel5_Parser
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -48,15 +49,6 @@
// * License along with this library; if not, write to the Free Software // * License along with this library; if not, write to the Free Software
// * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// */ // */
/**
* PHPExcel_Writer_Excel5_Parser
*
* @category PHPExcel
* @package PHPExcel_Writer_Excel5
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Writer_Excel5_Parser class PHPExcel_Writer_Excel5_Parser
{ {
/** Constants */ /** Constants */
@ -77,43 +69,43 @@ class PHPExcel_Writer_Excel5_Parser
* The index of the character we are currently looking at * The index of the character we are currently looking at
* @var integer * @var integer
*/ */
public $_current_char; public $currentCharacter;
/** /**
* The token we are working on. * The token we are working on.
* @var string * @var string
*/ */
public $_current_token; public $currentToken;
/** /**
* The formula to parse * The formula to parse
* @var string * @var string
*/ */
public $_formula; private $formula;
/** /**
* The character ahead of the current char * The character ahead of the current char
* @var string * @var string
*/ */
public $_lookahead; public $lookAhead;
/** /**
* The parse tree to be generated * The parse tree to be generated
* @var string * @var string
*/ */
public $_parse_tree; private $parseTree;
/** /**
* Array of external sheets * Array of external sheets
* @var array * @var array
*/ */
public $_ext_sheets; private $externalSheets;
/** /**
* Array of sheet references in the form of REF structures * Array of sheet references in the form of REF structures
* @var array * @var array
*/ */
public $_references; public $references;
/** /**
* The class constructor * The class constructor
@ -121,14 +113,14 @@ class PHPExcel_Writer_Excel5_Parser
*/ */
public function __construct() public function __construct()
{ {
$this->_current_char = 0; $this->currentCharacter = 0;
$this->_current_token = ''; // The token we are working on. $this->currentToken = ''; // The token we are working on.
$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->parseTree = ''; // 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 function's ptg's
$this->_ext_sheets = array(); $this->externalSheets = array();
$this->_references = array(); $this->references = array();
} }
/** /**
@ -136,7 +128,7 @@ class PHPExcel_Writer_Excel5_Parser
* *
* @access private * @access private
*/ */
private function _initializeHashes() private function initializeHashes()
{ {
// The Excel ptg indices // The Excel ptg indices
$this->ptg = array( $this->ptg = array(
@ -250,7 +242,7 @@ class PHPExcel_Writer_Excel5_Parser
// class: The reference, value or array class of the function args. // class: The reference, value or array class of the function args.
// vol: The function is volatile. // vol: The function is volatile.
// //
$this->_functions = array( $this->functions = array(
// function ptg args class vol // 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 ),
@ -512,37 +504,37 @@ class PHPExcel_Writer_Excel5_Parser
* @param mixed $token The token to convert. * @param mixed $token The token to convert.
* @return mixed the converted token on success * @return mixed the converted token on success
*/ */
private function _convert($token) private function convert($token)
{ {
if (preg_match("/\"([^\"]|\"\"){0,255}\"/", $token)) { if (preg_match("/\"([^\"]|\"\"){0,255}\"/", $token)) {
return $this->_convertString($token); return $this->convertString($token);
} elseif (is_numeric($token)) { } elseif (is_numeric($token)) {
return $this->_convertNumber($token); return $this->convertNumber($token);
// match references like A1 or $A$1 // match references like A1 or $A$1
} elseif (preg_match('/^\$?([A-Ia-i]?[A-Za-z])\$?(\d+)$/', $token)) { } elseif (preg_match('/^\$?([A-Ia-i]?[A-Za-z])\$?(\d+)$/', $token)) {
return $this->_convertRef2d($token); return $this->convertRef2d($token);
// match external references like Sheet1!A1 or Sheet1:Sheet2!A1 or Sheet1!$A$1 or Sheet1:Sheet2!$A$1 // match external references like Sheet1!A1 or Sheet1:Sheet2!A1 or Sheet1!$A$1 or Sheet1:Sheet2!$A$1
} elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?[A-Ia-i]?[A-Za-z]\\$?(\d+)$/u", $token)) { } elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?[A-Ia-i]?[A-Za-z]\\$?(\d+)$/u", $token)) {
return $this->_convertRef3d($token); return $this->convertRef3d($token);
// match external references like 'Sheet1'!A1 or 'Sheet1:Sheet2'!A1 or 'Sheet1'!$A$1 or 'Sheet1:Sheet2'!$A$1 // match external references like 'Sheet1'!A1 or 'Sheet1:Sheet2'!A1 or 'Sheet1'!$A$1 or 'Sheet1:Sheet2'!$A$1
} elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?[A-Ia-i]?[A-Za-z]\\$?(\d+)$/u", $token)) { } elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?[A-Ia-i]?[A-Za-z]\\$?(\d+)$/u", $token)) {
return $this->_convertRef3d($token); return $this->convertRef3d($token);
// match ranges like A1:B2 or $A$1:$B$2 // match ranges like A1:B2 or $A$1:$B$2
} elseif (preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?(\d+)\:(\$)?[A-Ia-i]?[A-Za-z](\$)?(\d+)$/', $token)) { } elseif (preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?(\d+)\:(\$)?[A-Ia-i]?[A-Za-z](\$)?(\d+)$/', $token)) {
return $this->_convertRange2d($token); return $this->convertRange2d($token);
// match external ranges like Sheet1!A1:B2 or Sheet1:Sheet2!A1:B2 or Sheet1!$A$1:$B$2 or Sheet1:Sheet2!$A$1:$B$2 // match external ranges like Sheet1!A1:B2 or Sheet1:Sheet2!A1:B2 or Sheet1!$A$1:$B$2 or Sheet1:Sheet2!$A$1:$B$2
} elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?([A-Ia-i]?[A-Za-z])?\\$?(\d+)\:\\$?([A-Ia-i]?[A-Za-z])?\\$?(\d+)$/u", $token)) { } elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?([A-Ia-i]?[A-Za-z])?\\$?(\d+)\:\\$?([A-Ia-i]?[A-Za-z])?\\$?(\d+)$/u", $token)) {
return $this->_convertRange3d($token); return $this->convertRange3d($token);
// match external ranges like 'Sheet1'!A1:B2 or 'Sheet1:Sheet2'!A1:B2 or 'Sheet1'!$A$1:$B$2 or 'Sheet1:Sheet2'!$A$1:$B$2 // match external ranges like 'Sheet1'!A1:B2 or 'Sheet1:Sheet2'!A1:B2 or 'Sheet1'!$A$1:$B$2 or 'Sheet1:Sheet2'!$A$1:$B$2
} elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?([A-Ia-i]?[A-Za-z])?\\$?(\d+)\:\\$?([A-Ia-i]?[A-Za-z])?\\$?(\d+)$/u", $token)) { } elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?([A-Ia-i]?[A-Za-z])?\\$?(\d+)\:\\$?([A-Ia-i]?[A-Za-z])?\\$?(\d+)$/u", $token)) {
return $this->_convertRange3d($token); return $this->convertRange3d($token);
// operators (including parentheses) // operators (including parentheses)
} elseif (isset($this->ptg[$token])) { } elseif (isset($this->ptg[$token])) {
@ -550,12 +542,12 @@ class PHPExcel_Writer_Excel5_Parser
// match error codes // match error codes
} elseif (preg_match("/^#[A-Z0\/]{3,5}[!?]{1}$/", $token) or $token == '#N/A') { } elseif (preg_match("/^#[A-Z0\/]{3,5}[!?]{1}$/", $token) or $token == '#N/A') {
return $this->_convertError($token); return $this->convertError($token);
// commented so argument number can be processed correctly. See toReversePolish(). // commented so argument number can be processed correctly. See toReversePolish().
/*elseif (preg_match("/[A-Z0-9\xc0-\xdc\.]+/", $token)) /*elseif (preg_match("/[A-Z0-9\xc0-\xdc\.]+/", $token))
{ {
return($this->_convertFunction($token, $this->_func_args)); return($this->convertFunction($token, $this->_func_args));
}*/ }*/
// if it's an argument, ignore the token (the argument remains) // if it's an argument, ignore the token (the argument remains)
@ -573,7 +565,7 @@ class PHPExcel_Writer_Excel5_Parser
* @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
*/ */
private function _convertNumber($num) private function convertNumber($num)
{ {
// Integer in the range 0..2**16-1 // Integer in the range 0..2**16-1
if ((preg_match("/^\d+$/", $num)) and ($num <= 65535)) { if ((preg_match("/^\d+$/", $num)) and ($num <= 65535)) {
@ -593,7 +585,7 @@ class PHPExcel_Writer_Excel5_Parser
* @param string $string A string for conversion to its ptg value. * @param string $string A string for conversion to its ptg value.
* @return mixed the converted token on success * @return mixed the converted token on success
*/ */
private function _convertString($string) private function convertString($string)
{ {
// chop away beggining and ending quotes // chop away beggining and ending quotes
$string = substr($string, 1, strlen($string) - 2); $string = substr($string, 1, strlen($string) - 2);
@ -613,18 +605,18 @@ class PHPExcel_Writer_Excel5_Parser
* @param integer $num_args The number of arguments the function receives. * @param integer $num_args The number of arguments the function receives.
* @return string The packed ptg for the function * @return string The packed ptg for the function
*/ */
private function _convertFunction($token, $num_args) private function convertFunction($token, $num_args)
{ {
$args = $this->_functions[$token][1]; $args = $this->functions[$token][1];
// $volatile = $this->_functions[$token][3]; // $volatile = $this->functions[$token][3];
// Fixed number of args eg. TIME($i, $j, $k). // Fixed number of args eg. TIME($i, $j, $k).
if ($args >= 0) { if ($args >= 0) {
return pack("Cv", $this->ptg['ptgFuncV'], $this->_functions[$token][0]); return pack("Cv", $this->ptg['ptgFuncV'], $this->functions[$token][0]);
} }
// Variable number of args eg. SUM($i, $j, $k, ..). // Variable number of args eg. SUM($i, $j, $k, ..).
if ($args == -1) { if ($args == -1) {
return pack("CCv", $this->ptg['ptgFuncVarV'], $num_args, $this->_functions[$token][0]); return pack("CCv", $this->ptg['ptgFuncVarV'], $num_args, $this->functions[$token][0]);
} }
} }
@ -635,7 +627,7 @@ class PHPExcel_Writer_Excel5_Parser
* @param string $range An Excel range in the A1:A2 * @param string $range An Excel range in the A1:A2
* @param int $class * @param int $class
*/ */
private function _convertRange2d($range, $class = 0) private function convertRange2d($range, $class = 0)
{ {
// TODO: possible class value 0,1,2 check Formula.pm // TODO: possible class value 0,1,2 check Formula.pm
@ -648,8 +640,8 @@ class PHPExcel_Writer_Excel5_Parser
} }
// Convert the cell references // Convert the cell references
list($row1, $col1) = $this->_cellToPackedRowcol($cell1); list($row1, $col1) = $this->cellToPackedRowcol($cell1);
list($row2, $col2) = $this->_cellToPackedRowcol($cell2); list($row2, $col2) = $this->cellToPackedRowcol($cell2);
// The ptg value depends on the class of the ptg. // The ptg value depends on the class of the ptg.
if ($class == 0) { if ($class == 0) {
@ -673,7 +665,7 @@ class PHPExcel_Writer_Excel5_Parser
* @param string $token An Excel range in the Sheet1!A1:A2 format. * @param string $token An Excel range in the Sheet1!A1:A2 format.
* @return mixed The packed ptgArea3d token on success. * @return mixed The packed ptgArea3d token on success.
*/ */
private function _convertRange3d($token) private function convertRange3d($token)
{ {
// $class = 0; // formulas like Sheet1!$A$1:$A$2 in list type data validation need this class (0x3B) // $class = 0; // formulas like Sheet1!$A$1:$A$2 in list type data validation need this class (0x3B)
@ -681,17 +673,17 @@ class PHPExcel_Writer_Excel5_Parser
list($ext_ref, $range) = explode('!', $token); list($ext_ref, $range) = explode('!', $token);
// Convert the external reference part (different for BIFF8) // Convert the external reference part (different for BIFF8)
$ext_ref = $this->_getRefIndex($ext_ref); $ext_ref = $this->getRefIndex($ext_ref);
// Split the range into 2 cell refs // Split the range into 2 cell refs
list($cell1, $cell2) = explode(':', $range); list($cell1, $cell2) = explode(':', $range);
// Convert the cell references // Convert the cell references
if (preg_match("/^(\\$)?[A-Ia-i]?[A-Za-z](\\$)?(\d+)$/", $cell1)) { if (preg_match("/^(\\$)?[A-Ia-i]?[A-Za-z](\\$)?(\d+)$/", $cell1)) {
list($row1, $col1) = $this->_cellToPackedRowcol($cell1); list($row1, $col1) = $this->cellToPackedRowcol($cell1);
list($row2, $col2) = $this->_cellToPackedRowcol($cell2); list($row2, $col2) = $this->cellToPackedRowcol($cell2);
} else { // It's a rows range (like 26:27) } else { // It's a rows range (like 26:27)
list($row1, $col1, $row2, $col2) = $this->_rangeToPackedRange($cell1.':'.$cell2); list($row1, $col1, $row2, $col2) = $this->rangeToPackedRange($cell1.':'.$cell2);
} }
// The ptg value depends on the class of the ptg. // The ptg value depends on the class of the ptg.
@ -715,12 +707,12 @@ class PHPExcel_Writer_Excel5_Parser
* @param string $cell An Excel cell reference * @param string $cell An Excel cell reference
* @return string The cell in packed() format with the corresponding ptg * @return string The cell in packed() format with the corresponding ptg
*/ */
private function _convertRef2d($cell) private function convertRef2d($cell)
{ {
// $class = 2; // as far as I know, this is magick. // $class = 2; // as far as I know, this is magick.
// Convert the cell reference // Convert the cell reference
$cell_array = $this->_cellToPackedRowcol($cell); $cell_array = $this->cellToPackedRowcol($cell);
list($row, $col) = $cell_array; list($row, $col) = $cell_array;
// The ptg value depends on the class of the ptg. // The ptg value depends on the class of the ptg.
@ -745,7 +737,7 @@ class PHPExcel_Writer_Excel5_Parser
* @param string $cell An Excel cell reference * @param string $cell An Excel cell reference
* @return mixed The packed ptgRef3d token on success. * @return mixed The packed ptgRef3d token on success.
*/ */
private function _convertRef3d($cell) private function convertRef3d($cell)
{ {
// $class = 2; // as far as I know, this is magick. // $class = 2; // as far as I know, this is magick.
@ -753,10 +745,10 @@ class PHPExcel_Writer_Excel5_Parser
list($ext_ref, $cell) = explode('!', $cell); list($ext_ref, $cell) = explode('!', $cell);
// Convert the external reference part (different for BIFF8) // Convert the external reference part (different for BIFF8)
$ext_ref = $this->_getRefIndex($ext_ref); $ext_ref = $this->getRefIndex($ext_ref);
// Convert the cell reference part // Convert the cell reference part
list($row, $col) = $this->_cellToPackedRowcol($cell); list($row, $col) = $this->cellToPackedRowcol($cell);
// The ptg value depends on the class of the ptg. // The ptg value depends on the class of the ptg.
// if ($class == 0) { // if ($class == 0) {
@ -779,7 +771,7 @@ class PHPExcel_Writer_Excel5_Parser
* @param string $errorCode The error code for conversion to its ptg value * @param string $errorCode The error code for conversion to its ptg value
* @return string The error code ptgErr * @return string The error code ptgErr
*/ */
private function _convertError($errorCode) private function convertError($errorCode)
{ {
switch ($errorCode) { switch ($errorCode) {
case '#NULL!': case '#NULL!':
@ -808,7 +800,7 @@ class PHPExcel_Writer_Excel5_Parser
* @param string $ext_ref The name of the external reference * @param string $ext_ref The name of the external reference
* @return string The reference index in packed() format * @return string The reference index in packed() format
*/ */
private function _packExtRef($ext_ref) private function packExtRef($ext_ref)
{ {
$ext_ref = preg_replace("/^'/", '', $ext_ref); // Remove leading ' if any. $ext_ref = preg_replace("/^'/", '', $ext_ref); // Remove leading ' if any.
$ext_ref = preg_replace("/'$/", '', $ext_ref); // Remove trailing ' if any. $ext_ref = preg_replace("/'$/", '', $ext_ref); // Remove trailing ' if any.
@ -817,11 +809,11 @@ class PHPExcel_Writer_Excel5_Parser
if (preg_match("/:/", $ext_ref)) { if (preg_match("/:/", $ext_ref)) {
list($sheet_name1, $sheet_name2) = explode(':', $ext_ref); list($sheet_name1, $sheet_name2) = explode(':', $ext_ref);
$sheet1 = $this->_getSheetIndex($sheet_name1); $sheet1 = $this->getSheetIndex($sheet_name1);
if ($sheet1 == -1) { if ($sheet1 == -1) {
throw new PHPExcel_Writer_Exception("Unknown sheet name $sheet_name1 in formula"); throw new PHPExcel_Writer_Exception("Unknown sheet name $sheet_name1 in formula");
} }
$sheet2 = $this->_getSheetIndex($sheet_name2); $sheet2 = $this->getSheetIndex($sheet_name2);
if ($sheet2 == -1) { if ($sheet2 == -1) {
throw new PHPExcel_Writer_Exception("Unknown sheet name $sheet_name2 in formula"); throw new PHPExcel_Writer_Exception("Unknown sheet name $sheet_name2 in formula");
} }
@ -831,7 +823,7 @@ class PHPExcel_Writer_Excel5_Parser
list($sheet1, $sheet2) = array($sheet2, $sheet1); list($sheet1, $sheet2) = array($sheet2, $sheet1);
} }
} else { // Single sheet name only. } else { // Single sheet name only.
$sheet1 = $this->_getSheetIndex($ext_ref); $sheet1 = $this->getSheetIndex($ext_ref);
if ($sheet1 == -1) { if ($sheet1 == -1) {
throw new PHPExcel_Writer_Exception("Unknown sheet name $ext_ref in formula"); throw new PHPExcel_Writer_Exception("Unknown sheet name $ext_ref in formula");
} }
@ -853,7 +845,7 @@ class PHPExcel_Writer_Excel5_Parser
* @param string $ext_ref The name of the external reference * @param string $ext_ref The name of the external reference
* @return mixed The reference index in packed() format on success * @return mixed The reference index in packed() format on success
*/ */
private function _getRefIndex($ext_ref) private function getRefIndex($ext_ref)
{ {
$ext_ref = preg_replace("/^'/", '', $ext_ref); // Remove leading ' if any. $ext_ref = preg_replace("/^'/", '', $ext_ref); // Remove leading ' if any.
$ext_ref = preg_replace("/'$/", '', $ext_ref); // Remove trailing ' if any. $ext_ref = preg_replace("/'$/", '', $ext_ref); // Remove trailing ' if any.
@ -863,11 +855,11 @@ class PHPExcel_Writer_Excel5_Parser
if (preg_match("/:/", $ext_ref)) { if (preg_match("/:/", $ext_ref)) {
list($sheet_name1, $sheet_name2) = explode(':', $ext_ref); list($sheet_name1, $sheet_name2) = explode(':', $ext_ref);
$sheet1 = $this->_getSheetIndex($sheet_name1); $sheet1 = $this->getSheetIndex($sheet_name1);
if ($sheet1 == -1) { if ($sheet1 == -1) {
throw new PHPExcel_Writer_Exception("Unknown sheet name $sheet_name1 in formula"); throw new PHPExcel_Writer_Exception("Unknown sheet name $sheet_name1 in formula");
} }
$sheet2 = $this->_getSheetIndex($sheet_name2); $sheet2 = $this->getSheetIndex($sheet_name2);
if ($sheet2 == -1) { if ($sheet2 == -1) {
throw new PHPExcel_Writer_Exception("Unknown sheet name $sheet_name2 in formula"); throw new PHPExcel_Writer_Exception("Unknown sheet name $sheet_name2 in formula");
} }
@ -877,7 +869,7 @@ class PHPExcel_Writer_Excel5_Parser
list($sheet1, $sheet2) = array($sheet2, $sheet1); list($sheet1, $sheet2) = array($sheet2, $sheet1);
} }
} else { // Single sheet name only. } else { // Single sheet name only.
$sheet1 = $this->_getSheetIndex($ext_ref); $sheet1 = $this->getSheetIndex($ext_ref);
if ($sheet1 == -1) { if ($sheet1 == -1) {
throw new PHPExcel_Writer_Exception("Unknown sheet name $ext_ref in formula"); throw new PHPExcel_Writer_Exception("Unknown sheet name $ext_ref in formula");
} }
@ -887,18 +879,18 @@ class PHPExcel_Writer_Excel5_Parser
// assume all references belong to this document // assume all references belong to this document
$supbook_index = 0x00; $supbook_index = 0x00;
$ref = pack('vvv', $supbook_index, $sheet1, $sheet2); $ref = pack('vvv', $supbook_index, $sheet1, $sheet2);
$total_references = count($this->_references); $totalreferences = count($this->references);
$index = -1; $index = -1;
for ($i = 0; $i < $total_references; ++$i) { for ($i = 0; $i < $totalreferences; ++$i) {
if ($ref == $this->_references[$i]) { if ($ref == $this->references[$i]) {
$index = $i; $index = $i;
break; break;
} }
} }
// if REF was not found add it to references array // if REF was not found add it to references array
if ($index == -1) { if ($index == -1) {
$this->_references[$total_references] = $ref; $this->references[$totalreferences] = $ref;
$index = $total_references; $index = $totalreferences;
} }
return pack('v', $index); return pack('v', $index);
@ -913,12 +905,12 @@ class PHPExcel_Writer_Excel5_Parser
* @param string $sheet_name Sheet name * @param string $sheet_name Sheet name
* @return integer The sheet index, -1 if the sheet was not found * @return integer The sheet index, -1 if the sheet was not found
*/ */
private function _getSheetIndex($sheet_name) private function getSheetIndex($sheet_name)
{ {
if (!isset($this->_ext_sheets[$sheet_name])) { if (!isset($this->externalSheets[$sheet_name])) {
return -1; return -1;
} else { } else {
return $this->_ext_sheets[$sheet_name]; return $this->externalSheets[$sheet_name];
} }
} }
@ -934,7 +926,7 @@ class PHPExcel_Writer_Excel5_Parser
*/ */
public function setExtSheet($name, $index) public function setExtSheet($name, $index)
{ {
$this->_ext_sheets[$name] = $index; $this->externalSheets[$name] = $index;
} }
/** /**
@ -944,10 +936,10 @@ class PHPExcel_Writer_Excel5_Parser
* @param string $cell The Excel cell reference to be packed * @param string $cell The Excel cell reference to be packed
* @return array Array containing the row and column in packed() format * @return array Array containing the row and column in packed() format
*/ */
private function _cellToPackedRowcol($cell) private function cellToPackedRowcol($cell)
{ {
$cell = strtoupper($cell); $cell = strtoupper($cell);
list($row, $col, $row_rel, $col_rel) = $this->_cellToRowcol($cell); list($row, $col, $row_rel, $col_rel) = $this->cellToRowcol($cell);
if ($col >= 256) { if ($col >= 256) {
throw new PHPExcel_Writer_Exception("Column in: $cell greater than 255"); throw new PHPExcel_Writer_Exception("Column in: $cell greater than 255");
} }
@ -973,7 +965,7 @@ class PHPExcel_Writer_Excel5_Parser
* @param string $range The Excel range to be packed * @param string $range The Excel range to be packed
* @return array Array containing (row1,col1,row2,col2) in packed() format * @return array Array containing (row1,col1,row2,col2) in packed() format
*/ */
private function _rangeToPackedRange($range) private function rangeToPackedRange($range)
{ {
preg_match('/(\$)?(\d+)\:(\$)?(\d+)/', $range, $match); preg_match('/(\$)?(\d+)\:(\$)?(\d+)/', $range, $match);
// return absolute rows if there is a $ in the ref // return absolute rows if there is a $ in the ref
@ -1014,7 +1006,7 @@ class PHPExcel_Writer_Excel5_Parser
* @param string $cell The Excel cell reference in A1 format. * @param string $cell The Excel cell reference in A1 format.
* @return array * @return array
*/ */
private function _cellToRowcol($cell) private function cellToRowcol($cell)
{ {
preg_match('/(\$)?([A-I]?[A-Z])(\$)?(\d+)/', $cell, $match); preg_match('/(\$)?([A-I]?[A-Z])(\$)?(\d+)/', $cell, $match);
// return absolute column if there is a $ in the ref // return absolute column if there is a $ in the ref
@ -1044,48 +1036,48 @@ class PHPExcel_Writer_Excel5_Parser
* *
* @access private * @access private
*/ */
private function _advance() private function advance()
{ {
$i = $this->_current_char; $i = $this->currentCharacter;
$formula_length = strlen($this->_formula); $formula_length = strlen($this->formula);
// eat up white spaces // eat up white spaces
if ($i < $formula_length) { if ($i < $formula_length) {
while ($this->_formula{$i} == " ") { while ($this->formula{$i} == " ") {
++$i; ++$i;
} }
if ($i < ($formula_length - 1)) { if ($i < ($formula_length - 1)) {
$this->_lookahead = $this->_formula{$i+1}; $this->lookAhead = $this->formula{$i+1};
} }
$token = ''; $token = '';
} }
while ($i < $formula_length) { while ($i < $formula_length) {
$token .= $this->_formula{$i}; $token .= $this->formula{$i};
if ($i < ($formula_length - 1)) { if ($i < ($formula_length - 1)) {
$this->_lookahead = $this->_formula{$i+1}; $this->lookAhead = $this->formula{$i+1};
} else { } else {
$this->_lookahead = ''; $this->lookAhead = '';
} }
if ($this->_match($token) != '') { if ($this->match($token) != '') {
//if ($i < strlen($this->_formula) - 1) { //if ($i < strlen($this->formula) - 1) {
// $this->_lookahead = $this->_formula{$i+1}; // $this->lookAhead = $this->formula{$i+1};
//} //}
$this->_current_char = $i + 1; $this->currentCharacter = $i + 1;
$this->_current_token = $token; $this->currentToken = $token;
return 1; return 1;
} }
if ($i < ($formula_length - 2)) { if ($i < ($formula_length - 2)) {
$this->_lookahead = $this->_formula{$i+2}; $this->lookAhead = $this->formula{$i+2};
} else { // if we run out of characters _lookahead becomes empty } else { // if we run out of characters lookAhead becomes empty
$this->_lookahead = ''; $this->lookAhead = '';
} }
++$i; ++$i;
} }
//die("Lexical error ".$this->_current_char); //die("Lexical error ".$this->currentCharacter);
} }
/** /**
@ -1095,7 +1087,7 @@ class PHPExcel_Writer_Excel5_Parser
* @param mixed $token The token to check. * @param mixed $token The token to check.
* @return mixed The checked token or false on failure * @return mixed The checked token or false on failure
*/ */
private function _match($token) private function match($token)
{ {
switch ($token) { switch ($token) {
case "+": case "+":
@ -1116,47 +1108,47 @@ class PHPExcel_Writer_Excel5_Parser
return $token; return $token;
break; break;
case ">": case ">":
if ($this->_lookahead == '=') { // it's a GE token if ($this->lookAhead == '=') { // it's a GE token
break; break;
} }
return $token; return $token;
break; break;
case "<": case "<":
// it's a LE or a NE token // it's a LE or a NE token
if (($this->_lookahead == '=') or ($this->_lookahead == '>')) { if (($this->lookAhead == '=') or ($this->lookAhead == '>')) {
break; break;
} }
return $token; return $token;
break; break;
default: default:
// if it's a reference A1 or $A$1 or $A1 or A$1 // if it's a reference A1 or $A$1 or $A1 or A$1
if (preg_match('/^\$?[A-Ia-i]?[A-Za-z]\$?[0-9]+$/', $token) and !preg_match("/[0-9]/", $this->_lookahead) and ($this->_lookahead != ':') and ($this->_lookahead != '.') and ($this->_lookahead != '!')) { if (preg_match('/^\$?[A-Ia-i]?[A-Za-z]\$?[0-9]+$/', $token) and !preg_match("/[0-9]/", $this->lookAhead) and ($this->lookAhead != ':') and ($this->lookAhead != '.') and ($this->lookAhead != '!')) {
return $token; return $token;
} elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/u", $token) and !preg_match("/[0-9]/", $this->_lookahead) and ($this->_lookahead != ':') and ($this->_lookahead != '.')) { } elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/u", $token) and !preg_match("/[0-9]/", $this->lookAhead) and ($this->lookAhead != ':') and ($this->lookAhead != '.')) {
// If it's an external reference (Sheet1!A1 or Sheet1:Sheet2!A1 or Sheet1!$A$1 or Sheet1:Sheet2!$A$1) // If it's an external reference (Sheet1!A1 or Sheet1:Sheet2!A1 or Sheet1!$A$1 or Sheet1:Sheet2!$A$1)
return $token; return $token;
} elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/u", $token) and !preg_match("/[0-9]/", $this->_lookahead) and ($this->_lookahead != ':') and ($this->_lookahead != '.')) { } elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/u", $token) and !preg_match("/[0-9]/", $this->lookAhead) and ($this->lookAhead != ':') and ($this->lookAhead != '.')) {
// If it's an external reference ('Sheet1'!A1 or 'Sheet1:Sheet2'!A1 or 'Sheet1'!$A$1 or 'Sheet1:Sheet2'!$A$1) // If it's an external reference ('Sheet1'!A1 or 'Sheet1:Sheet2'!A1 or 'Sheet1'!$A$1 or 'Sheet1:Sheet2'!$A$1)
return $token; return $token;
} elseif (preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+:(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/', $token) && !preg_match("/[0-9]/", $this->_lookahead)) { } elseif (preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+:(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/', $token) && !preg_match("/[0-9]/", $this->lookAhead)) {
// if it's a range A1:A2 or $A$1:$A$2 // if it's a range A1:A2 or $A$1:$A$2
return $token; return $token;
} elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+:\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+$/u", $token) and !preg_match("/[0-9]/", $this->_lookahead)) { } elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+:\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+$/u", $token) and !preg_match("/[0-9]/", $this->lookAhead)) {
// If it's an external range like Sheet1!A1:B2 or Sheet1:Sheet2!A1:B2 or Sheet1!$A$1:$B$2 or Sheet1:Sheet2!$A$1:$B$2 // If it's an external range like Sheet1!A1:B2 or Sheet1:Sheet2!A1:B2 or Sheet1!$A$1:$B$2 or Sheet1:Sheet2!$A$1:$B$2
return $token; return $token;
} elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+:\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+$/u", $token) and !preg_match("/[0-9]/", $this->_lookahead)) { } elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+:\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+$/u", $token) and !preg_match("/[0-9]/", $this->lookAhead)) {
// If it's an external range like 'Sheet1'!A1:B2 or 'Sheet1:Sheet2'!A1:B2 or 'Sheet1'!$A$1:$B$2 or 'Sheet1:Sheet2'!$A$1:$B$2 // If it's an external range like 'Sheet1'!A1:B2 or 'Sheet1:Sheet2'!A1:B2 or 'Sheet1'!$A$1:$B$2 or 'Sheet1:Sheet2'!$A$1:$B$2
return $token; return $token;
} elseif (is_numeric($token) and (!is_numeric($token.$this->_lookahead) or ($this->_lookahead == '')) and ($this->_lookahead != '!') and ($this->_lookahead != ':')) { } elseif (is_numeric($token) and (!is_numeric($token.$this->lookAhead) or ($this->lookAhead == '')) and ($this->lookAhead != '!') and ($this->lookAhead != ':')) {
// 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)
return $token; return $token;
} elseif (preg_match("/\"([^\"]|\"\"){0,255}\"/", $token) and $this->_lookahead != '"' and (substr_count($token, '"')%2 == 0)) { } elseif (preg_match("/\"([^\"]|\"\"){0,255}\"/", $token) and $this->lookAhead != '"' and (substr_count($token, '"')%2 == 0)) {
// If it's a string (of maximum 255 characters) // If it's a string (of maximum 255 characters)
return $token; return $token;
} elseif (preg_match("/^#[A-Z0\/]{3,5}[!?]{1}$/", $token) or $token == '#N/A') { } elseif (preg_match("/^#[A-Z0\/]{3,5}[!?]{1}$/", $token) or $token == '#N/A') {
// If it's an error code // If it's an error code
return $token; return $token;
} 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 == "(")) {
// if it's a function call // if it's a function call
return $token; return $token;
} elseif (substr($token, -1) == ')') { } elseif (substr($token, -1) == ')') {
@ -1178,11 +1170,11 @@ class PHPExcel_Writer_Excel5_Parser
*/ */
public function parse($formula) public function parse($formula)
{ {
$this->_current_char = 0; $this->currentCharacter = 0;
$this->_formula = $formula; $this->formula = $formula;
$this->_lookahead = isset($formula{1}) ? $formula{1} : ''; $this->lookAhead = isset($formula{1}) ? $formula{1} : '';
$this->_advance(); $this->advance();
$this->_parse_tree = $this->_condition(); $this->parseTree = $this->condition();
return true; return true;
} }
@ -1193,37 +1185,37 @@ class PHPExcel_Writer_Excel5_Parser
* @access private * @access private
* @return mixed The parsed ptg'd tree on success * @return mixed The parsed ptg'd tree on success
*/ */
private function _condition() private function condition()
{ {
$result = $this->_expression(); $result = $this->expression();
if ($this->_current_token == "<") { if ($this->currentToken == "<") {
$this->_advance(); $this->advance();
$result2 = $this->_expression(); $result2 = $this->expression();
$result = $this->_createTree('ptgLT', $result, $result2); $result = $this->createTree('ptgLT', $result, $result2);
} elseif ($this->_current_token == ">") { } elseif ($this->currentToken == ">") {
$this->_advance(); $this->advance();
$result2 = $this->_expression(); $result2 = $this->expression();
$result = $this->_createTree('ptgGT', $result, $result2); $result = $this->createTree('ptgGT', $result, $result2);
} elseif ($this->_current_token == "<=") { } elseif ($this->currentToken == "<=") {
$this->_advance(); $this->advance();
$result2 = $this->_expression(); $result2 = $this->expression();
$result = $this->_createTree('ptgLE', $result, $result2); $result = $this->createTree('ptgLE', $result, $result2);
} elseif ($this->_current_token == ">=") { } elseif ($this->currentToken == ">=") {
$this->_advance(); $this->advance();
$result2 = $this->_expression(); $result2 = $this->expression();
$result = $this->_createTree('ptgGE', $result, $result2); $result = $this->createTree('ptgGE', $result, $result2);
} elseif ($this->_current_token == "=") { } elseif ($this->currentToken == "=") {
$this->_advance(); $this->advance();
$result2 = $this->_expression(); $result2 = $this->expression();
$result = $this->_createTree('ptgEQ', $result, $result2); $result = $this->createTree('ptgEQ', $result, $result2);
} elseif ($this->_current_token == "<>") { } elseif ($this->currentToken == "<>") {
$this->_advance(); $this->advance();
$result2 = $this->_expression(); $result2 = $this->expression();
$result = $this->_createTree('ptgNE', $result, $result2); $result = $this->createTree('ptgNE', $result, $result2);
} elseif ($this->_current_token == "&") { } elseif ($this->currentToken == "&") {
$this->_advance(); $this->advance();
$result2 = $this->_expression(); $result2 = $this->expression();
$result = $this->_createTree('ptgConcat', $result, $result2); $result = $this->createTree('ptgConcat', $result, $result2);
} }
return $result; return $result;
} }
@ -1239,55 +1231,55 @@ class PHPExcel_Writer_Excel5_Parser
* @access private * @access private
* @return mixed The parsed ptg'd tree on success * @return mixed The parsed ptg'd tree on success
*/ */
private function _expression() private function expression()
{ {
// If it's a string return a string node // If it's a string return a string node
if (preg_match("/\"([^\"]|\"\"){0,255}\"/", $this->_current_token)) { if (preg_match("/\"([^\"]|\"\"){0,255}\"/", $this->currentToken)) {
$tmp = str_replace('""', '"', $this->_current_token); $tmp = str_replace('""', '"', $this->currentToken);
if (($tmp == '"') || ($tmp == '')) { if (($tmp == '"') || ($tmp == '')) {
// Trap for "" that has been used for an empty string // Trap for "" that has been used for an empty string
$tmp = '""'; $tmp = '""';
} }
$result = $this->_createTree($tmp, '', ''); $result = $this->createTree($tmp, '', '');
$this->_advance(); $this->advance();
return $result; return $result;
// If it's an error code // If it's an error code
} elseif (preg_match("/^#[A-Z0\/]{3,5}[!?]{1}$/", $this->_current_token) or $this->_current_token == '#N/A') { } elseif (preg_match("/^#[A-Z0\/]{3,5}[!?]{1}$/", $this->currentToken) or $this->currentToken == '#N/A') {
$result = $this->_createTree($this->_current_token, 'ptgErr', ''); $result = $this->createTree($this->currentToken, 'ptgErr', '');
$this->_advance(); $this->advance();
return $result; return $result;
// If it's a negative value // If it's a negative value
} elseif ($this->_current_token == "-") { } elseif ($this->currentToken == "-") {
// catch "-" Term // catch "-" Term
$this->_advance(); $this->advance();
$result2 = $this->_expression(); $result2 = $this->expression();
$result = $this->_createTree('ptgUminus', $result2, ''); $result = $this->createTree('ptgUminus', $result2, '');
return $result; return $result;
// If it's a positive value // If it's a positive value
} elseif ($this->_current_token == "+") { } elseif ($this->currentToken == "+") {
// catch "+" Term // catch "+" Term
$this->_advance(); $this->advance();
$result2 = $this->_expression(); $result2 = $this->expression();
$result = $this->_createTree('ptgUplus', $result2, ''); $result = $this->createTree('ptgUplus', $result2, '');
return $result; return $result;
} }
$result = $this->_term(); $result = $this->term();
while (($this->_current_token == "+") or while (($this->currentToken == "+") or
($this->_current_token == "-") or ($this->currentToken == "-") or
($this->_current_token == "^")) { ($this->currentToken == "^")) {
/**/ /**/
if ($this->_current_token == "+") { if ($this->currentToken == "+") {
$this->_advance(); $this->advance();
$result2 = $this->_term(); $result2 = $this->term();
$result = $this->_createTree('ptgAdd', $result, $result2); $result = $this->createTree('ptgAdd', $result, $result2);
} elseif ($this->_current_token == "-") { } elseif ($this->currentToken == "-") {
$this->_advance(); $this->advance();
$result2 = $this->_term(); $result2 = $this->term();
$result = $this->_createTree('ptgSub', $result, $result2); $result = $this->createTree('ptgSub', $result, $result2);
} else { } else {
$this->_advance(); $this->advance();
$result2 = $this->_term(); $result2 = $this->term();
$result = $this->_createTree('ptgPower', $result, $result2); $result = $this->createTree('ptgPower', $result, $result2);
} }
} }
return $result; return $result;
@ -1298,12 +1290,12 @@ class PHPExcel_Writer_Excel5_Parser
* 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
* @see _fact() * @see fact()
* @return array The parsed ptg'd tree * @return array The parsed ptg'd tree
*/ */
private function _parenthesizedExpression() private function parenthesizedExpression()
{ {
$result = $this->_createTree('ptgParen', $this->_expression(), ''); $result = $this->createTree('ptgParen', $this->expression(), '');
return $result; return $result;
} }
@ -1314,20 +1306,20 @@ class PHPExcel_Writer_Excel5_Parser
* @access private * @access private
* @return mixed The parsed ptg'd tree on success * @return mixed The parsed ptg'd tree on success
*/ */
private function _term() private function term()
{ {
$result = $this->_fact(); $result = $this->fact();
while (($this->_current_token == "*") or while (($this->currentToken == "*") or
($this->_current_token == "/")) { ($this->currentToken == "/")) {
/**/ /**/
if ($this->_current_token == "*") { if ($this->currentToken == "*") {
$this->_advance(); $this->advance();
$result2 = $this->_fact(); $result2 = $this->fact();
$result = $this->_createTree('ptgMul', $result, $result2); $result = $this->createTree('ptgMul', $result, $result2);
} else { } else {
$this->_advance(); $this->advance();
$result2 = $this->_fact(); $result2 = $this->fact();
$result = $this->_createTree('ptgDiv', $result, $result2); $result = $this->createTree('ptgDiv', $result, $result2);
} }
} }
return $result; return $result;
@ -1344,69 +1336,69 @@ class PHPExcel_Writer_Excel5_Parser
* @access private * @access private
* @return mixed The parsed ptg'd tree on success * @return mixed The parsed ptg'd tree on success
*/ */
private function _fact() private function fact()
{ {
if ($this->_current_token == "(") { if ($this->currentToken == "(") {
$this->_advance(); // eat the "(" $this->advance(); // eat the "("
$result = $this->_parenthesizedExpression(); $result = $this->parenthesizedExpression();
if ($this->_current_token != ")") { if ($this->currentToken != ")") {
throw new PHPExcel_Writer_Exception("')' token expected."); throw new PHPExcel_Writer_Exception("')' token expected.");
} }
$this->_advance(); // eat the ")" $this->advance(); // eat the ")"
return $result; return $result;
} }
// if it's a reference // if it's a reference
if (preg_match('/^\$?[A-Ia-i]?[A-Za-z]\$?[0-9]+$/', $this->_current_token)) { if (preg_match('/^\$?[A-Ia-i]?[A-Za-z]\$?[0-9]+$/', $this->currentToken)) {
$result = $this->_createTree($this->_current_token, '', ''); $result = $this->createTree($this->currentToken, '', '');
$this->_advance(); $this->advance();
return $result; return $result;
} elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/u", $this->_current_token)) { } elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/u", $this->currentToken)) {
// If it's an external reference (Sheet1!A1 or Sheet1:Sheet2!A1 or Sheet1!$A$1 or Sheet1:Sheet2!$A$1) // If it's an external reference (Sheet1!A1 or Sheet1:Sheet2!A1 or Sheet1!$A$1 or Sheet1:Sheet2!$A$1)
$result = $this->_createTree($this->_current_token, '', ''); $result = $this->createTree($this->currentToken, '', '');
$this->_advance(); $this->advance();
return $result; return $result;
} elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/u", $this->_current_token)) { } elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/u", $this->currentToken)) {
// If it's an external reference ('Sheet1'!A1 or 'Sheet1:Sheet2'!A1 or 'Sheet1'!$A$1 or 'Sheet1:Sheet2'!$A$1) // If it's an external reference ('Sheet1'!A1 or 'Sheet1:Sheet2'!A1 or 'Sheet1'!$A$1 or 'Sheet1:Sheet2'!$A$1)
$result = $this->_createTree($this->_current_token, '', ''); $result = $this->createTree($this->currentToken, '', '');
$this->_advance(); $this->advance();
return $result; return $result;
} 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->currentToken) 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->currentToken)) {
// if it's a range A1:B2 or $A$1:$B$2 // if it's a range A1:B2 or $A$1:$B$2
// must be an error? // must be an error?
$result = $this->_createTree($this->_current_token, '', ''); $result = $this->createTree($this->currentToken, '', '');
$this->_advance(); $this->advance();
return $result; return $result;
} elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+:\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+$/u", $this->_current_token)) { } elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+:\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+$/u", $this->currentToken)) {
// If it's an external range (Sheet1!A1:B2 or Sheet1:Sheet2!A1:B2 or Sheet1!$A$1:$B$2 or Sheet1:Sheet2!$A$1:$B$2) // If it's an external range (Sheet1!A1:B2 or Sheet1:Sheet2!A1:B2 or Sheet1!$A$1:$B$2 or Sheet1:Sheet2!$A$1:$B$2)
// must be an error? // must be an error?
//$result = $this->_current_token; //$result = $this->currentToken;
$result = $this->_createTree($this->_current_token, '', ''); $result = $this->createTree($this->currentToken, '', '');
$this->_advance(); $this->advance();
return $result; return $result;
} elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+:\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+$/u", $this->_current_token)) { } elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+:\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+$/u", $this->currentToken)) {
// If it's an external range ('Sheet1'!A1:B2 or 'Sheet1'!A1:B2 or 'Sheet1'!$A$1:$B$2 or 'Sheet1'!$A$1:$B$2) // If it's an external range ('Sheet1'!A1:B2 or 'Sheet1'!A1:B2 or 'Sheet1'!$A$1:$B$2 or 'Sheet1'!$A$1:$B$2)
// must be an error? // must be an error?
//$result = $this->_current_token; //$result = $this->currentToken;
$result = $this->_createTree($this->_current_token, '', ''); $result = $this->createTree($this->currentToken, '', '');
$this->_advance(); $this->advance();
return $result; return $result;
} elseif (is_numeric($this->_current_token)) { } elseif (is_numeric($this->currentToken)) {
// If it's a number or a percent // If it's a number or a percent
if ($this->_lookahead == '%') { if ($this->lookAhead == '%') {
$result = $this->_createTree('ptgPercent', $this->_current_token, ''); $result = $this->createTree('ptgPercent', $this->currentToken, '');
$this->_advance(); // Skip the percentage operator once we've pre-built that tree $this->advance(); // Skip the percentage operator once we've pre-built that tree
} else { } else {
$result = $this->_createTree($this->_current_token, '', ''); $result = $this->createTree($this->currentToken, '', '');
} }
$this->_advance(); $this->advance();
return $result; return $result;
} elseif (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/i", $this->_current_token)) { } elseif (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/i", $this->currentToken)) {
// if it's a function call // if it's a function call
$result = $this->_func(); $result = $this->func();
return $result; return $result;
} }
throw new PHPExcel_Writer_Exception("Syntax error: ".$this->_current_token.", lookahead: ".$this->_lookahead.", current char: ".$this->_current_char); throw new PHPExcel_Writer_Exception("Syntax error: ".$this->currentToken.", lookahead: ".$this->lookAhead.", current char: ".$this->currentCharacter);
} }
/** /**
@ -1416,40 +1408,40 @@ class PHPExcel_Writer_Excel5_Parser
* @access private * @access private
* @return mixed The parsed ptg'd tree on success * @return mixed The parsed ptg'd tree on success
*/ */
private function _func() private function func()
{ {
$num_args = 0; // number of arguments received $num_args = 0; // number of arguments received
$function = strtoupper($this->_current_token); $function = strtoupper($this->currentToken);
$result = ''; // initialize result $result = ''; // initialize result
$this->_advance(); $this->advance();
$this->_advance(); // eat the "(" $this->advance(); // eat the "("
while ($this->_current_token != ')') { while ($this->currentToken != ')') {
/**/ /**/
if ($num_args > 0) { if ($num_args > 0) {
if ($this->_current_token == "," || $this->_current_token == ";") { if ($this->currentToken == "," || $this->currentToken == ";") {
$this->_advance(); // eat the "," or ";" $this->advance(); // eat the "," or ";"
} else { } else {
throw new PHPExcel_Writer_Exception("Syntax error: comma expected in function $function, arg #{$num_args}"); throw new PHPExcel_Writer_Exception("Syntax error: comma expected in function $function, arg #{$num_args}");
} }
$result2 = $this->_condition(); $result2 = $this->condition();
$result = $this->_createTree('arg', $result, $result2); $result = $this->createTree('arg', $result, $result2);
} else { // first argument } else { // first argument
$result2 = $this->_condition(); $result2 = $this->condition();
$result = $this->_createTree('arg', '', $result2); $result = $this->createTree('arg', '', $result2);
} }
++$num_args; ++$num_args;
} }
if (!isset($this->_functions[$function])) { if (!isset($this->functions[$function])) {
throw new PHPExcel_Writer_Exception("Function $function() doesn't exist"); throw new PHPExcel_Writer_Exception("Function $function() doesn't exist");
} }
$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)) {
throw new PHPExcel_Writer_Exception("Incorrect number of arguments in function $function() "); throw new PHPExcel_Writer_Exception("Incorrect number of arguments in function $function() ");
} }
$result = $this->_createTree($function, $result, $num_args); $result = $this->createTree($function, $result, $num_args);
$this->_advance(); // eat the ")" $this->advance(); // eat the ")"
return $result; return $result;
} }
@ -1463,7 +1455,7 @@ class PHPExcel_Writer_Excel5_Parser
* @param mixed $right The right array (sub-tree) or a final node. * @param mixed $right The right array (sub-tree) or a final node.
* @return array A tree * @return array A tree
*/ */
private function _createTree($value, $left, $right) private function createTree($value, $left, $right)
{ {
return array('value' => $value, 'left' => $left, 'right' => $right); return array('value' => $value, 'left' => $left, 'right' => $right);
} }
@ -1498,22 +1490,22 @@ class PHPExcel_Writer_Excel5_Parser
public function toReversePolish($tree = array()) public function toReversePolish($tree = array())
{ {
$polish = ""; // the string we are going to return $polish = ""; // the string we are going to return
if (empty($tree)) { // If it's the first call use _parse_tree if (empty($tree)) { // If it's the first call use parseTree
$tree = $this->_parse_tree; $tree = $this->parseTree;
} }
if (is_array($tree['left'])) { if (is_array($tree['left'])) {
$converted_tree = $this->toReversePolish($tree['left']); $converted_tree = $this->toReversePolish($tree['left']);
$polish .= $converted_tree; $polish .= $converted_tree;
} elseif ($tree['left'] != '') { // It's a final node } elseif ($tree['left'] != '') { // It's a final node
$converted_tree = $this->_convert($tree['left']); $converted_tree = $this->convert($tree['left']);
$polish .= $converted_tree; $polish .= $converted_tree;
} }
if (is_array($tree['right'])) { if (is_array($tree['right'])) {
$converted_tree = $this->toReversePolish($tree['right']); $converted_tree = $this->toReversePolish($tree['right']);
$polish .= $converted_tree; $polish .= $converted_tree;
} elseif ($tree['right'] != '') { // It's a final node } elseif ($tree['right'] != '') { // It's a final node
$converted_tree = $this->_convert($tree['right']); $converted_tree = $this->convert($tree['right']);
$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 function convert it here (so we can set it's arguments)
@ -1529,9 +1521,9 @@ class PHPExcel_Writer_Excel5_Parser
$left_tree = ''; $left_tree = '';
} }
// add it's left subtree and return. // add it's left subtree and return.
return $left_tree.$this->_convertFunction($tree['value'], $tree['right']); return $left_tree.$this->convertFunction($tree['value'], $tree['right']);
} else { } else {
$converted_tree = $this->_convert($tree['value']); $converted_tree = $this->convert($tree['value']);
} }
$polish .= $converted_tree; $polish .= $converted_tree;
return $polish; return $polish;

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_Writer_Excel5_Workbook
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -59,15 +60,6 @@
// * License along with this library; if not, write to the Free Software // * License along with this library; if not, write to the Free Software
// * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// */ // */
/**
* PHPExcel_Writer_Excel5_Workbook
*
* @category PHPExcel
* @package PHPExcel_Writer_Excel5
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
{ {
/** /**
@ -75,119 +67,119 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
* *
* @var PHPExcel_Writer_Excel5_Parser * @var PHPExcel_Writer_Excel5_Parser
*/ */
private $_parser; private $parser;
/** /**
* The BIFF file size for the workbook. * The BIFF file size for the workbook.
* @var integer * @var integer
* @see _calcSheetOffsets() * @see calcSheetOffsets()
*/ */
public $_biffsize; private $biffSize;
/** /**
* XF Writers * XF Writers
* @var PHPExcel_Writer_Excel5_Xf[] * @var PHPExcel_Writer_Excel5_Xf[]
*/ */
private $_xfWriters = array(); private $xfWriters = array();
/** /**
* Array containing the colour palette * Array containing the colour palette
* @var array * @var array
*/ */
public $_palette; private $palette;
/** /**
* The codepage indicates the text encoding used for strings * The codepage indicates the text encoding used for strings
* @var integer * @var integer
*/ */
public $_codepage; private $codepage;
/** /**
* The country code used for localization * The country code used for localization
* @var integer * @var integer
*/ */
public $_country_code; private $countryCode;
/** /**
* Workbook * Workbook
* @var PHPExcel * @var PHPExcel
*/ */
private $_phpExcel; private $phpExcel;
/** /**
* Fonts writers * Fonts writers
* *
* @var PHPExcel_Writer_Excel5_Font[] * @var PHPExcel_Writer_Excel5_Font[]
*/ */
private $_fontWriters = array(); private $fontWriters = array();
/** /**
* Added fonts. Maps from font's hash => index in workbook * Added fonts. Maps from font's hash => index in workbook
* *
* @var array * @var array
*/ */
private $_addedFonts = array(); private $addedFonts = array();
/** /**
* Shared number formats * Shared number formats
* *
* @var array * @var array
*/ */
private $_numberFormats = array(); private $numberFormats = array();
/** /**
* Added number formats. Maps from numberFormat's hash => index in workbook * Added number formats. Maps from numberFormat's hash => index in workbook
* *
* @var array * @var array
*/ */
private $_addedNumberFormats = array(); private $addedNumberFormats = array();
/** /**
* Sizes of the binary worksheet streams * Sizes of the binary worksheet streams
* *
* @var array * @var array
*/ */
private $_worksheetSizes = array(); private $worksheetSizes = array();
/** /**
* Offsets of the binary worksheet streams relative to the start of the global workbook stream * Offsets of the binary worksheet streams relative to the start of the global workbook stream
* *
* @var array * @var array
*/ */
private $_worksheetOffsets = array(); private $worksheetOffsets = array();
/** /**
* Total number of shared strings in workbook * Total number of shared strings in workbook
* *
* @var int * @var int
*/ */
private $_str_total; private $strTotal;
/** /**
* Number of unique shared strings in workbook * Number of unique shared strings in workbook
* *
* @var int * @var int
*/ */
private $_str_unique; private $strUnique;
/** /**
* Array of unique shared strings in workbook * Array of unique shared strings in workbook
* *
* @var array * @var array
*/ */
private $_str_table; private $strTable;
/** /**
* Color cache * Color cache
*/ */
private $_colors; private $colors;
/** /**
* Escher object corresponding to MSODRAWINGGROUP * Escher object corresponding to MSODRAWINGGROUP
* *
* @var PHPExcel_Shared_Escher * @var PHPExcel_Shared_Escher
*/ */
private $_escher; private $escher;
/** /**
@ -205,37 +197,37 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
// It needs to call its parent's constructor explicitly // It needs to call its parent's constructor explicitly
parent::__construct(); parent::__construct();
$this->_parser = $parser; $this->parser = $parser;
$this->_biffsize = 0; $this->biffSize = 0;
$this->_palette = array(); $this->palette = array();
$this->_country_code = -1; $this->countryCode = -1;
$this->_str_total = &$str_total; $this->strTotal = &$str_total;
$this->_str_unique = &$str_unique; $this->strUnique = &$str_unique;
$this->_str_table = &$str_table; $this->strTable = &$str_table;
$this->_colors = &$colors; $this->colors = &$colors;
$this->_setPaletteXl97(); $this->setPaletteXl97();
$this->_phpExcel = $phpExcel; $this->phpExcel = $phpExcel;
// set BIFFwriter limit for CONTINUE records // set BIFFwriter limit for CONTINUE records
// $this->_limit = 8224; // $this->_limit = 8224;
$this->_codepage = 0x04B0; $this->codepage = 0x04B0;
// Add empty sheets and Build color cache // Add empty sheets and Build color cache
$countSheets = $phpExcel->getSheetCount(); $countSheets = $phpExcel->getSheetCount();
for ($i = 0; $i < $countSheets; ++$i) { for ($i = 0; $i < $countSheets; ++$i) {
$phpSheet = $phpExcel->getSheet($i); $phpSheet = $phpExcel->getSheet($i);
$this->_parser->setExtSheet($phpSheet->getTitle(), $i); // Register worksheet name with parser $this->parser->setExtSheet($phpSheet->getTitle(), $i); // Register worksheet name with parser
$supbook_index = 0x00; $supbook_index = 0x00;
$ref = pack('vvv', $supbook_index, $i, $i); $ref = pack('vvv', $supbook_index, $i, $i);
$this->_parser->_references[] = $ref; // Register reference with parser $this->parser->references[] = $ref; // Register reference with parser
// Sheet tab colors? // Sheet tab colors?
if ($phpSheet->isTabColorSet()) { if ($phpSheet->isTabColorSet()) {
$this->_addColor($phpSheet->getTabColor()->getRGB()); $this->addColor($phpSheet->getTabColor()->getRGB());
} }
} }
@ -254,30 +246,30 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
$xfWriter->setIsStyleXf($isStyleXf); $xfWriter->setIsStyleXf($isStyleXf);
// Add the font if not already added // Add the font if not already added
$fontIndex = $this->_addFont($style->getFont()); $fontIndex = $this->addFont($style->getFont());
// Assign the font index to the xf record // Assign the font index to the xf record
$xfWriter->setFontIndex($fontIndex); $xfWriter->setFontIndex($fontIndex);
// Background colors, best to treat these after the font so black will come after white in custom palette // Background colors, best to treat these after the font so black will come after white in custom palette
$xfWriter->setFgColor($this->_addColor($style->getFill()->getStartColor()->getRGB())); $xfWriter->setFgColor($this->addColor($style->getFill()->getStartColor()->getRGB()));
$xfWriter->setBgColor($this->_addColor($style->getFill()->getEndColor()->getRGB())); $xfWriter->setBgColor($this->addColor($style->getFill()->getEndColor()->getRGB()));
$xfWriter->setBottomColor($this->_addColor($style->getBorders()->getBottom()->getColor()->getRGB())); $xfWriter->setBottomColor($this->addColor($style->getBorders()->getBottom()->getColor()->getRGB()));
$xfWriter->setTopColor($this->_addColor($style->getBorders()->getTop()->getColor()->getRGB())); $xfWriter->setTopColor($this->addColor($style->getBorders()->getTop()->getColor()->getRGB()));
$xfWriter->setRightColor($this->_addColor($style->getBorders()->getRight()->getColor()->getRGB())); $xfWriter->setRightColor($this->addColor($style->getBorders()->getRight()->getColor()->getRGB()));
$xfWriter->setLeftColor($this->_addColor($style->getBorders()->getLeft()->getColor()->getRGB())); $xfWriter->setLeftColor($this->addColor($style->getBorders()->getLeft()->getColor()->getRGB()));
$xfWriter->setDiagColor($this->_addColor($style->getBorders()->getDiagonal()->getColor()->getRGB())); $xfWriter->setDiagColor($this->addColor($style->getBorders()->getDiagonal()->getColor()->getRGB()));
// Add the number format if it is not a built-in one and not already added // Add the number format if it is not a built-in one and not already added
if ($style->getNumberFormat()->getBuiltInFormatCode() === false) { if ($style->getNumberFormat()->getBuiltInFormatCode() === false) {
$numberFormatHashCode = $style->getNumberFormat()->getHashCode(); $numberFormatHashCode = $style->getNumberFormat()->getHashCode();
if (isset($this->_addedNumberFormats[$numberFormatHashCode])) { if (isset($this->addedNumberFormats[$numberFormatHashCode])) {
$numberFormatIndex = $this->_addedNumberFormats[$numberFormatHashCode]; $numberFormatIndex = $this->addedNumberFormats[$numberFormatHashCode];
} else { } else {
$numberFormatIndex = 164 + count($this->_numberFormats); $numberFormatIndex = 164 + count($this->numberFormats);
$this->_numberFormats[$numberFormatIndex] = $style->getNumberFormat(); $this->numberFormats[$numberFormatIndex] = $style->getNumberFormat();
$this->_addedNumberFormats[$numberFormatHashCode] = $numberFormatIndex; $this->addedNumberFormats[$numberFormatHashCode] = $numberFormatIndex;
} }
} else { } else {
$numberFormatIndex = (int) $style->getNumberFormat()->getBuiltInFormatCode(); $numberFormatIndex = (int) $style->getNumberFormat()->getBuiltInFormatCode();
@ -286,9 +278,9 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
// Assign the number format index to xf record // Assign the number format index to xf record
$xfWriter->setNumberFormatIndex($numberFormatIndex); $xfWriter->setNumberFormatIndex($numberFormatIndex);
$this->_xfWriters[] = $xfWriter; $this->xfWriters[] = $xfWriter;
$xfIndex = count($this->_xfWriters) - 1; $xfIndex = count($this->xfWriters) - 1;
return $xfIndex; return $xfIndex;
} }
@ -298,20 +290,20 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
* @param PHPExcel_Style_Font $font * @param PHPExcel_Style_Font $font
* @return int Index to FONT record * @return int Index to FONT record
*/ */
public function _addFont(PHPExcel_Style_Font $font) public function addFont(PHPExcel_Style_Font $font)
{ {
$fontHashCode = $font->getHashCode(); $fontHashCode = $font->getHashCode();
if (isset($this->_addedFonts[$fontHashCode])) { if (isset($this->addedFonts[$fontHashCode])) {
$fontIndex = $this->_addedFonts[$fontHashCode]; $fontIndex = $this->addedFonts[$fontHashCode];
} else { } else {
$countFonts = count($this->_fontWriters); $countFonts = count($this->fontWriters);
$fontIndex = ($countFonts < 4) ? $countFonts : $countFonts + 1; $fontIndex = ($countFonts < 4) ? $countFonts : $countFonts + 1;
$fontWriter = new PHPExcel_Writer_Excel5_Font($font); $fontWriter = new PHPExcel_Writer_Excel5_Font($font);
$fontWriter->setColorIndex($this->_addColor($font->getColor()->getRGB())); $fontWriter->setColorIndex($this->addColor($font->getColor()->getRGB()));
$this->_fontWriters[] = $fontWriter; $this->fontWriters[] = $fontWriter;
$this->_addedFonts[$fontHashCode] = $fontIndex; $this->addedFonts[$fontHashCode] = $fontIndex;
} }
return $fontIndex; return $fontIndex;
} }
@ -322,27 +314,27 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
* @param string $rgb E.g. 'FF00AA' * @param string $rgb E.g. 'FF00AA'
* @return int Color index * @return int Color index
*/ */
private function _addColor($rgb) private function addColor($rgb)
{ {
if (!isset($this->_colors[$rgb])) { if (!isset($this->colors[$rgb])) {
if (count($this->_colors) < 57) { if (count($this->colors) < 57) {
// then we add a custom color altering the palette // then we add a custom color altering the palette
$colorIndex = 8 + count($this->_colors); $colorIndex = 8 + count($this->colors);
$this->_palette[$colorIndex] = $this->palette[$colorIndex] =
array( array(
hexdec(substr($rgb, 0, 2)), hexdec(substr($rgb, 0, 2)),
hexdec(substr($rgb, 2, 2)), hexdec(substr($rgb, 2, 2)),
hexdec(substr($rgb, 4)), hexdec(substr($rgb, 4)),
0 0
); );
$this->_colors[$rgb] = $colorIndex; $this->colors[$rgb] = $colorIndex;
} else { } else {
// no room for more custom colors, just map to black // no room for more custom colors, just map to black
$colorIndex = 0; $colorIndex = 0;
} }
} else { } else {
// fetch already added custom color // fetch already added custom color
$colorIndex = $this->_colors[$rgb]; $colorIndex = $this->colors[$rgb];
} }
return $colorIndex; return $colorIndex;
@ -353,9 +345,9 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
* *
* @access private * @access private
*/ */
private function _setPaletteXl97() private function setPaletteXl97()
{ {
$this->_palette = array( $this->palette = array(
0x08 => array(0x00, 0x00, 0x00, 0x00), 0x08 => array(0x00, 0x00, 0x00, 0x00),
0x09 => array(0xff, 0xff, 0xff, 0x00), 0x09 => array(0xff, 0xff, 0xff, 0x00),
0x0A => array(0xff, 0x00, 0x00, 0x00), 0x0A => array(0xff, 0x00, 0x00, 0x00),
@ -424,45 +416,45 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
*/ */
public function writeWorkbook($pWorksheetSizes = null) public function writeWorkbook($pWorksheetSizes = null)
{ {
$this->_worksheetSizes = $pWorksheetSizes; $this->worksheetSizes = $pWorksheetSizes;
// Calculate the number of selected worksheet tabs and call the finalization // Calculate the number of selected worksheet tabs and call the finalization
// methods for each worksheet // methods for each worksheet
$total_worksheets = $this->_phpExcel->getSheetCount(); $total_worksheets = $this->phpExcel->getSheetCount();
// Add part 1 of the Workbook globals, what goes before the SHEET records // Add part 1 of the Workbook globals, what goes before the SHEET records
$this->_storeBof(0x0005); $this->storeBof(0x0005);
$this->_writeCodepage(); $this->writeCodepage();
$this->_writeWindow1(); $this->writeWindow1();
$this->_writeDatemode(); $this->writeDateMode();
$this->_writeAllFonts(); $this->writeAllFonts();
$this->_writeAllNumFormats(); $this->writeAllNumberFormats();
$this->_writeAllXfs(); $this->writeAllXfs();
$this->_writeAllStyles(); $this->writeAllStyles();
$this->_writePalette(); $this->writePalette();
// Prepare part 3 of the workbook global stream, what goes after the SHEET records // Prepare part 3 of the workbook global stream, what goes after the SHEET records
$part3 = ''; $part3 = '';
if ($this->_country_code != -1) { if ($this->countryCode != -1) {
$part3 .= $this->_writeCountry(); $part3 .= $this->writeCountry();
} }
$part3 .= $this->_writeRecalcId(); $part3 .= $this->writeRecalcId();
$part3 .= $this->_writeSupbookInternal(); $part3 .= $this->writeSupbookInternal();
/* TODO: store external SUPBOOK records and XCT and CRN records /* TODO: store external SUPBOOK records and XCT and CRN records
in case of external references for BIFF8 */ in case of external references for BIFF8 */
$part3 .= $this->_writeExternsheetBiff8(); $part3 .= $this->writeExternalsheetBiff8();
$part3 .= $this->_writeAllDefinedNamesBiff8(); $part3 .= $this->writeAllDefinedNamesBiff8();
$part3 .= $this->_writeMsoDrawingGroup(); $part3 .= $this->writeMsoDrawingGroup();
$part3 .= $this->_writeSharedStringsTable(); $part3 .= $this->writeSharedStringsTable();
$part3 .= $this->writeEof(); $part3 .= $this->writeEof();
// Add part 2 of the Workbook globals, the SHEET records // Add part 2 of the Workbook globals, the SHEET records
$this->_calcSheetOffsets(); $this->calcSheetOffsets();
for ($i = 0; $i < $total_worksheets; ++$i) { for ($i = 0; $i < $total_worksheets; ++$i) {
$this->_writeBoundsheet($this->_phpExcel->getSheet($i), $this->_worksheetOffsets[$i]); $this->writeBoundSheet($this->phpExcel->getSheet($i), $this->worksheetOffsets[$i]);
} }
// Add part 3 of the Workbook globals // Add part 3 of the Workbook globals
@ -476,7 +468,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
* *
* @access private * @access private
*/ */
private function _calcSheetOffsets() private function calcSheetOffsets()
{ {
$boundsheet_length = 10; // fixed length for a BOUNDSHEET record $boundsheet_length = 10; // fixed length for a BOUNDSHEET record
@ -484,84 +476,84 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
$offset = $this->_datasize; $offset = $this->_datasize;
// add size of Workbook globals part 2, the length of the SHEET records // add size of Workbook globals part 2, the length of the SHEET records
$total_worksheets = count($this->_phpExcel->getAllSheets()); $total_worksheets = count($this->phpExcel->getAllSheets());
foreach ($this->_phpExcel->getWorksheetIterator() as $sheet) { foreach ($this->phpExcel->getWorksheetIterator() as $sheet) {
$offset += $boundsheet_length + strlen(PHPExcel_Shared_String::UTF8toBIFF8UnicodeShort($sheet->getTitle())); $offset += $boundsheet_length + strlen(PHPExcel_Shared_String::UTF8toBIFF8UnicodeShort($sheet->getTitle()));
} }
// add the sizes of each of the Sheet substreams, respectively // add the sizes of each of the Sheet substreams, respectively
for ($i = 0; $i < $total_worksheets; ++$i) { for ($i = 0; $i < $total_worksheets; ++$i) {
$this->_worksheetOffsets[$i] = $offset; $this->worksheetOffsets[$i] = $offset;
$offset += $this->_worksheetSizes[$i]; $offset += $this->worksheetSizes[$i];
} }
$this->_biffsize = $offset; $this->biffSize = $offset;
} }
/** /**
* Store the Excel FONT records. * Store the Excel FONT records.
*/ */
private function _writeAllFonts() private function writeAllFonts()
{ {
foreach ($this->_fontWriters as $fontWriter) { foreach ($this->fontWriters as $fontWriter) {
$this->_append($fontWriter->writeFont()); $this->append($fontWriter->writeFont());
} }
} }
/** /**
* Store user defined numerical formats i.e. FORMAT records * Store user defined numerical formats i.e. FORMAT records
*/ */
private function _writeAllNumFormats() private function writeAllNumberFormats()
{ {
foreach ($this->_numberFormats as $numberFormatIndex => $numberFormat) { foreach ($this->numberFormats as $numberFormatIndex => $numberFormat) {
$this->_writeNumFormat($numberFormat->getFormatCode(), $numberFormatIndex); $this->writeNumberFormat($numberFormat->getFormatCode(), $numberFormatIndex);
} }
} }
/** /**
* Write all XF records. * Write all XF records.
*/ */
private function _writeAllXfs() private function writeAllXfs()
{ {
foreach ($this->_xfWriters as $xfWriter) { foreach ($this->xfWriters as $xfWriter) {
$this->_append($xfWriter->writeXf()); $this->append($xfWriter->writeXf());
} }
} }
/** /**
* Write all STYLE records. * Write all STYLE records.
*/ */
private function _writeAllStyles() private function writeAllStyles()
{ {
$this->_writeStyle(); $this->writeStyle();
} }
/** /**
* Write the EXTERNCOUNT and EXTERNSHEET records. These are used as indexes for * Write the EXTERNCOUNT and EXTERNSHEET records. These are used as indexes for
* the NAME records. * the NAME records.
*/ */
private function _writeExterns() private function writeExternals()
{ {
$countSheets = $this->_phpExcel->getSheetCount(); $countSheets = $this->phpExcel->getSheetCount();
// Create EXTERNCOUNT with number of worksheets // Create EXTERNCOUNT with number of worksheets
$this->_writeExterncount($countSheets); $this->writeExternalCount($countSheets);
// Create EXTERNSHEET for each worksheet // Create EXTERNSHEET for each worksheet
for ($i = 0; $i < $countSheets; ++$i) { for ($i = 0; $i < $countSheets; ++$i) {
$this->_writeExternsheet($this->_phpExcel->getSheet($i)->getTitle()); $this->writeExternalSheet($this->phpExcel->getSheet($i)->getTitle());
} }
} }
/** /**
* Write the NAME record to define the print area and the repeat rows and cols. * Write the NAME record to define the print area and the repeat rows and cols.
*/ */
private function _writeNames() private function writeNames()
{ {
// total number of sheets // total number of sheets
$total_worksheets = $this->_phpExcel->getSheetCount(); $total_worksheets = $this->phpExcel->getSheetCount();
// Create the print area NAME records // Create the print area NAME records
for ($i = 0; $i < $total_worksheets; ++$i) { for ($i = 0; $i < $total_worksheets; ++$i) {
$sheetSetup = $this->_phpExcel->getSheet($i)->getPageSetup(); $sheetSetup = $this->phpExcel->getSheet($i)->getPageSetup();
// Write a Name record if the print area has been defined // Write a Name record if the print area has been defined
if ($sheetSetup->isPrintAreaSet()) { if ($sheetSetup->isPrintAreaSet()) {
// Print area // Print area
@ -575,7 +567,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
$print_colmin = PHPExcel_Cell::columnIndexFromString($printArea[0][0]) - 1; $print_colmin = PHPExcel_Cell::columnIndexFromString($printArea[0][0]) - 1;
$print_colmax = PHPExcel_Cell::columnIndexFromString($printArea[1][0]) - 1; $print_colmax = PHPExcel_Cell::columnIndexFromString($printArea[1][0]) - 1;
$this->_writeNameShort( $this->writeNameShort(
$i, // sheet index $i, // sheet index
0x06, // NAME type 0x06, // NAME type
$print_rowmin, $print_rowmin,
@ -588,7 +580,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
// Create the print title NAME records // Create the print title NAME records
for ($i = 0; $i < $total_worksheets; ++$i) { for ($i = 0; $i < $total_worksheets; ++$i) {
$sheetSetup = $this->_phpExcel->getSheet($i)->getPageSetup(); $sheetSetup = $this->phpExcel->getSheet($i)->getPageSetup();
// simultaneous repeatColumns repeatRows // simultaneous repeatColumns repeatRows
if ($sheetSetup->isColumnsToRepeatAtLeftSet() && $sheetSetup->isRowsToRepeatAtTopSet()) { if ($sheetSetup->isColumnsToRepeatAtLeftSet() && $sheetSetup->isRowsToRepeatAtTopSet()) {
@ -600,7 +592,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
$rowmin = $repeat[0] - 1; $rowmin = $repeat[0] - 1;
$rowmax = $repeat[1] - 1; $rowmax = $repeat[1] - 1;
$this->_writeNameLong( $this->writeNameLong(
$i, // sheet index $i, // sheet index
0x07, // NAME type 0x07, // NAME type
$rowmin, $rowmin,
@ -631,7 +623,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
$rowmax = 65535; $rowmax = 65535;
} }
$this->_writeNameShort( $this->writeNameShort(
$i, // sheet index $i, // sheet index
0x07, // NAME type 0x07, // NAME type
$rowmin, $rowmin,
@ -647,14 +639,14 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
* Writes all the DEFINEDNAME records (BIFF8). * Writes all the DEFINEDNAME records (BIFF8).
* So far this is only used for repeating rows/columns (print titles) and print areas * So far this is only used for repeating rows/columns (print titles) and print areas
*/ */
private function _writeAllDefinedNamesBiff8() private function writeAllDefinedNamesBiff8()
{ {
$chunk = ''; $chunk = '';
// Named ranges // Named ranges
if (count($this->_phpExcel->getNamedRanges()) > 0) { if (count($this->phpExcel->getNamedRanges()) > 0) {
// Loop named ranges // Loop named ranges
$namedRanges = $this->_phpExcel->getNamedRanges(); $namedRanges = $this->phpExcel->getNamedRanges();
foreach ($namedRanges as $namedRange) { foreach ($namedRanges as $namedRange) {
// Create absolute coordinate // Create absolute coordinate
$range = PHPExcel_Cell::splitRange($namedRange->getRange()); $range = PHPExcel_Cell::splitRange($namedRange->getRange());
@ -668,8 +660,8 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
// parse formula // parse formula
try { try {
$error = $this->_parser->parse($range); $error = $this->parser->parse($range);
$formulaData = $this->_parser->toReversePolish(); $formulaData = $this->parser->toReversePolish();
// make sure tRef3d is of type tRef3dR (0x3A) // make sure tRef3d is of type tRef3dR (0x3A)
if (isset($formulaData{0}) and ($formulaData{0} == "\x7A" or $formulaData{0} == "\x5A")) { if (isset($formulaData{0}) and ($formulaData{0} == "\x7A" or $formulaData{0} == "\x5A")) {
@ -678,12 +670,12 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
if ($namedRange->getLocalOnly()) { if ($namedRange->getLocalOnly()) {
// local scope // local scope
$scope = $this->_phpExcel->getIndex($namedRange->getScope()) + 1; $scope = $this->phpExcel->getIndex($namedRange->getScope()) + 1;
} else { } else {
// global scope // global scope
$scope = 0; $scope = 0;
} }
$chunk .= $this->writeData($this->_writeDefinedNameBiff8($namedRange->getName(), $formulaData, $scope, false)); $chunk .= $this->writeData($this->writeDefinedNameBiff8($namedRange->getName(), $formulaData, $scope, false));
} catch (PHPExcel_Exception $e) { } catch (PHPExcel_Exception $e) {
// do nothing // do nothing
@ -692,11 +684,11 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
} }
// total number of sheets // total number of sheets
$total_worksheets = $this->_phpExcel->getSheetCount(); $total_worksheets = $this->phpExcel->getSheetCount();
// write the print titles (repeating rows, columns), if any // write the print titles (repeating rows, columns), if any
for ($i = 0; $i < $total_worksheets; ++$i) { for ($i = 0; $i < $total_worksheets; ++$i) {
$sheetSetup = $this->_phpExcel->getSheet($i)->getPageSetup(); $sheetSetup = $this->phpExcel->getSheet($i)->getPageSetup();
// simultaneous repeatColumns repeatRows // simultaneous repeatColumns repeatRows
if ($sheetSetup->isColumnsToRepeatAtLeftSet() && $sheetSetup->isRowsToRepeatAtTopSet()) { if ($sheetSetup->isColumnsToRepeatAtLeftSet() && $sheetSetup->isRowsToRepeatAtTopSet()) {
$repeat = $sheetSetup->getColumnsToRepeatAtLeft(); $repeat = $sheetSetup->getColumnsToRepeatAtLeft();
@ -714,7 +706,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
$formulaData .= pack('C', 0x10); // tList $formulaData .= pack('C', 0x10); // tList
// store the DEFINEDNAME record // store the DEFINEDNAME record
$chunk .= $this->writeData($this->_writeDefinedNameBiff8(pack('C', 0x07), $formulaData, $i + 1, true)); $chunk .= $this->writeData($this->writeDefinedNameBiff8(pack('C', 0x07), $formulaData, $i + 1, true));
// (exclusive) either repeatColumns or repeatRows // (exclusive) either repeatColumns or repeatRows
} elseif ($sheetSetup->isColumnsToRepeatAtLeftSet() || $sheetSetup->isRowsToRepeatAtTopSet()) { } elseif ($sheetSetup->isColumnsToRepeatAtLeftSet() || $sheetSetup->isRowsToRepeatAtTopSet()) {
@ -741,13 +733,13 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
$formulaData = pack('Cvvvvv', 0x3B, $i, $rowmin, $rowmax, $colmin, $colmax); $formulaData = pack('Cvvvvv', 0x3B, $i, $rowmin, $rowmax, $colmin, $colmax);
// store the DEFINEDNAME record // store the DEFINEDNAME record
$chunk .= $this->writeData($this->_writeDefinedNameBiff8(pack('C', 0x07), $formulaData, $i + 1, true)); $chunk .= $this->writeData($this->writeDefinedNameBiff8(pack('C', 0x07), $formulaData, $i + 1, true));
} }
} }
// write the print areas, if any // write the print areas, if any
for ($i = 0; $i < $total_worksheets; ++$i) { for ($i = 0; $i < $total_worksheets; ++$i) {
$sheetSetup = $this->_phpExcel->getSheet($i)->getPageSetup(); $sheetSetup = $this->phpExcel->getSheet($i)->getPageSetup();
if ($sheetSetup->isPrintAreaSet()) { if ($sheetSetup->isPrintAreaSet()) {
// Print area, e.g. A3:J6,H1:X20 // Print area, e.g. A3:J6,H1:X20
$printArea = PHPExcel_Cell::splitRange($sheetSetup->getPrintArea()); $printArea = PHPExcel_Cell::splitRange($sheetSetup->getPrintArea());
@ -773,13 +765,13 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
} }
// store the DEFINEDNAME record // store the DEFINEDNAME record
$chunk .= $this->writeData($this->_writeDefinedNameBiff8(pack('C', 0x06), $formulaData, $i + 1, true)); $chunk .= $this->writeData($this->writeDefinedNameBiff8(pack('C', 0x06), $formulaData, $i + 1, true));
} }
} }
// write autofilters, if any // write autofilters, if any
for ($i = 0; $i < $total_worksheets; ++$i) { for ($i = 0; $i < $total_worksheets; ++$i) {
$sheetAutoFilter = $this->_phpExcel->getSheet($i)->getAutoFilter(); $sheetAutoFilter = $this->phpExcel->getSheet($i)->getAutoFilter();
$autoFilterRange = $sheetAutoFilter->getRange(); $autoFilterRange = $sheetAutoFilter->getRange();
if (!empty($autoFilterRange)) { if (!empty($autoFilterRange)) {
$rangeBounds = PHPExcel_Cell::rangeBoundaries($autoFilterRange); $rangeBounds = PHPExcel_Cell::rangeBoundaries($autoFilterRange);
@ -787,7 +779,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
//Autofilter built in name //Autofilter built in name
$name = pack('C', 0x0D); $name = pack('C', 0x0D);
$chunk .= $this->writeData($this->_writeShortNameBiff8($name, $i + 1, $rangeBounds, true)); $chunk .= $this->writeData($this->writeShortNameBiff8($name, $i + 1, $rangeBounds, true));
} }
} }
@ -803,7 +795,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
* @param boolean $isBuiltIn Built-in name? * @param boolean $isBuiltIn Built-in name?
* @return string Complete binary record data * @return string Complete binary record data
*/ */
private function _writeDefinedNameBiff8($name, $formulaData, $sheetIndex = 0, $isBuiltIn = false) private function writeDefinedNameBiff8($name, $formulaData, $sheetIndex = 0, $isBuiltIn = false)
{ {
$record = 0x0018; $record = 0x0018;
@ -838,7 +830,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
* @param boolean $isHidden * @param boolean $isHidden
* @return string Complete binary record data * @return string Complete binary record data
* */ * */
private function _writeShortNameBiff8($name, $sheetIndex = 0, $rangeBounds, $isHidden = false) private function writeShortNameBiff8($name, $sheetIndex = 0, $rangeBounds, $isHidden = false)
{ {
$record = 0x0018; $record = 0x0018;
@ -871,22 +863,22 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
/** /**
* Stores the CODEPAGE biff record. * Stores the CODEPAGE biff record.
*/ */
private function _writeCodepage() private function writeCodepage()
{ {
$record = 0x0042; // Record identifier $record = 0x0042; // Record identifier
$length = 0x0002; // Number of bytes to follow $length = 0x0002; // Number of bytes to follow
$cv = $this->_codepage; // The code page $cv = $this->codepage; // The code page
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
$data = pack('v', $cv); $data = pack('v', $cv);
$this->_append($header . $data); $this->append($header . $data);
} }
/** /**
* Write Excel BIFF WINDOW1 record. * Write Excel BIFF WINDOW1 record.
*/ */
private function _writeWindow1() private function writeWindow1()
{ {
$record = 0x003D; // Record identifier $record = 0x003D; // Record identifier
$length = 0x0012; // Number of bytes to follow $length = 0x0012; // Number of bytes to follow
@ -905,11 +897,11 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
// not supported by PHPExcel, set to 0 // not supported by PHPExcel, set to 0
$itabFirst = 0; // 1st displayed worksheet $itabFirst = 0; // 1st displayed worksheet
$itabCur = $this->_phpExcel->getActiveSheetIndex(); // Active worksheet $itabCur = $this->phpExcel->getActiveSheetIndex(); // Active worksheet
$header = pack("vv", $record, $length); $header = pack("vv", $record, $length);
$data = pack("vvvvvvvvv", $xWn, $yWn, $dxWn, $dyWn, $grbit, $itabCur, $itabFirst, $ctabsel, $wTabRatio); $data = pack("vvvvvvvvv", $xWn, $yWn, $dxWn, $dyWn, $grbit, $itabCur, $itabFirst, $ctabsel, $wTabRatio);
$this->_append($header . $data); $this->append($header . $data);
} }
/** /**
@ -918,7 +910,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
* @param PHPExcel_Worksheet $sheet Worksheet name * @param PHPExcel_Worksheet $sheet Worksheet name
* @param integer $offset Location of worksheet BOF * @param integer $offset Location of worksheet BOF
*/ */
private function _writeBoundsheet($sheet, $offset) private function writeBoundSheet($sheet, $offset)
{ {
$sheetname = $sheet->getTitle(); $sheetname = $sheet->getTitle();
$record = 0x0085; // Record identifier $record = 0x0085; // Record identifier
@ -949,19 +941,19 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
$length = strlen($data); $length = strlen($data);
$header = pack("vv", $record, $length); $header = pack("vv", $record, $length);
$this->_append($header . $data); $this->append($header . $data);
} }
/** /**
* Write Internal SUPBOOK record * Write Internal SUPBOOK record
*/ */
private function _writeSupbookInternal() private function writeSupbookInternal()
{ {
$record = 0x01AE; // Record identifier $record = 0x01AE; // Record identifier
$length = 0x0004; // Bytes to follow $length = 0x0004; // Bytes to follow
$header = pack("vv", $record, $length); $header = pack("vv", $record, $length);
$data = pack("vv", $this->_phpExcel->getSheetCount(), 0x0401); $data = pack("vv", $this->phpExcel->getSheetCount(), 0x0401);
return $this->writeData($header . $data); return $this->writeData($header . $data);
} }
@ -970,17 +962,17 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
* formulas. * formulas.
* *
*/ */
private function _writeExternsheetBiff8() private function writeExternalsheetBiff8()
{ {
$total_references = count($this->_parser->_references); $totalReferences = count($this->parser->references);
$record = 0x0017; // Record identifier $record = 0x0017; // Record identifier
$length = 2 + 6 * $total_references; // Number of bytes to follow $length = 2 + 6 * $totalReferences; // Number of bytes to follow
$supbook_index = 0; // FIXME: only using internal SUPBOOK record $supbook_index = 0; // FIXME: only using internal SUPBOOK record
$header = pack("vv", $record, $length); $header = pack("vv", $record, $length);
$data = pack('v', $total_references); $data = pack('v', $totalReferences);
for ($i = 0; $i < $total_references; ++$i) { for ($i = 0; $i < $totalReferences; ++$i) {
$data .= $this->_parser->_references[$i]; $data .= $this->parser->references[$i];
} }
return $this->writeData($header . $data); return $this->writeData($header . $data);
} }
@ -988,7 +980,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
/** /**
* Write Excel BIFF STYLE records. * Write Excel BIFF STYLE records.
*/ */
private function _writeStyle() private function writeStyle()
{ {
$record = 0x0293; // Record identifier $record = 0x0293; // Record identifier
$length = 0x0004; // Bytes to follow $length = 0x0004; // Bytes to follow
@ -999,7 +991,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
$header = pack("vv", $record, $length); $header = pack("vv", $record, $length);
$data = pack("vCC", $ixfe, $BuiltIn, $iLevel); $data = pack("vCC", $ixfe, $BuiltIn, $iLevel);
$this->_append($header . $data); $this->append($header . $data);
} }
/** /**
@ -1008,7 +1000,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
* @param string $format Custom format string * @param string $format Custom format string
* @param integer $ifmt Format index code * @param integer $ifmt Format index code
*/ */
private function _writeNumFormat($format, $ifmt) private function writeNumberFormat($format, $ifmt)
{ {
$record = 0x041E; // Record identifier $record = 0x041E; // Record identifier
@ -1018,23 +1010,24 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
$header = pack("vv", $record, $length); $header = pack("vv", $record, $length);
$data = pack("v", $ifmt) . $numberFormatString; $data = pack("v", $ifmt) . $numberFormatString;
$this->_append($header . $data); $this->append($header . $data);
} }
/** /**
* Write DATEMODE record to indicate the date system in use (1904 or 1900). * Write DATEMODE record to indicate the date system in use (1904 or 1900).
*/ */
private function _writeDatemode() private function writeDateMode()
{ {
$record = 0x0022; // Record identifier $record = 0x0022; // Record identifier
$length = 0x0002; // Bytes to follow $length = 0x0002; // Bytes to follow
$f1904 = (PHPExcel_Shared_Date::getExcelCalendar() == PHPExcel_Shared_Date::CALENDAR_MAC_1904) ? $f1904 = (PHPExcel_Shared_Date::getExcelCalendar() == PHPExcel_Shared_Date::CALENDAR_MAC_1904)
1 : 0; // Flag for 1904 date system ? 1
: 0; // Flag for 1904 date system
$header = pack("vv", $record, $length); $header = pack("vv", $record, $length);
$data = pack("v", $f1904); $data = pack("v", $f1904);
$this->_append($header . $data); $this->append($header . $data);
} }
/** /**
@ -1049,14 +1042,14 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
* *
* @param integer $cxals Number of external references * @param integer $cxals Number of external references
*/ */
private function _writeExterncount($cxals) private function writeExternalCount($cxals)
{ {
$record = 0x0016; // Record identifier $record = 0x0016; // Record identifier
$length = 0x0002; // Number of bytes to follow $length = 0x0002; // Number of bytes to follow
$header = pack("vv", $record, $length); $header = pack("vv", $record, $length);
$data = pack("v", $cxals); $data = pack("v", $cxals);
$this->_append($header . $data); $this->append($header . $data);
} }
/** /**
@ -1068,7 +1061,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
* *
* @param string $sheetname Worksheet name * @param string $sheetname Worksheet name
*/ */
private function _writeExternsheet($sheetname) private function writeExternalSheet($sheetname)
{ {
$record = 0x0017; // Record identifier $record = 0x0017; // Record identifier
$length = 0x02 + strlen($sheetname); // Number of bytes to follow $length = 0x02 + strlen($sheetname); // Number of bytes to follow
@ -1078,7 +1071,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
$header = pack("vv", $record, $length); $header = pack("vv", $record, $length);
$data = pack("CC", $cch, $rgch); $data = pack("CC", $cch, $rgch);
$this->_append($header . $data . $sheetname); $this->append($header . $data . $sheetname);
} }
/** /**
@ -1092,7 +1085,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
* @param integer $colmin Start colum * @param integer $colmin Start colum
* @param integer $colmax End column * @param integer $colmax End column
*/ */
private function _writeNameShort($index, $type, $rowmin, $rowmax, $colmin, $colmax) private function writeNameShort($index, $type, $rowmin, $rowmax, $colmin, $colmax)
{ {
$record = 0x0018; // Record identifier $record = 0x0018; // Record identifier
$length = 0x0024; // Number of bytes to follow $length = 0x0024; // Number of bytes to follow
@ -1110,7 +1103,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
$rgch = $type; // Built-in name type $rgch = $type; // Built-in name type
$unknown03 = 0x3b; $unknown03 = 0x3b;
$unknown04 = 0xffff-$index; $unknown04 = 0xffff - $index;
$unknown05 = 0x0000; $unknown05 = 0x0000;
$unknown06 = 0x0000; $unknown06 = 0x0000;
$unknown07 = 0x1087; $unknown07 = 0x1087;
@ -1140,13 +1133,13 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
$data .= pack("v", $rowmax); $data .= pack("v", $rowmax);
$data .= pack("C", $colmin); $data .= pack("C", $colmin);
$data .= pack("C", $colmax); $data .= pack("C", $colmax);
$this->_append($header . $data); $this->append($header . $data);
} }
/** /**
* Store the NAME record in the long format that is used for storing the repeat * Store the NAME record in the long format that is used for storing the repeat
* rows and columns when both are specified. This shares a lot of code with * rows and columns when both are specified. This shares a lot of code with
* _writeNameShort() but we use a separate method to keep the code clean. * writeNameShort() but we use a separate method to keep the code clean.
* Code abstraction for reuse can be carried too far, and I should know. ;-) * Code abstraction for reuse can be carried too far, and I should know. ;-)
* *
* @param integer $index Sheet index * @param integer $index Sheet index
@ -1156,7 +1149,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
* @param integer $colmin Start colum * @param integer $colmin Start colum
* @param integer $colmax End column * @param integer $colmax End column
*/ */
private function _writeNameLong($index, $type, $rowmin, $rowmax, $colmin, $colmax) private function writeNameLong($index, $type, $rowmin, $rowmax, $colmin, $colmax)
{ {
$record = 0x0018; // Record identifier $record = 0x0018; // Record identifier
$length = 0x003d; // Number of bytes to follow $length = 0x003d; // Number of bytes to follow
@ -1223,7 +1216,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
$data .= pack("C", 0xff); $data .= pack("C", 0xff);
// End of data // End of data
$data .= pack("C", 0x10); $data .= pack("C", 0x10);
$this->_append($header . $data); $this->append($header . $data);
} }
/** /**
@ -1231,15 +1224,15 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
* *
* @return string * @return string
*/ */
private function _writeCountry() private function writeCountry()
{ {
$record = 0x008C; // Record identifier $record = 0x008C; // Record identifier
$length = 4; // Number of bytes to follow $length = 4; // Number of bytes to follow
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
/* using the same country code always for simplicity */ /* using the same country code always for simplicity */
$data = pack('vv', $this->_country_code, $this->_country_code); $data = pack('vv', $this->countryCode, $this->countryCode);
//$this->_append($header . $data); //$this->append($header . $data);
return $this->writeData($header . $data); return $this->writeData($header . $data);
} }
@ -1248,7 +1241,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
* *
* @return string * @return string
*/ */
private function _writeRecalcId() private function writeRecalcId()
{ {
$record = 0x01C1; // Record identifier $record = 0x01C1; // Record identifier
$length = 8; // Number of bytes to follow $length = 8; // Number of bytes to follow
@ -1264,9 +1257,9 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
/** /**
* Stores the PALETTE biff record. * Stores the PALETTE biff record.
*/ */
private function _writePalette() private function writePalette()
{ {
$aref = $this->_palette; $aref = $this->palette;
$record = 0x0092; // Record identifier $record = 0x0092; // Record identifier
$length = 2 + 4 * count($aref); // Number of bytes to follow $length = 2 + 4 * count($aref); // Number of bytes to follow
@ -1281,7 +1274,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
} }
$header = pack("vvv", $record, $length, $ccv); $header = pack("vvv", $record, $length, $ccv);
$this->_append($header . $data); $this->append($header . $data);
} }
/** /**
@ -1298,7 +1291,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
* *
* @return string Binary data * @return string Binary data
*/ */
private function _writeSharedStringsTable() private function writeSharedStringsTable()
{ {
// maximum size of record data (excluding record header) // maximum size of record data (excluding record header)
$continue_limit = 8224; $continue_limit = 8224;
@ -1307,10 +1300,10 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
$recordDatas = array(); $recordDatas = array();
// start SST record data block with total number of strings, total number of unique strings // start SST record data block with total number of strings, total number of unique strings
$recordData = pack("VV", $this->_str_total, $this->_str_unique); $recordData = pack("VV", $this->strTotal, $this->strUnique);
// loop through all (unique) strings in shared strings table // loop through all (unique) strings in shared strings table
foreach (array_keys($this->_str_table) as $string) { foreach (array_keys($this->strTable) as $string) {
// here $string is a BIFF8 encoded string // here $string is a BIFF8 encoded string
// length = character count // length = character count
@ -1412,11 +1405,11 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
/** /**
* Writes the MSODRAWINGGROUP record if needed. Possibly split using CONTINUE records. * Writes the MSODRAWINGGROUP record if needed. Possibly split using CONTINUE records.
*/ */
private function _writeMsoDrawingGroup() private function writeMsoDrawingGroup()
{ {
// write the Escher stream if necessary // write the Escher stream if necessary
if (isset($this->_escher)) { if (isset($this->escher)) {
$writer = new PHPExcel_Writer_Excel5_Escher($this->_escher); $writer = new PHPExcel_Writer_Excel5_Escher($this->escher);
$data = $writer->close(); $data = $writer->close();
$record = 0x00EB; $record = 0x00EB;
@ -1436,7 +1429,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
*/ */
public function getEscher() public function getEscher()
{ {
return $this->_escher; return $this->escher;
} }
/** /**
@ -1446,6 +1439,6 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
*/ */
public function setEscher(PHPExcel_Shared_Escher $pValue = null) public function setEscher(PHPExcel_Shared_Escher $pValue = null)
{ {
$this->_escher = $pValue; $this->escher = $pValue;
} }
} }

View File

@ -273,7 +273,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$num_sheets = $_phpSheet->getParent()->getSheetCount(); $num_sheets = $_phpSheet->getParent()->getSheetCount();
// Write BOF record // Write BOF record
$this->_storeBof(0x0010); $this->storeBof(0x0010);
// Write PRINTHEADERS // Write PRINTHEADERS
$this->_writePrintHeaders(); $this->_writePrintHeaders();
@ -347,16 +347,16 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$this->_writeVcenter(); $this->_writeVcenter();
// Write left margin // Write left margin
$this->_writeMarginLeft(); $this->writeMarginLeft();
// Write right margin // Write right margin
$this->_writeMarginRight(); $this->writeMarginRight();
// Write top margin // Write top margin
$this->_writeMarginTop(); $this->writeMarginTop();
// Write bottom margin // Write bottom margin
$this->_writeMarginBottom(); $this->writeMarginBottom();
// Write page setup // Write page setup
$this->_writeSetup(); $this->_writeSetup();
@ -458,7 +458,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
break; break;
case PHPExcel_Cell_DataType::TYPE_ERROR: case PHPExcel_Cell_DataType::TYPE_ERROR:
$this->writeBoolErr($row, $column, self::_mapErrorCode($cVal), 1, $xfIndex); $this->writeBoolErr($row, $column, self::mapErrorCode($cVal), 1, $xfIndex);
break; break;
} }
@ -466,13 +466,13 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
} }
// Append // Append
$this->_writeMsoDrawing(); $this->writeMsoDrawing();
// Write WINDOW2 record // Write WINDOW2 record
$this->writeWindow2(); $this->writeWindow2();
// Write PLV record // Write PLV record
$this->_writePageLayoutView(); $this->writePageLayoutView();
// Write ZOOM record // Write ZOOM record
$this->_writeZoom(); $this->_writeZoom();
@ -508,7 +508,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$this->writeUrl($row - 1, PHPExcel_Cell::columnIndexFromString($column) - 1, $url); $this->writeUrl($row - 1, PHPExcel_Cell::columnIndexFromString($column) - 1, $url);
} }
$this->_writeDataValidity(); $this->writeDataValidity();
$this->_writeSheetLayout(); $this->_writeSheetLayout();
// Write SHEETPROTECTION record // Write SHEETPROTECTION record
@ -536,7 +536,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
} }
} }
$this->_storeEof(); $this->storeEof();
} }
/** /**
@ -646,7 +646,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$xl_double = strrev($xl_double); $xl_double = strrev($xl_double);
} }
$this->_append($header.$data.$xl_double); $this->append($header.$data.$xl_double);
return(0); return(0);
} }
@ -686,7 +686,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
$data = pack('vvvV', $row, $col, $xfIndex, $this->_str_table[$str]); $data = pack('vvvV', $row, $col, $xfIndex, $this->_str_table[$str]);
$this->_append($header.$data); $this->append($header.$data);
} }
/** /**
@ -721,7 +721,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$header = pack("vv", $record, $length); $header = pack("vv", $record, $length);
$data = pack("vvvv", $row, $col, $xfIndex, $strlen); $data = pack("vvvv", $row, $col, $xfIndex, $strlen);
$this->_append($header . $data . $str); $this->append($header . $data . $str);
return($str_error); return($str_error);
} }
@ -755,7 +755,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
$data = pack('vvvV', $row, $col, $xfIndex, $this->_str_table[$str]); $data = pack('vvvV', $row, $col, $xfIndex, $this->_str_table[$str]);
$this->_append($header.$data); $this->append($header.$data);
} }
/** /**
@ -776,14 +776,14 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$length = 0x0006 + min($note_length, 2048); $length = 0x0006 + min($note_length, 2048);
$header = pack("vv", $record, $length); $header = pack("vv", $record, $length);
$data = pack("vvv", $row, $col, $note_length); $data = pack("vvv", $row, $col, $note_length);
$this->_append($header . $data . substr($note, 0, 2048)); $this->append($header . $data . substr($note, 0, 2048));
for ($i = $max_length; $i < $note_length; $i += $max_length) { for ($i = $max_length; $i < $note_length; $i += $max_length) {
$chunk = substr($note, $i, $max_length); $chunk = substr($note, $i, $max_length);
$length = 0x0006 + strlen($chunk); $length = 0x0006 + strlen($chunk);
$header = pack("vv", $record, $length); $header = pack("vv", $record, $length);
$data = pack("vvv", -1, 0, strlen($chunk)); $data = pack("vvv", -1, 0, strlen($chunk));
$this->_append($header.$data.$chunk); $this->append($header.$data.$chunk);
} }
return(0); return(0);
} }
@ -811,7 +811,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$header = pack("vv", $record, $length); $header = pack("vv", $record, $length);
$data = pack("vvv", $row, $col, $xfIndex); $data = pack("vvv", $row, $col, $xfIndex);
$this->_append($header . $data); $this->append($header . $data);
return 0; return 0;
} }
@ -831,7 +831,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$header = pack("vv", $record, $length); $header = pack("vv", $record, $length);
$data = pack("vvvCC", $row, $col, $xfIndex, $value, $isError); $data = pack("vvvCC", $row, $col, $xfIndex, $value, $isError);
$this->_append($header . $data); $this->append($header . $data);
return 0; return 0;
} }
@ -871,7 +871,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
} elseif (is_string($calculatedValue)) { } elseif (is_string($calculatedValue)) {
if (array_key_exists($calculatedValue, PHPExcel_Cell_DataType::getErrorCodes())) { if (array_key_exists($calculatedValue, PHPExcel_Cell_DataType::getErrorCodes())) {
// Error value // Error value
$num = pack('CCCvCv', 0x02, 0x00, self::_mapErrorCode($calculatedValue), 0x00, 0x00, 0xFFFF); $num = pack('CCCvCv', 0x02, 0x00, self::mapErrorCode($calculatedValue), 0x00, 0x00, 0xFFFF);
} elseif ($calculatedValue === '') { } elseif ($calculatedValue === '') {
// Empty string (and BIFF8) // Empty string (and BIFF8)
$num = pack('CCCvCv', 0x03, 0x00, 0x00, 0x00, 0x00, 0xFFFF); $num = pack('CCCvCv', 0x03, 0x00, 0x00, 0x00, 0x00, 0xFFFF);
@ -913,7 +913,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$data = pack("vvv", $row, $col, $xfIndex) $data = pack("vvv", $row, $col, $xfIndex)
. $num . $num
. pack("vVv", $grbit, $unknown, $formlen); . pack("vVv", $grbit, $unknown, $formlen);
$this->_append($header . $data . $formula); $this->append($header . $data . $formula);
// Append also a STRING record if necessary // Append also a STRING record if necessary
if ($stringValue !== null) { if ($stringValue !== null) {
@ -941,7 +941,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$length = strlen($data); $length = strlen($data);
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
$this->_append($header . $data); $this->append($header . $data);
} }
/** /**
@ -1038,7 +1038,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$data = pack("vvvv", $row1, $row2, $col1, $col2); $data = pack("vvvv", $row1, $row2, $col1, $col2);
// Write the packed data // Write the packed data
$this->_append($header . $data . $this->append($header . $data .
$unknown1 . $options . $unknown1 . $options .
$unknown2 . $url_len . $url); $unknown2 . $url_len . $url);
return 0; return 0;
@ -1087,7 +1087,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$data = pack("vvvv", $row1, $row2, $col1, $col2); $data = pack("vvvv", $row1, $row2, $col1, $col2);
// Write the packed data // Write the packed data
$this->_append($header . $data . $this->append($header . $data .
$unknown1 . $options . $unknown1 . $options .
$url_len . $url); $url_len . $url);
return 0; return 0;
@ -1190,7 +1190,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$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 0; return 0;
} }
@ -1247,7 +1247,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$header = pack("vv", $record, $length); $header = pack("vv", $record, $length);
$data = pack("vvvvvvvv", $row, $colMic, $colMac, $miyRw, $irwMac, $reserved, $grbit, $ixfe); $data = pack("vvvvvvvv", $row, $colMic, $colMac, $miyRw, $irwMac, $reserved, $grbit, $ixfe);
$this->_append($header.$data); $this->append($header.$data);
} }
/** /**
@ -1261,7 +1261,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$data = pack('VVvvv', $this->firstRowIndex, $this->lastRowIndex + 1, $this->firstColumnIndex, $this->lastColumnIndex + 1, 0x0000); // reserved $data = pack('VVvvv', $this->firstRowIndex, $this->lastRowIndex + 1, $this->firstColumnIndex, $this->lastColumnIndex + 1, 0x0000); // reserved
$header = pack("vv", $record, $length); $header = pack("vv", $record, $length);
$this->_append($header.$data); $this->append($header.$data);
} }
/** /**
@ -1315,7 +1315,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$data .= pack("vvvvV", $rgbHdr, 0x0000, $zoom_factor_page_break, $zoom_factor_normal, 0x00000000); $data .= pack("vvvvV", $rgbHdr, 0x0000, $zoom_factor_page_break, $zoom_factor_normal, 0x00000000);
$this->_append($header.$data); $this->append($header.$data);
} }
/** /**
@ -1337,7 +1337,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$header = pack("vv", $record, $length); $header = pack("vv", $record, $length);
$data = pack("vv", 1, $defaultRowHeight); $data = pack("vv", 1, $defaultRowHeight);
$this->_append($header . $data); $this->append($header . $data);
} }
/** /**
@ -1352,7 +1352,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$header = pack("vv", $record, $length); $header = pack("vv", $record, $length);
$data = pack("v", $defaultColWidth); $data = pack("v", $defaultColWidth);
$this->_append($header . $data); $this->append($header . $data);
} }
/** /**
@ -1410,7 +1410,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$header = pack("vv", $record, $length); $header = pack("vv", $record, $length);
$data = pack("vvvvvv", $colFirst, $colLast, $coldx, $ixfe, $grbit, $reserved); $data = pack("vvvvvv", $colFirst, $colLast, $coldx, $ixfe, $grbit, $reserved);
$this->_append($header.$data); $this->append($header.$data);
} }
/** /**
@ -1471,7 +1471,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$header = pack("vv", $record, $length); $header = pack("vv", $record, $length);
$data = pack("CvvvvvvCC", $pnn, $rwAct, $colAct, $irefAct, $cref, $rwFirst, $rwLast, $colFirst, $colLast); $data = pack("CvvvvvvCC", $pnn, $rwAct, $colAct, $irefAct, $cref, $rwFirst, $rwLast, $colFirst, $colLast);
$this->_append($header . $data); $this->append($header . $data);
} }
/** /**
@ -1519,7 +1519,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$recordData = pack('v', $j) . $recordData; $recordData = pack('v', $j) . $recordData;
$length = strlen($recordData); $length = strlen($recordData);
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
$this->_append($header . $recordData); $this->append($header . $recordData);
// initialize for next record, if any // initialize for next record, if any
$recordData = ''; $recordData = '';
@ -1552,7 +1552,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$record = 0x0862; // Record identifier $record = 0x0862; // Record identifier
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
$this->_append($header . $recordData); $this->append($header . $recordData);
} }
/** /**
@ -1596,7 +1596,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$length = strlen($recordData); $length = strlen($recordData);
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
$this->_append($header . $recordData); $this->append($header . $recordData);
} }
/** /**
@ -1643,7 +1643,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$record = 0x0868; // Record identifier $record = 0x0868; // Record identifier
$header = pack("vv", $record, $length); $header = pack("vv", $record, $length);
$this->_append($header . $recordData); $this->append($header . $recordData);
} }
} }
@ -1666,7 +1666,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$header = pack("vv", $record, $length); $header = pack("vv", $record, $length);
$data = pack("v", $count); $data = pack("v", $count);
$this->_append($header . $data); $this->append($header . $data);
} }
/** /**
@ -1697,7 +1697,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$header = pack("vv", $record, $length); $header = pack("vv", $record, $length);
$data = pack("CC", $cch, $rgch); $data = pack("CC", $cch, $rgch);
$this->_append($header . $data . $sheetname); $this->append($header . $data . $sheetname);
} }
/** /**
@ -1780,7 +1780,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$header = pack("vv", $record, $length); $header = pack("vv", $record, $length);
$data = pack("vvvvv", $x, $y, $rwTop, $colLeft, $pnnAct); $data = pack("vvvvv", $x, $y, $rwTop, $colLeft, $pnnAct);
$this->_append($header . $data); $this->append($header . $data);
} }
/** /**
@ -1841,7 +1841,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$data1 = pack("vvvvvvvv", $iPaperSize, $iScale, $iPageStart, $iFitWidth, $iFitHeight, $grbit, $iRes, $iVRes); $data1 = pack("vvvvvvvv", $iPaperSize, $iScale, $iPageStart, $iFitWidth, $iFitHeight, $grbit, $iRes, $iVRes);
$data2 = $numHdr.$numFtr; $data2 = $numHdr.$numFtr;
$data3 = pack("v", $iCopies); $data3 = pack("v", $iCopies);
$this->_append($header . $data1 . $data2 . $data3); $this->append($header . $data1 . $data2 . $data3);
} }
/** /**
@ -1865,7 +1865,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$header = pack("vv", $record, $length); $header = pack("vv", $record, $length);
$this->_append($header . $recordData); $this->append($header . $recordData);
} }
/** /**
@ -1889,7 +1889,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$header = pack("vv", $record, $length); $header = pack("vv", $record, $length);
$this->_append($header . $recordData); $this->append($header . $recordData);
} }
/** /**
@ -1907,7 +1907,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$header = pack("vv", $record, $length); $header = pack("vv", $record, $length);
$data = pack("v", $fHCenter); $data = pack("v", $fHCenter);
$this->_append($header.$data); $this->append($header.$data);
} }
/** /**
@ -1922,13 +1922,13 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$header = pack("vv", $record, $length); $header = pack("vv", $record, $length);
$data = pack("v", $fVCenter); $data = pack("v", $fVCenter);
$this->_append($header . $data); $this->append($header . $data);
} }
/** /**
* Store the LEFTMARGIN BIFF record. * Store the LEFTMARGIN BIFF record.
*/ */
private function _writeMarginLeft() private function writeMarginLeft()
{ {
$record = 0x0026; // Record identifier $record = 0x0026; // Record identifier
$length = 0x0008; // Bytes to follow $length = 0x0008; // Bytes to follow
@ -1941,13 +1941,13 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$data = strrev($data); $data = strrev($data);
} }
$this->_append($header . $data); $this->append($header . $data);
} }
/** /**
* Store the RIGHTMARGIN BIFF record. * Store the RIGHTMARGIN BIFF record.
*/ */
private function _writeMarginRight() private function writeMarginRight()
{ {
$record = 0x0027; // Record identifier $record = 0x0027; // Record identifier
$length = 0x0008; // Bytes to follow $length = 0x0008; // Bytes to follow
@ -1960,13 +1960,13 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$data = strrev($data); $data = strrev($data);
} }
$this->_append($header . $data); $this->append($header . $data);
} }
/** /**
* Store the TOPMARGIN BIFF record. * Store the TOPMARGIN BIFF record.
*/ */
private function _writeMarginTop() private function writeMarginTop()
{ {
$record = 0x0028; // Record identifier $record = 0x0028; // Record identifier
$length = 0x0008; // Bytes to follow $length = 0x0008; // Bytes to follow
@ -1979,13 +1979,13 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$data = strrev($data); $data = strrev($data);
} }
$this->_append($header . $data); $this->append($header . $data);
} }
/** /**
* Store the BOTTOMMARGIN BIFF record. * Store the BOTTOMMARGIN BIFF record.
*/ */
private function _writeMarginBottom() private function writeMarginBottom()
{ {
$record = 0x0029; // Record identifier $record = 0x0029; // Record identifier
$length = 0x0008; // Bytes to follow $length = 0x0008; // Bytes to follow
@ -1998,7 +1998,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$data = strrev($data); $data = strrev($data);
} }
$this->_append($header . $data); $this->append($header . $data);
} }
/** /**
@ -2013,7 +2013,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$header = pack("vv", $record, $length); $header = pack("vv", $record, $length);
$data = pack("v", $fPrintRwCol); $data = pack("v", $fPrintRwCol);
$this->_append($header . $data); $this->append($header . $data);
} }
/** /**
@ -2029,7 +2029,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$header = pack("vv", $record, $length); $header = pack("vv", $record, $length);
$data = pack("v", $fPrintGrid); $data = pack("v", $fPrintGrid);
$this->_append($header . $data); $this->append($header . $data);
} }
/** /**
@ -2045,7 +2045,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$header = pack("vv", $record, $length); $header = pack("vv", $record, $length);
$data = pack("v", $fGridSet); $data = pack("v", $fGridSet);
$this->_append($header . $data); $this->append($header . $data);
} }
/** /**
@ -2061,7 +2061,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$header = pack("vv", $record, $length); $header = pack("vv", $record, $length);
$data = pack("v", $iNumFilters); $data = pack("v", $iNumFilters);
$this->_append($header . $data); $this->append($header . $data);
} }
/** /**
@ -2108,7 +2108,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$header = pack("vv", $record, $length); $header = pack("vv", $record, $length);
$data = pack("vvvv", $dxRwGut, $dxColGut, $maxRowOutlineLevel, $col_level); $data = pack("vvvv", $dxRwGut, $dxColGut, $maxRowOutlineLevel, $col_level);
$this->_append($header.$data); $this->append($header.$data);
} }
/** /**
@ -2144,7 +2144,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$header = pack("vv", $record, $length); $header = pack("vv", $record, $length);
$data = pack("v", $grbit); $data = pack("v", $grbit);
$this->_append($header . $data); $this->append($header . $data);
} }
/** /**
@ -2197,7 +2197,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$data .= pack("vvv", $hbreak, 0x0000, 0x00ff); $data .= pack("vvv", $hbreak, 0x0000, 0x00ff);
} }
$this->_append($header . $data); $this->append($header . $data);
} }
// vertical page breaks // vertical page breaks
@ -2224,7 +2224,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$data .= pack("vvv", $vbreak, 0x0000, 0xffff); $data .= pack("vvv", $vbreak, 0x0000, 0xffff);
} }
$this->_append($header . $data); $this->append($header . $data);
} }
} }
@ -2246,7 +2246,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$header = pack("vv", $record, $length); $header = pack("vv", $record, $length);
$data = pack("v", $fLock); $data = pack("v", $fLock);
$this->_append($header.$data); $this->append($header.$data);
} }
/** /**
@ -2270,7 +2270,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
$data = pack('v', 1); $data = pack('v', 1);
$this->_append($header . $data); $this->append($header . $data);
} }
/** /**
@ -2294,7 +2294,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
$data = pack('v', 1); $data = pack('v', 1);
$this->_append($header . $data); $this->append($header . $data);
} }
/** /**
@ -2315,7 +2315,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$header = pack("vv", $record, $length); $header = pack("vv", $record, $length);
$data = pack("v", $wPassword); $data = pack("v", $wPassword);
$this->_append($header . $data); $this->append($header . $data);
} }
/** /**
@ -2350,7 +2350,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$lcb = $size; $lcb = $size;
$header = pack("vvvvV", $record, $length, $cf, $env, $lcb); $header = pack("vvvvV", $record, $length, $cf, $env, $lcb);
$this->_append($header.$data); $this->append($header.$data);
} }
/** /**
@ -2534,7 +2534,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$data .= pack("v", $grbit2); $data .= pack("v", $grbit2);
$data .= pack("V", $Reserved5); $data .= pack("V", $Reserved5);
$this->_append($header . $data); $this->append($header . $data);
} }
/** /**
@ -2669,7 +2669,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$header = pack("vv", $record, $length); $header = pack("vv", $record, $length);
$data = pack("vv", $this->_phpSheet->getSheetView()->getZoomScale(), 100); $data = pack("vv", $this->_phpSheet->getSheetView()->getZoomScale(), 100);
$this->_append($header . $data); $this->append($header . $data);
} }
/** /**
@ -2695,7 +2695,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
/** /**
* Write MSODRAWING record * Write MSODRAWING record
*/ */
private function _writeMsoDrawing() private function writeMsoDrawing()
{ {
// write the Escher stream if necessary // write the Escher stream if necessary
if (isset($this->escher)) { if (isset($this->escher)) {
@ -2718,7 +2718,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$length = strlen($dataChunk); $length = strlen($dataChunk);
$header = pack("vv", $record, $length); $header = pack("vv", $record, $length);
$this->_append($header . $dataChunk); $this->append($header . $dataChunk);
// OBJ record // OBJ record
$record = 0x005D; // record identifier $record = 0x005D; // record identifier
@ -2772,7 +2772,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$length = strlen($objData); $length = strlen($objData);
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
$this->_append($header . $objData); $this->append($header . $objData);
} }
} }
} }
@ -2780,7 +2780,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
/** /**
* Store the DATAVALIDATIONS and DATAVALIDATION records. * Store the DATAVALIDATIONS and DATAVALIDATION records.
*/ */
private function _writeDataValidity() private function writeDataValidity()
{ {
// Datavalidation collection // Datavalidation collection
$dataValidationCollection = $this->_phpSheet->getDataValidationCollection(); $dataValidationCollection = $this->_phpSheet->getDataValidationCollection();
@ -2798,7 +2798,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
$data = pack('vVVVV', $grbit, $horPos, $verPos, $objId, count($dataValidationCollection)); $data = pack('vVVVV', $grbit, $horPos, $verPos, $objId, count($dataValidationCollection));
$this->_append($header.$data); $this->append($header.$data);
// DATAVALIDATION records // DATAVALIDATION records
$record = 0x01BE; // Record identifier $record = 0x01BE; // Record identifier
@ -2963,7 +2963,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$length = strlen($data); $length = strlen($data);
$header = pack("vv", $record, $length); $header = pack("vv", $record, $length);
$this->_append($header . $data); $this->append($header . $data);
} }
} }
} }
@ -2974,7 +2974,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
* @param string $errorCode * @param string $errorCode
* @return int * @return int
*/ */
private static function _mapErrorCode($errorCode) private static function mapErrorCode($errorCode)
{ {
switch ($errorCode) { switch ($errorCode) {
case '#NULL!': case '#NULL!':
@ -2999,7 +2999,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
/** /**
* Write PLV Record * Write PLV Record
*/ */
private function _writePageLayoutView() private function writePageLayoutView()
{ {
$record = 0x088B; // Record identifier $record = 0x088B; // Record identifier
$length = 0x0010; // Bytes to follow $length = 0x0010; // Bytes to follow
@ -3024,7 +3024,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$header = pack("vv", $record, $length); $header = pack("vv", $record, $length);
$data = pack("vvVVvv", $rt, $grbitFrt, 0x00000000, 0x00000000, $wScalvePLV, $grbit); $data = pack("vvVVvv", $rt, $grbitFrt, 0x00000000, 0x00000000, $wScalvePLV, $grbit);
$this->_append($header . $data); $this->append($header . $data);
} }
/** /**
@ -4200,7 +4200,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$data .= $operand2; $data .= $operand2;
} }
$header = pack('vv', $record, strlen($data)); $header = pack('vv', $record, strlen($data));
$this->_append($header . $data); $this->append($header . $data);
} }
/** /**
@ -4251,6 +4251,6 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$data .= $cellRange; $data .= $cellRange;
$data .= pack('v', 0x0001); $data .= pack('v', 0x0001);
$data .= $cellRange; $data .= $cellRange;
$this->_append($header . $data); $this->append($header . $data);
} }
} }

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_Writer_Excel5_Xf
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -59,15 +60,6 @@
// * License along with this library; if not, write to the Free Software // * License along with this library; if not, write to the Free Software
// * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// */ // */
/**
* PHPExcel_Writer_Excel5_Xf
*
* @category PHPExcel
* @package PHPExcel_Writer_Excel5
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Writer_Excel5_Xf class PHPExcel_Writer_Excel5_Xf
{ {
/** /**