PSR-2 : Fixes

This commit is contained in:
Progi1984 2015-05-12 17:57:29 +02:00
parent 5bb747f8cc
commit f37630e938
8 changed files with 655 additions and 696 deletions

View File

@ -48,7 +48,8 @@ abstract class PHPExcel_Writer_Excel2007_WriterPart
* @param PHPExcel_Writer_IWriter $pWriter * @param PHPExcel_Writer_IWriter $pWriter
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
public function setParentWriter(PHPExcel_Writer_IWriter $pWriter = null) { public function setParentWriter(PHPExcel_Writer_IWriter $pWriter = null)
{
$this->_parentWriter = $pWriter; $this->_parentWriter = $pWriter;
} }
@ -58,7 +59,8 @@ abstract class PHPExcel_Writer_Excel2007_WriterPart
* @return PHPExcel_Writer_IWriter * @return PHPExcel_Writer_IWriter
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
public function getParentWriter() { public function getParentWriter()
{
if (!is_null($this->_parentWriter)) { if (!is_null($this->_parentWriter)) {
return $this->_parentWriter; return $this->_parentWriter;
} else { } else {
@ -72,10 +74,10 @@ abstract class PHPExcel_Writer_Excel2007_WriterPart
* @param PHPExcel_Writer_IWriter $pWriter * @param PHPExcel_Writer_IWriter $pWriter
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
public function __construct(PHPExcel_Writer_IWriter $pWriter = null) { public function __construct(PHPExcel_Writer_IWriter $pWriter = null)
{
if (!is_null($pWriter)) { if (!is_null($pWriter)) {
$this->_parentWriter = $pWriter; $this->_parentWriter = $pWriter;
} }
} }
} }

View File

@ -95,7 +95,8 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
* *
* @param PHPExcel $phpExcel PHPExcel object * @param PHPExcel $phpExcel PHPExcel object
*/ */
public function __construct(PHPExcel $phpExcel) { public function __construct(PHPExcel $phpExcel)
{
$this->_phpExcel = $phpExcel; $this->_phpExcel = $phpExcel;
$this->_parser = new PHPExcel_Writer_Excel5_Parser(); $this->_parser = new PHPExcel_Writer_Excel5_Parser();
@ -107,13 +108,14 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
* @param string $pFilename * @param string $pFilename
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
public function save($pFilename = null) { public function save($pFilename = null)
{
// garbage collect // garbage collect
$this->_phpExcel->garbageCollect(); $this->_phpExcel->garbageCollect();
$saveDebugLog = PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->getWriteDebugLog(); $saveDebugLog = PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->getWriteDebugLog();
PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->setWriteDebugLog(FALSE); PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->setWriteDebugLog(false);
$saveDateReturnType = PHPExcel_Calculation_Functions::getReturnDateType(); $saveDateReturnType = PHPExcel_Calculation_Functions::getReturnDateType();
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL); PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
@ -121,18 +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->_writerWorkbook = new PHPExcel_Writer_Excel5_Workbook($this->_phpExcel, $this->_str_total, $this->_str_unique, $this->_str_table, $this->_colors, $this->_parser);
$this->_str_total, $this->_str_unique, $this->_str_table,
$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->_str_total, $this->_str_unique, $this->_writerWorksheets[$i] = new PHPExcel_Writer_Excel5_Worksheet($this->_str_total, $this->_str_unique, $this->_str_table, $this->_colors, $this->_parser, $this->_preCalculateFormulas, $this->_phpExcel->getSheet($i));
$this->_str_table, $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.
@ -190,14 +186,14 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
$this->_documentSummaryInformation = $this->_writeDocumentSummaryInformation(); $this->_documentSummaryInformation = $this->_writeDocumentSummaryInformation();
// initialize OLE Document Summary Information // initialize OLE Document Summary Information
if(isset($this->_documentSummaryInformation) && !empty($this->_documentSummaryInformation)){ if (isset($this->_documentSummaryInformation) && !empty($this->_documentSummaryInformation)) {
$OLE_DocumentSummaryInformation = new PHPExcel_Shared_OLE_PPS_File(PHPExcel_Shared_OLE::Asc2Ucs(chr(5) . 'DocumentSummaryInformation')); $OLE_DocumentSummaryInformation = new PHPExcel_Shared_OLE_PPS_File(PHPExcel_Shared_OLE::Asc2Ucs(chr(5) . 'DocumentSummaryInformation'));
$OLE_DocumentSummaryInformation->append($this->_documentSummaryInformation); $OLE_DocumentSummaryInformation->append($this->_documentSummaryInformation);
} }
$this->_summaryInformation = $this->_writeSummaryInformation(); $this->_summaryInformation = $this->_writeSummaryInformation();
// initialize OLE Summary Information // initialize OLE Summary Information
if(isset($this->_summaryInformation) && !empty($this->_summaryInformation)){ if (isset($this->_summaryInformation) && !empty($this->_summaryInformation)) {
$OLE_SummaryInformation = new PHPExcel_Shared_OLE_PPS_File(PHPExcel_Shared_OLE::Asc2Ucs(chr(5) . 'SummaryInformation')); $OLE_SummaryInformation = new PHPExcel_Shared_OLE_PPS_File(PHPExcel_Shared_OLE::Asc2Ucs(chr(5) . 'SummaryInformation'));
$OLE_SummaryInformation->append($this->_summaryInformation); $OLE_SummaryInformation->append($this->_summaryInformation);
} }
@ -205,11 +201,11 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
// define OLE Parts // define OLE Parts
$arrRootData = array($OLE); $arrRootData = array($OLE);
// initialize OLE Properties file // initialize OLE Properties file
if(isset($OLE_SummaryInformation)){ if (isset($OLE_SummaryInformation)) {
$arrRootData[] = $OLE_SummaryInformation; $arrRootData[] = $OLE_SummaryInformation;
} }
// initialize OLE Extended Properties file // initialize OLE Extended Properties file
if(isset($OLE_DocumentSummaryInformation)){ if (isset($OLE_DocumentSummaryInformation)) {
$arrRootData[] = $OLE_DocumentSummaryInformation; $arrRootData[] = $OLE_DocumentSummaryInformation;
} }
@ -229,7 +225,8 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
* @throws PHPExcel_Writer_Exception when directory does not exist * @throws PHPExcel_Writer_Exception when directory does not exist
* @return PHPExcel_Writer_Excel5 * @return PHPExcel_Writer_Excel5
*/ */
public function setTempDir($pValue = '') { public function setTempDir($pValue = '')
{
return $this; return $this;
} }
@ -330,13 +327,13 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
} }
// AutoFilters // AutoFilters
if(!empty($filterRange)){ if (!empty($filterRange)) {
$rangeBounds = PHPExcel_Cell::rangeBoundaries($filterRange); $rangeBounds = PHPExcel_Cell::rangeBoundaries($filterRange);
$iNumColStart = $rangeBounds[0][0]; $iNumColStart = $rangeBounds[0][0];
$iNumColEnd = $rangeBounds[1][0]; $iNumColEnd = $rangeBounds[1][0];
$iInc = $iNumColStart; $iInc = $iNumColStart;
while($iInc <= $iNumColEnd){ while($iInc <= $iNumColEnd) {
++$countShapes[$sheetIndex]; ++$countShapes[$sheetIndex];
// create an Drawing Object for the dropdown // create an Drawing Object for the dropdown
@ -444,8 +441,7 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
++$sheetCountShapes; ++$sheetCountShapes;
++$totalCountShapes; ++$totalCountShapes;
$spId = $sheetCountShapes $spId = $sheetCountShapes | ($this->_phpExcel->getIndex($sheet) + 1) << 10;
| ($this->_phpExcel->getIndex($sheet) + 1) << 10;
$spIdMax = max($spId, $spIdMax); $spIdMax = max($spId, $spIdMax);
} }
} }
@ -463,31 +459,26 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
foreach ($this->_phpExcel->getAllsheets() as $sheet) { foreach ($this->_phpExcel->getAllsheets() as $sheet) {
foreach ($sheet->getDrawingCollection() as $drawing) { foreach ($sheet->getDrawingCollection() as $drawing) {
if ($drawing instanceof PHPExcel_Worksheet_Drawing) { if ($drawing instanceof PHPExcel_Worksheet_Drawing) {
$filename = $drawing->getPath(); $filename = $drawing->getPath();
list($imagesx, $imagesy, $imageFormat) = getimagesize($filename); list($imagesx, $imagesy, $imageFormat) = getimagesize($filename);
switch ($imageFormat) { switch ($imageFormat) {
case 1: // GIF, not supported by BIFF8, we convert to PNG case 1: // GIF, not supported by BIFF8, we convert to PNG
$blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG; $blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG;
ob_start(); ob_start();
imagepng(imagecreatefromgif($filename)); imagepng(imagecreatefromgif ($filename));
$blipData = ob_get_contents(); $blipData = ob_get_contents();
ob_end_clean(); ob_end_clean();
break; break;
case 2: // JPEG case 2: // JPEG
$blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_JPEG; $blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_JPEG;
$blipData = file_get_contents($filename); $blipData = file_get_contents($filename);
break; break;
case 3: // PNG case 3: // PNG
$blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG; $blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG;
$blipData = file_get_contents($filename); $blipData = file_get_contents($filename);
break; break;
case 6: // Windows DIB (BMP), we convert to PNG case 6: // Windows DIB (BMP), we convert to PNG
$blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG; $blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG;
ob_start(); ob_start();
@ -495,9 +486,8 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
$blipData = ob_get_contents(); $blipData = ob_get_contents();
ob_end_clean(); ob_end_clean();
break; break;
default:
default: continue 2; continue 2;
} }
$blip = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip(); $blip = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip();
@ -508,23 +498,18 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
$BSE->setBlip($blip); $BSE->setBlip($blip);
$bstoreContainer->addBSE($BSE); $bstoreContainer->addBSE($BSE);
} else if ($drawing instanceof PHPExcel_Worksheet_MemoryDrawing) { } else if ($drawing instanceof PHPExcel_Worksheet_MemoryDrawing) {
switch ($drawing->getRenderingFunction()) { switch ($drawing->getRenderingFunction()) {
case PHPExcel_Worksheet_MemoryDrawing::RENDERING_JPEG: case PHPExcel_Worksheet_MemoryDrawing::RENDERING_JPEG:
$blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_JPEG; $blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_JPEG;
$renderingFunction = 'imagejpeg'; $renderingFunction = 'imagejpeg';
break; break;
case PHPExcel_Worksheet_MemoryDrawing::RENDERING_GIF: case PHPExcel_Worksheet_MemoryDrawing::RENDERING_GIF:
case PHPExcel_Worksheet_MemoryDrawing::RENDERING_PNG: case PHPExcel_Worksheet_MemoryDrawing::RENDERING_PNG:
case PHPExcel_Worksheet_MemoryDrawing::RENDERING_DEFAULT: case PHPExcel_Worksheet_MemoryDrawing::RENDERING_DEFAULT:
$blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG; $blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG;
$renderingFunction = 'imagepng'; $renderingFunction = 'imagepng';
break; break;
} }
ob_start(); ob_start();
@ -552,8 +537,8 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
* Build the OLE Part for DocumentSummary Information * Build the OLE Part for DocumentSummary Information
* @return string * @return string
*/ */
private function _writeDocumentSummaryInformation(){ private function _writeDocumentSummaryInformation()
{
// offset: 0; size: 2; must be 0xFE 0xFF (UTF-16 LE byte order mark) // offset: 0; size: 2; must be 0xFE 0xFF (UTF-16 LE byte order mark)
$data = pack('v', 0xFFFE); $data = pack('v', 0xFFFE);
// offset: 2; size: 2; // offset: 2; size: 2;
@ -586,7 +571,7 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
$dataSection_NumProps++; $dataSection_NumProps++;
// GKPIDDSI_CATEGORY : Category // GKPIDDSI_CATEGORY : Category
if($this->_phpExcel->getProperties()->getCategory()){ if ($this->_phpExcel->getProperties()->getCategory()) {
$dataProp = $this->_phpExcel->getProperties()->getCategory(); $dataProp = $this->_phpExcel->getProperties()->getCategory();
$dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x02), $dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x02),
'offset' => array('pack' => 'V'), 'offset' => array('pack' => 'V'),
@ -682,7 +667,7 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
// 4 Property count // 4 Property count
// 8 * $dataSection_NumProps (8 = ID (4) + OffSet(4)) // 8 * $dataSection_NumProps (8 = ID (4) + OffSet(4))
$dataSection_Content_Offset = 8 + $dataSection_NumProps * 8; $dataSection_Content_Offset = 8 + $dataSection_NumProps * 8;
foreach ($dataSection as $dataProp){ foreach ($dataSection as $dataProp) {
// Summary // Summary
$dataSection_Summary .= pack($dataProp['summary']['pack'], $dataProp['summary']['data']); $dataSection_Summary .= pack($dataProp['summary']['pack'], $dataProp['summary']['data']);
// Offset // Offset
@ -690,25 +675,25 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
// DataType // DataType
$dataSection_Content .= pack($dataProp['type']['pack'], $dataProp['type']['data']); $dataSection_Content .= pack($dataProp['type']['pack'], $dataProp['type']['data']);
// Data // Data
if($dataProp['type']['data'] == 0x02){ // 2 byte signed integer if ($dataProp['type']['data'] == 0x02) { // 2 byte signed integer
$dataSection_Content .= pack('V', $dataProp['data']['data']); $dataSection_Content .= pack('V', $dataProp['data']['data']);
$dataSection_Content_Offset += 4 + 4; $dataSection_Content_Offset += 4 + 4;
} }
elseif($dataProp['type']['data'] == 0x03){ // 4 byte signed integer elseif ($dataProp['type']['data'] == 0x03) { // 4 byte signed integer
$dataSection_Content .= pack('V', $dataProp['data']['data']); $dataSection_Content .= pack('V', $dataProp['data']['data']);
$dataSection_Content_Offset += 4 + 4; $dataSection_Content_Offset += 4 + 4;
} }
elseif($dataProp['type']['data'] == 0x0B){ // Boolean elseif ($dataProp['type']['data'] == 0x0B) { // Boolean
if($dataProp['data']['data'] == false){ if ($dataProp['data']['data'] == false) {
$dataSection_Content .= pack('V', 0x0000); $dataSection_Content .= pack('V', 0x0000);
} else { } else {
$dataSection_Content .= pack('V', 0x0001); $dataSection_Content .= pack('V', 0x0001);
} }
$dataSection_Content_Offset += 4 + 4; $dataSection_Content_Offset += 4 + 4;
} }
elseif($dataProp['type']['data'] == 0x1E){ // null-terminated string prepended by dword string length elseif ($dataProp['type']['data'] == 0x1E) { // null-terminated string prepended by dword string length
// Null-terminated string // Null-terminated string
$dataProp['data']['data'] .= chr(0); $dataProp['data']['data'] .= chr(0);
$dataProp['data']['length'] += 1; $dataProp['data']['length'] += 1;
@ -721,7 +706,7 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
$dataSection_Content_Offset += 4 + 4 + strlen($dataProp['data']['data']); $dataSection_Content_Offset += 4 + 4 + strlen($dataProp['data']['data']);
} }
elseif($dataProp['type']['data'] == 0x40){ // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601) elseif ($dataProp['type']['data'] == 0x40) { // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601)
$dataSection_Content .= $dataProp['data']['data']; $dataSection_Content .= $dataProp['data']['data'];
$dataSection_Content_Offset += 4 + 8; $dataSection_Content_Offset += 4 + 8;
@ -753,7 +738,8 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
* Build the OLE Part for Summary Information * Build the OLE Part for Summary Information
* @return string * @return string
*/ */
private function _writeSummaryInformation(){ private function _writeSummaryInformation()
{
// offset: 0; size: 2; must be 0xFE 0xFF (UTF-16 LE byte order mark) // offset: 0; size: 2; must be 0xFE 0xFF (UTF-16 LE byte order mark)
$data = pack('v', 0xFFFE); $data = pack('v', 0xFFFE);
// offset: 2; size: 2; // offset: 2; size: 2;
@ -786,7 +772,7 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
$dataSection_NumProps++; $dataSection_NumProps++;
// Title // Title
if($this->_phpExcel->getProperties()->getTitle()){ if ($this->_phpExcel->getProperties()->getTitle()) {
$dataProp = $this->_phpExcel->getProperties()->getTitle(); $dataProp = $this->_phpExcel->getProperties()->getTitle();
$dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x02), $dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x02),
'offset' => array('pack' => 'V'), 'offset' => array('pack' => 'V'),
@ -795,7 +781,7 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
$dataSection_NumProps++; $dataSection_NumProps++;
} }
// Subject // Subject
if($this->_phpExcel->getProperties()->getSubject()){ if ($this->_phpExcel->getProperties()->getSubject()) {
$dataProp = $this->_phpExcel->getProperties()->getSubject(); $dataProp = $this->_phpExcel->getProperties()->getSubject();
$dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x03), $dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x03),
'offset' => array('pack' => 'V'), 'offset' => array('pack' => 'V'),
@ -804,7 +790,7 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
$dataSection_NumProps++; $dataSection_NumProps++;
} }
// Author (Creator) // Author (Creator)
if($this->_phpExcel->getProperties()->getCreator()){ if ($this->_phpExcel->getProperties()->getCreator()) {
$dataProp = $this->_phpExcel->getProperties()->getCreator(); $dataProp = $this->_phpExcel->getProperties()->getCreator();
$dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x04), $dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x04),
'offset' => array('pack' => 'V'), 'offset' => array('pack' => 'V'),
@ -813,7 +799,7 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
$dataSection_NumProps++; $dataSection_NumProps++;
} }
// Keywords // Keywords
if($this->_phpExcel->getProperties()->getKeywords()){ if ($this->_phpExcel->getProperties()->getKeywords()) {
$dataProp = $this->_phpExcel->getProperties()->getKeywords(); $dataProp = $this->_phpExcel->getProperties()->getKeywords();
$dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x05), $dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x05),
'offset' => array('pack' => 'V'), 'offset' => array('pack' => 'V'),
@ -822,7 +808,7 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
$dataSection_NumProps++; $dataSection_NumProps++;
} }
// Comments (Description) // Comments (Description)
if($this->_phpExcel->getProperties()->getDescription()){ if ($this->_phpExcel->getProperties()->getDescription()) {
$dataProp = $this->_phpExcel->getProperties()->getDescription(); $dataProp = $this->_phpExcel->getProperties()->getDescription();
$dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x06), $dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x06),
'offset' => array('pack' => 'V'), 'offset' => array('pack' => 'V'),
@ -831,7 +817,7 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
$dataSection_NumProps++; $dataSection_NumProps++;
} }
// Last Saved By (LastModifiedBy) // Last Saved By (LastModifiedBy)
if($this->_phpExcel->getProperties()->getLastModifiedBy()){ if ($this->_phpExcel->getProperties()->getLastModifiedBy()) {
$dataProp = $this->_phpExcel->getProperties()->getLastModifiedBy(); $dataProp = $this->_phpExcel->getProperties()->getLastModifiedBy();
$dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x08), $dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x08),
'offset' => array('pack' => 'V'), 'offset' => array('pack' => 'V'),
@ -840,7 +826,7 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
$dataSection_NumProps++; $dataSection_NumProps++;
} }
// Created Date/Time // Created Date/Time
if($this->_phpExcel->getProperties()->getCreated()){ if ($this->_phpExcel->getProperties()->getCreated()) {
$dataProp = $this->_phpExcel->getProperties()->getCreated(); $dataProp = $this->_phpExcel->getProperties()->getCreated();
$dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x0C), $dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x0C),
'offset' => array('pack' => 'V'), 'offset' => array('pack' => 'V'),
@ -849,7 +835,7 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
$dataSection_NumProps++; $dataSection_NumProps++;
} }
// Modified Date/Time // Modified Date/Time
if($this->_phpExcel->getProperties()->getModified()){ if ($this->_phpExcel->getProperties()->getModified()) {
$dataProp = $this->_phpExcel->getProperties()->getModified(); $dataProp = $this->_phpExcel->getProperties()->getModified();
$dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x0D), $dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x0D),
'offset' => array('pack' => 'V'), 'offset' => array('pack' => 'V'),
@ -869,7 +855,7 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
// 4 Property count // 4 Property count
// 8 * $dataSection_NumProps (8 = ID (4) + OffSet(4)) // 8 * $dataSection_NumProps (8 = ID (4) + OffSet(4))
$dataSection_Content_Offset = 8 + $dataSection_NumProps * 8; $dataSection_Content_Offset = 8 + $dataSection_NumProps * 8;
foreach ($dataSection as $dataProp){ foreach ($dataSection as $dataProp) {
// Summary // Summary
$dataSection_Summary .= pack($dataProp['summary']['pack'], $dataProp['summary']['data']); $dataSection_Summary .= pack($dataProp['summary']['pack'], $dataProp['summary']['data']);
// Offset // Offset
@ -877,17 +863,17 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
// DataType // DataType
$dataSection_Content .= pack($dataProp['type']['pack'], $dataProp['type']['data']); $dataSection_Content .= pack($dataProp['type']['pack'], $dataProp['type']['data']);
// Data // Data
if($dataProp['type']['data'] == 0x02){ // 2 byte signed integer if ($dataProp['type']['data'] == 0x02) { // 2 byte signed integer
$dataSection_Content .= pack('V', $dataProp['data']['data']); $dataSection_Content .= pack('V', $dataProp['data']['data']);
$dataSection_Content_Offset += 4 + 4; $dataSection_Content_Offset += 4 + 4;
} }
elseif($dataProp['type']['data'] == 0x03){ // 4 byte signed integer elseif ($dataProp['type']['data'] == 0x03) { // 4 byte signed integer
$dataSection_Content .= pack('V', $dataProp['data']['data']); $dataSection_Content .= pack('V', $dataProp['data']['data']);
$dataSection_Content_Offset += 4 + 4; $dataSection_Content_Offset += 4 + 4;
} }
elseif($dataProp['type']['data'] == 0x1E){ // null-terminated string prepended by dword string length elseif ($dataProp['type']['data'] == 0x1E) { // null-terminated string prepended by dword string length
// Null-terminated string // Null-terminated string
$dataProp['data']['data'] .= chr(0); $dataProp['data']['data'] .= chr(0);
$dataProp['data']['length'] += 1; $dataProp['data']['length'] += 1;
@ -900,7 +886,7 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
$dataSection_Content_Offset += 4 + 4 + strlen($dataProp['data']['data']); $dataSection_Content_Offset += 4 + 4 + strlen($dataProp['data']['data']);
} }
elseif($dataProp['type']['data'] == 0x40){ // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601) elseif ($dataProp['type']['data'] == 0x40) { // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601)
$dataSection_Content .= $dataProp['data']['data']; $dataSection_Content .= $dataProp['data']['data'];
$dataSection_Content_Offset += 4 + 8; $dataSection_Content_Offset += 4 + 8;

View File

@ -118,7 +118,7 @@ class PHPExcel_Writer_Excel5_BIFFwriter
$number = pack("C8", 0x8D, 0x97, 0x6E, 0x12, 0x83, 0xC0, 0xF3, 0x3F); $number = pack("C8", 0x8D, 0x97, 0x6E, 0x12, 0x83, 0xC0, 0xF3, 0x3F);
if ($number == $teststr) { if ($number == $teststr) {
$byte_order = 0; // Little Endian $byte_order = 0; // Little Endian
} elseif ($number == strrev($teststr)){ } elseif ($number == strrev($teststr)) {
$byte_order = 1; // Big Endian $byte_order = 1; // Big Endian
} else { } else {
// Give up. I'll fix this in a later version. // Give up. I'll fix this in a later version.
@ -136,7 +136,7 @@ class PHPExcel_Writer_Excel5_BIFFwriter
* @param string $data binary data to append * @param string $data binary data to append
* @access private * @access private
*/ */
function _append($data) private function _append($data)
{ {
if (strlen($data) - 4 > $this->_limit) { if (strlen($data) - 4 > $this->_limit) {
$data = $this->_addContinue($data); $data = $this->_addContinue($data);
@ -169,7 +169,7 @@ class PHPExcel_Writer_Excel5_BIFFwriter
* 0x0010 Worksheet. * 0x0010 Worksheet.
* @access private * @access private
*/ */
function _storeBof($type) private function _storeBof($type)
{ {
$record = 0x0809; // Record identifier (BIFF5-BIFF8) $record = 0x0809; // Record identifier (BIFF5-BIFF8)
$length = 0x0010; $length = 0x0010;
@ -192,7 +192,7 @@ class PHPExcel_Writer_Excel5_BIFFwriter
* *
* @access private * @access private
*/ */
function _storeEof() private function _storeEof()
{ {
$record = 0x000A; // Record identifier $record = 0x000A; // Record identifier
$length = 0x0000; // Number of bytes to follow $length = 0x0000; // Number of bytes to follow
@ -226,7 +226,7 @@ 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
*/ */
function _addContinue($data) private function _addContinue($data)
{ {
$limit = $this->_limit; $limit = $this->_limit;
$record = 0x003C; // Record identifier $record = 0x003C; // Record identifier
@ -251,5 +251,4 @@ class PHPExcel_Writer_Excel5_BIFFwriter
return $tmp; return $tmp;
} }
} }

View File

@ -78,7 +78,6 @@ class PHPExcel_Writer_Excel5_Escher
$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);
@ -90,7 +89,6 @@ class PHPExcel_Writer_Excel5_Escher
$this->_spTypes = $writer->getSpTypes(); $this->_spTypes = $writer->getSpTypes();
} }
break; break;
case 'PHPExcel_Shared_Escher_DggContainer': case 'PHPExcel_Shared_Escher_DggContainer':
// this is a container record // this is a container record
@ -107,11 +105,11 @@ class PHPExcel_Writer_Excel5_Escher
// dgg data // dgg data
$dggData = $dggData =
pack('VVVV' pack('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)
@ -143,7 +141,6 @@ class PHPExcel_Writer_Excel5_Escher
$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
@ -171,7 +168,6 @@ class PHPExcel_Writer_Excel5_Escher
$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
@ -221,13 +217,11 @@ class PHPExcel_Writer_Excel5_Escher
$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 = '';
@ -281,10 +275,8 @@ class PHPExcel_Writer_Excel5_Escher
$this->_data .= $innerData; $this->_data .= $innerData;
break; break;
} }
break; break;
case 'PHPExcel_Shared_Escher_DgContainer': case 'PHPExcel_Shared_Escher_DgContainer':
// this is a container record // this is a container record
@ -338,7 +330,6 @@ class PHPExcel_Writer_Excel5_Escher
$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
@ -378,7 +369,6 @@ class PHPExcel_Writer_Excel5_Escher
$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
$data = ''; $data = '';
@ -464,9 +454,7 @@ class PHPExcel_Writer_Excel5_Escher
// end offsetY // end offsetY
$endOffsetY = $this->_object->getEndOffsetY(); $endOffsetY = $this->_object->getEndOffsetY();
$clientAnchorData = pack('vvvvvvvvv', $this->_object->getSpFlag(), $clientAnchorData = pack('vvvvvvvvv', $this->_object->getSpFlag(), $c1, $startOffsetX, $r1, $startOffsetY, $c2, $endOffsetX, $r2, $endOffsetY);
$c1, $startOffsetX, $r1, $startOffsetY,
$c2, $endOffsetX, $r2, $endOffsetY);
$length = strlen($clientAnchorData); $length = strlen($clientAnchorData);
@ -507,7 +495,6 @@ class PHPExcel_Writer_Excel5_Escher
$this->_data = $header . $data; $this->_data = $header . $data;
break; break;
} }
return $this->_data; return $this->_data;
@ -532,6 +519,4 @@ class PHPExcel_Writer_Excel5_Escher
{ {
return $this->_spTypes; return $this->_spTypes;
} }
} }

View File

@ -107,12 +107,17 @@ class PHPExcel_Writer_Excel5_Font
$grbit |= 0x20; $grbit |= 0x20;
} }
$data = pack("vvvvvCCCC", $data = pack(
$this->_font->getSize() * 20, // Fontsize (in twips) "vvvvvCCCC",
// Fontsize (in twips)
$this->_font->getSize() * 20,
$grbit, $grbit,
$icv, // Colour // Colour
self::_mapBold($this->_font->getBold()), // Font weight $icv,
$sss, // Superscript/Subscript // Font weight
self::_mapBold($this->_font->getBold()),
// Superscript/Subscript
$sss,
self::_mapUnderline($this->_font->getUnderline()), self::_mapUnderline($this->_font->getUnderline()),
$bFamily, $bFamily,
$bCharSet, $bCharSet,
@ -132,7 +137,8 @@ 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
} }
@ -144,7 +150,8 @@ class PHPExcel_Writer_Excel5_Font
* @static array of int * @static array of int
* *
*/ */
private static $_mapUnderline = array( PHPExcel_Style_Font::UNDERLINE_NONE => 0x00, private static $_mapUnderline = array(
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,
@ -156,10 +163,11 @@ class PHPExcel_Writer_Excel5_Font
* @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

@ -136,7 +136,7 @@ class PHPExcel_Writer_Excel5_Parser
* *
* @access private * @access private
*/ */
function _initializeHashes() private function _initializeHashes()
{ {
// The Excel ptg indices // The Excel ptg indices
$this->ptg = array( $this->ptg = array(
@ -512,7 +512,7 @@ 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
*/ */
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);
@ -521,15 +521,15 @@ class PHPExcel_Writer_Excel5_Parser
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
@ -537,11 +537,11 @@ class PHPExcel_Writer_Excel5_Parser
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)
@ -553,9 +553,9 @@ class PHPExcel_Writer_Excel5_Parser
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 +573,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
*/ */
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 +593,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
*/ */
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,16 +613,16 @@ 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
*/ */
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 +635,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
*/ */
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
@ -673,7 +673,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.
*/ */
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)
@ -715,7 +715,7 @@ 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
*/ */
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.
@ -745,7 +745,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.
*/ */
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.
@ -779,16 +779,23 @@ 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
*/ */
function _convertError($errorCode) private function _convertError($errorCode)
{ {
switch ($errorCode) { switch ($errorCode) {
case '#NULL!': return pack("C", 0x00); case '#NULL!':
case '#DIV/0!': return pack("C", 0x07); return pack("C", 0x00);
case '#VALUE!': return pack("C", 0x0F); case '#DIV/0!':
case '#REF!': return pack("C", 0x17); return pack("C", 0x07);
case '#NAME?': return pack("C", 0x1D); case '#VALUE!':
case '#NUM!': return pack("C", 0x24); return pack("C", 0x0F);
case '#N/A': return pack("C", 0x2A); case '#REF!':
return pack("C", 0x17);
case '#NAME?':
return pack("C", 0x1D);
case '#NUM!':
return pack("C", 0x24);
case '#N/A':
return pack("C", 0x2A);
} }
return pack("C", 0xFF); return pack("C", 0xFF);
} }
@ -801,7 +808,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
*/ */
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.
@ -846,7 +853,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
*/ */
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.
@ -906,7 +913,7 @@ 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
*/ */
function _getSheetIndex($sheet_name) private function _getSheetIndex($sheet_name)
{ {
if (!isset($this->_ext_sheets[$sheet_name])) { if (!isset($this->_ext_sheets[$sheet_name])) {
return -1; return -1;
@ -925,7 +932,7 @@ class PHPExcel_Writer_Excel5_Parser
* @param string $name The name of the worksheet being added * @param string $name The name of the worksheet being added
* @param integer $index The index of the worksheet being added * @param integer $index The index of the worksheet being added
*/ */
function setExtSheet($name, $index) public function setExtSheet($name, $index)
{ {
$this->_ext_sheets[$name] = $index; $this->_ext_sheets[$name] = $index;
} }
@ -937,7 +944,7 @@ 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
*/ */
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);
@ -966,7 +973,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
*/ */
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
@ -1007,9 +1014,9 @@ 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
*/ */
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
$col_rel = empty($match[1]) ? 1 : 0; $col_rel = empty($match[1]) ? 1 : 0;
$col_ref = $match[2]; $col_ref = $match[2];
@ -1037,7 +1044,7 @@ class PHPExcel_Writer_Excel5_Parser
* *
* @access private * @access private
*/ */
function _advance() private function _advance()
{ {
$i = $this->_current_char; $i = $this->_current_char;
$formula_length = strlen($this->_formula); $formula_length = strlen($this->_formula);
@ -1088,7 +1095,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
*/ */
function _match($token) private function _match($token)
{ {
switch($token) { switch($token) {
case "+": case "+":
@ -1123,65 +1130,55 @@ class PHPExcel_Writer_Excel5_Parser
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 if (preg_match('/^\$?[A-Ia-i]?[A-Za-z]\$?[0-9]+$/', $token) and
!preg_match("/[0-9]/",$this->_lookahead) and !preg_match("/[0-9]/", $this->_lookahead) and
($this->_lookahead != ':') and ($this->_lookahead != '.') and ($this->_lookahead != ':') and ($this->_lookahead != '.') and
($this->_lookahead != '!')) ($this->_lookahead != '!')) {
{
return $token; return $token;
} }
// 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)
elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/u",$token) and 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 !preg_match("/[0-9]/", $this->_lookahead) and
($this->_lookahead != ':') and ($this->_lookahead != '.')) ($this->_lookahead != ':') and ($this->_lookahead != '.')) {
{
return $token; return $token;
} }
// 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)
elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/u",$token) and 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 !preg_match("/[0-9]/", $this->_lookahead) and
($this->_lookahead != ':') and ($this->_lookahead != '.')) ($this->_lookahead != ':') and ($this->_lookahead != '.')) {
{
return $token; return $token;
} }
// if it's a range A1:A2 or $A$1:$A$2 // if it's a range A1:A2 or $A$1:$A$2
elseif (preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+:(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/', $token) and elseif (preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+:(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/', $token) and
!preg_match("/[0-9]/",$this->_lookahead)) !preg_match("/[0-9]/", $this->_lookahead)) {
{
return $token; return $token;
} }
// If it's 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
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 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)) !preg_match("/[0-9]/", $this->_lookahead)) {
{
return $token; return $token;
} }
// 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
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 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)) !preg_match("/[0-9]/", $this->_lookahead)) {
{
return $token; return $token;
} }
// If it's a number (check that it's not a sheet name or range) // If it's a number (check that it's not a sheet name or range)
elseif (is_numeric($token) and elseif (is_numeric($token) and
(!is_numeric($token.$this->_lookahead) or ($this->_lookahead == '')) and (!is_numeric($token.$this->_lookahead) or ($this->_lookahead == '')) and
($this->_lookahead != '!') and ($this->_lookahead != ':')) ($this->_lookahead != '!') and ($this->_lookahead != ':')) {
{
return $token; return $token;
} }
// If it's a string (of maximum 255 characters) // If it's a string (of maximum 255 characters)
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)) {
{
return $token; return $token;
} }
// If it's an error code // If it's an error code
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 $token; return $token;
} }
// if it's a function call // if it's a function call
elseif (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/i",$token) and ($this->_lookahead == "(")) elseif (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/i", $token) and ($this->_lookahead == "(")) {
{
return $token; return $token;
} }
// It's an argument of some description (e.g. a named range), // It's an argument of some description (e.g. a named range),
@ -1201,7 +1198,7 @@ class PHPExcel_Writer_Excel5_Parser
* sign (=). * sign (=).
* @return mixed true on success * @return mixed true on success
*/ */
function parse($formula) public function parse($formula)
{ {
$this->_current_char = 0; $this->_current_char = 0;
$this->_formula = $formula; $this->_formula = $formula;
@ -1218,7 +1215,7 @@ 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
*/ */
function _condition() private function _condition()
{ {
$result = $this->_expression(); $result = $this->_expression();
if ($this->_current_token == "<") { if ($this->_current_token == "<") {
@ -1264,7 +1261,7 @@ 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
*/ */
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->_current_token)) {
@ -1323,7 +1320,7 @@ class PHPExcel_Writer_Excel5_Parser
* @see _fact() * @see _fact()
* @return array The parsed ptg'd tree * @return array The parsed ptg'd tree
*/ */
function _parenthesizedExpression() private function _parenthesizedExpression()
{ {
$result = $this->_createTree('ptgParen', $this->_expression(), ''); $result = $this->_createTree('ptgParen', $this->_expression(), '');
return $result; return $result;
@ -1336,7 +1333,7 @@ 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
*/ */
function _term() private function _term()
{ {
$result = $this->_fact(); $result = $this->_fact();
while (($this->_current_token == "*") or while (($this->_current_token == "*") or
@ -1366,7 +1363,7 @@ 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
*/ */
function _fact() private function _fact()
{ {
if ($this->_current_token == "(") { if ($this->_current_token == "(") {
$this->_advance(); // eat the "(" $this->_advance(); // eat the "("
@ -1378,29 +1375,29 @@ class PHPExcel_Writer_Excel5_Parser
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->_current_token))
{ {
$result = $this->_createTree($this->_current_token, '', ''); $result = $this->_createTree($this->_current_token, '', '');
$this->_advance(); $this->_advance();
return $result; return $result;
} }
// 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)
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->_current_token))
{ {
$result = $this->_createTree($this->_current_token, '', ''); $result = $this->_createTree($this->_current_token, '', '');
$this->_advance(); $this->_advance();
return $result; return $result;
} }
// 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)
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->_current_token))
{ {
$result = $this->_createTree($this->_current_token, '', ''); $result = $this->_createTree($this->_current_token, '', '');
$this->_advance(); $this->_advance();
return $result; return $result;
} }
// if it's a range A1:B2 or $A$1:$B$2 // if it's a range A1:B2 or $A$1:$B$2
elseif (preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+:(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/',$this->_current_token) or elseif (preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+:(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/', $this->_current_token) or
preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+\.\.(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/',$this->_current_token)) preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+\.\.(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/', $this->_current_token))
{ {
// must be an error? // must be an error?
$result = $this->_createTree($this->_current_token, '', ''); $result = $this->_createTree($this->_current_token, '', '');
@ -1408,7 +1405,7 @@ class PHPExcel_Writer_Excel5_Parser
return $result; return $result;
} }
// 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)
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->_current_token))
{ {
// must be an error? // must be an error?
//$result = $this->_current_token; //$result = $this->_current_token;
@ -1417,7 +1414,7 @@ class PHPExcel_Writer_Excel5_Parser
return $result; return $result;
} }
// 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)
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->_current_token))
{ {
// must be an error? // must be an error?
//$result = $this->_current_token; //$result = $this->_current_token;
@ -1438,7 +1435,7 @@ class PHPExcel_Writer_Excel5_Parser
return $result; return $result;
} }
// if it's a function call // if it's a function call
elseif (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/i",$this->_current_token)) elseif (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/i", $this->_current_token))
{ {
$result = $this->_func(); $result = $this->_func();
return $result; return $result;
@ -1455,7 +1452,7 @@ 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
*/ */
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->_current_token);
@ -1485,7 +1482,7 @@ class PHPExcel_Writer_Excel5_Parser
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() ");
} }
@ -1505,7 +1502,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
*/ */
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);
} }
@ -1537,7 +1534,7 @@ class PHPExcel_Writer_Excel5_Parser
* @param array $tree The optional tree to convert. * @param array $tree The optional tree to convert.
* @return string The tree in reverse polish notation * @return string The tree in reverse polish notation
*/ */
function toReversePolish($tree = array()) public function toReversePolish($tree = array())
{ {
$polish = ""; // the string we are going to return $polish = ""; // the string we are going to return
if (empty($tree)) { // If it's the first call use _parse_tree if (empty($tree)) { // If it's the first call use _parse_tree
@ -1559,9 +1556,9 @@ class PHPExcel_Writer_Excel5_Parser
$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)
if (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/",$tree['value']) and if (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/", $tree['value']) and
!preg_match('/^([A-Ia-i]?[A-Za-z])(\d+)$/',$tree['value']) and !preg_match('/^([A-Ia-i]?[A-Za-z])(\d+)$/', $tree['value']) and
!preg_match("/^[A-Ia-i]?[A-Za-z](\d+)\.\.[A-Ia-i]?[A-Za-z](\d+)$/",$tree['value']) and !preg_match("/^[A-Ia-i]?[A-Za-z](\d+)\.\.[A-Ia-i]?[A-Za-z](\d+)$/", $tree['value']) and
!is_numeric($tree['value']) and !is_numeric($tree['value']) and
!isset($this->ptg[$tree['value']])) !isset($this->ptg[$tree['value']]))
{ {
@ -1579,5 +1576,4 @@ class PHPExcel_Writer_Excel5_Parser
$polish .= $converted_tree; $polish .= $converted_tree;
return $polish; return $polish;
} }
} }

View File

@ -200,9 +200,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
* @param array &$colors Colour Table * @param array &$colors Colour Table
* @param mixed $parser The formula parser created for the Workbook * @param mixed $parser The formula parser created for the Workbook
*/ */
public function __construct(PHPExcel $phpExcel = null, public function __construct(PHPExcel $phpExcel = null, &$str_total, &$str_unique, &$str_table, &$colors, $parser)
&$str_total, &$str_unique, &$str_table, &$colors,
$parser )
{ {
// It needs to call its parent's constructor explicitly // It needs to call its parent's constructor explicitly
parent::__construct(); parent::__construct();
@ -303,7 +301,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
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);
@ -324,7 +322,8 @@ 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
@ -354,7 +353,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
* *
* @access private * @access private
*/ */
function _setPaletteXl97() private function _setPaletteXl97()
{ {
$this->_palette = array( $this->_palette = array(
0x08 => array(0x00, 0x00, 0x00, 0x00), 0x08 => array(0x00, 0x00, 0x00, 0x00),
@ -477,7 +476,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
* *
* @access private * @access private
*/ */
function _calcSheetOffsets() private function _calcSheetOffsets()
{ {
$boundsheet_length = 10; // fixed length for a BOUNDSHEET record $boundsheet_length = 10; // fixed length for a BOUNDSHEET record
@ -612,7 +611,6 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
// (exclusive) either repeatColumns or repeatRows // (exclusive) either repeatColumns or repeatRows
} else if ($sheetSetup->isColumnsToRepeatAtLeftSet() || $sheetSetup->isRowsToRepeatAtTopSet()) { } else if ($sheetSetup->isColumnsToRepeatAtLeftSet() || $sheetSetup->isRowsToRepeatAtTopSet()) {
// Columns to repeat // Columns to repeat
if ($sheetSetup->isColumnsToRepeatAtLeftSet()) { if ($sheetSetup->isColumnsToRepeatAtLeftSet()) {
$repeat = $sheetSetup->getColumnsToRepeatAtLeft(); $repeat = $sheetSetup->getColumnsToRepeatAtLeft();
@ -658,7 +656,6 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
// 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());
for ($i = 0; $i < count($range); $i++) { for ($i = 0; $i < count($range); $i++) {
@ -688,7 +685,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
} }
$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
} }
} }
@ -721,7 +718,6 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
// (exclusive) either repeatColumns or repeatRows // (exclusive) either repeatColumns or repeatRows
} else if ($sheetSetup->isColumnsToRepeatAtLeftSet() || $sheetSetup->isRowsToRepeatAtTopSet()) { } else if ($sheetSetup->isColumnsToRepeatAtLeftSet() || $sheetSetup->isRowsToRepeatAtTopSet()) {
// Columns to repeat // Columns to repeat
if ($sheetSetup->isColumnsToRepeatAtLeftSet()) { if ($sheetSetup->isColumnsToRepeatAtLeftSet()) {
$repeat = $sheetSetup->getColumnsToRepeatAtLeft(); $repeat = $sheetSetup->getColumnsToRepeatAtLeft();
@ -785,7 +781,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
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);
//Autofilter built in name //Autofilter built in name
@ -842,7 +838,8 @@ 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;
// option flags // option flags
@ -854,7 +851,8 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
$rangeBounds[0][1] - 1, $rangeBounds[0][1] - 1,
$rangeBounds[1][1] - 1, $rangeBounds[1][1] - 1,
$rangeBounds[0][0] - 1, $rangeBounds[0][0] - 1,
$rangeBounds[1][0] - 1); $rangeBounds[1][0] - 1
);
// size of the formula (in bytes) // size of the formula (in bytes)
$sz = strlen($extra); $sz = strlen($extra);
@ -909,10 +907,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
$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, $data = pack("vvvvvvvvv", $xWn, $yWn, $dxWn, $dyWn, $grbit, $itabCur, $itabFirst, $ctabsel, $wTabRatio);
$grbit,
$itabCur, $itabFirst,
$ctabsel, $wTabRatio);
$this->_append($header . $data); $this->_append($header . $data);
} }
@ -929,10 +924,18 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
// sheet state // sheet state
switch ($sheet->getSheetState()) { switch ($sheet->getSheetState()) {
case PHPExcel_Worksheet::SHEETSTATE_VISIBLE: $ss = 0x00; break; case PHPExcel_Worksheet::SHEETSTATE_VISIBLE:
case PHPExcel_Worksheet::SHEETSTATE_HIDDEN: $ss = 0x01; break; $ss = 0x00;
case PHPExcel_Worksheet::SHEETSTATE_VERYHIDDEN: $ss = 0x02; break; break;
default: $ss = 0x00; break; case PHPExcel_Worksheet::SHEETSTATE_HIDDEN:
$ss = 0x01;
break;
case PHPExcel_Worksheet::SHEETSTATE_VERYHIDDEN:
$ss = 0x02;
break;
default:
$ss = 0x00;
break;
} }
// sheet type // sheet type
@ -1307,7 +1310,6 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
// 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->_str_table) as $string) {
// here $string is a BIFF8 encoded string // here $string is a BIFF8 encoded string
// length = character count // length = character count
@ -1320,7 +1322,6 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
$finished = false; $finished = false;
while ($finished === false) { while ($finished === false) {
// normally, there will be only one cycle, but if string cannot immediately be written as is // normally, there will be only one cycle, but if string cannot immediately be written as is
// there will be need for more than one cylcle, if string longer than one record data block, there // there will be need for more than one cylcle, if string longer than one record data block, there
// may be need for even more cycles // may be need for even more cycles
@ -1369,7 +1370,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
$effective_space_remaining = $space_remaining; $effective_space_remaining = $space_remaining;
// for uncompressed strings, sometimes effective space remaining is reduced by 1 // for uncompressed strings, sometimes effective space remaining is reduced by 1
if ( $encoding == 1 && (strlen($string) - $space_remaining) % 2 == 1 ) { if ($encoding == 1 && (strlen($string) - $space_remaining) % 2 == 1) {
--$effective_space_remaining; --$effective_space_remaining;
} }
@ -1422,7 +1423,6 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
$header = pack("vv", $record, $length); $header = pack("vv", $record, $length);
return $this->writeData($header . $data); return $this->writeData($header . $data);
} else { } else {
return ''; return '';
} }

View File

@ -1254,7 +1254,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$grbit |= 0x0100; $grbit |= 0x0100;
$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);
} }
@ -1590,15 +1590,15 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
// record data // record data
$recordData = pack( $recordData = pack(
'vVVCVVvv' 'vVVCVVvv',
, 0x0867 // repeated record identifier 0x0867, // repeated record identifier
, 0x0000 // not used 0x0000, // not used
, 0x0000 // not used 0x0000, // not used
, 0x00 // not used 0x00, // not used
, 0x01000200 // unknown data 0x01000200, // unknown data
, 0xFFFFFFFF // unknown data 0xFFFFFFFF, // unknown data
, $options // options $options, // options
, 0x0000 // not used 0x0000 // not used
); );
$length = strlen($recordData); $length = strlen($recordData);
@ -1846,14 +1846,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
} }
$header = pack("vv", $record, $length); $header = pack("vv", $record, $length);
$data1 = pack("vvvvvvvv", $iPaperSize, $data1 = pack("vvvvvvvv", $iPaperSize, $iScale, $iPageStart, $iFitWidth, $iFitHeight, $grbit, $iRes, $iVRes);
$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);
@ -2194,7 +2187,6 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
//horizontal page breaks //horizontal page breaks
if (!empty($hbreaks)) { if (!empty($hbreaks)) {
// Sort and filter array of page breaks // Sort and filter array of page breaks
sort($hbreaks, SORT_NUMERIC); sort($hbreaks, SORT_NUMERIC);
if ($hbreaks[0] == 0) { // don't use first break if it's 0 if ($hbreaks[0] == 0) { // don't use first break if it's 0
@ -2218,7 +2210,6 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
// vertical page breaks // vertical page breaks
if (!empty($vbreaks)) { if (!empty($vbreaks)) {
// 1000 vertical pagebreaks appears to be an internal Excel 5 limit. // 1000 vertical pagebreaks appears to be an internal Excel 5 limit.
// It is slightly higher in Excel 97/200, approx. 1026 // It is slightly higher in Excel 97/200, approx. 1026
$vbreaks = array_slice($vbreaks, 0, 1000); $vbreaks = array_slice($vbreaks, 0, 1000);
@ -2472,10 +2463,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$x2 = $width / PHPExcel_Shared_Excel5::sizeCol($this->_phpSheet, PHPExcel_Cell::stringFromColumnIndex($col_end)) * 1024; // Distance to right side of object $x2 = $width / PHPExcel_Shared_Excel5::sizeCol($this->_phpSheet, PHPExcel_Cell::stringFromColumnIndex($col_end)) * 1024; // Distance to right side of object
$y2 = $height / PHPExcel_Shared_Excel5::sizeRow($this->_phpSheet, $row_end + 1) * 256; // Distance to bottom of object $y2 = $height / PHPExcel_Shared_Excel5::sizeRow($this->_phpSheet, $row_end + 1) * 256; // Distance to bottom of object
$this->_writeObjPicture($col_start, $x1, $this->_writeObjPicture($col_start, $x1, $row_start, $y1, $col_end, $x2, $row_end, $y2);
$row_start, $y1,
$col_end, $x2,
$row_end, $y2);
} }
/** /**
@ -2491,7 +2479,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
* @param integer $rwB Row containing bottom right corner of object * @param integer $rwB Row containing bottom right corner of object
* @param integer $dyB Distance from bottom of cell * @param integer $dyB Distance from bottom of cell
*/ */
private function _writeObjPicture($colL,$dxL,$rwT,$dyT,$colR,$dxR,$rwB,$dyB) private function _writeObjPicture($colL, $dxL, $rwT, $dyT, $colR, $dxR, $rwB, $dyB)
{ {
$record = 0x005d; // Record identifier $record = 0x005d; // Record identifier
$length = 0x003c; // Bytes to follow $length = 0x003c; // Bytes to follow
@ -2598,7 +2586,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
public function _processBitmap($bitmap) public function _processBitmap($bitmap)
{ {
// Open file. // Open file.
$bmp_fd = @fopen($bitmap,"rb"); $bmp_fd = @fopen($bitmap, "rb");
if (!$bmp_fd) { if (!$bmp_fd) {
throw new PHPExcel_Writer_Exception("Couldn't import $bitmap"); throw new PHPExcel_Writer_Exception("Couldn't import $bitmap");
} }
@ -2748,15 +2736,15 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
if ($spTypes[$i] == 0x00C9) { if ($spTypes[$i] == 0x00C9) {
// Add ftCmo (common object data) subobject // Add ftCmo (common object data) subobject
$objData .= $objData .=
pack('vvvvvVVV' pack('vvvvvVVV',
, 0x0015 // 0x0015 = ftCmo 0x0015, // 0x0015 = ftCmo
, 0x0012 // length of ftCmo data 0x0012, // length of ftCmo data
, 0x0014 // object type, 0x0014 = filter 0x0014, // object type, 0x0014 = filter
, $i // object id number, Excel seems to use 1-based index, local for the sheet $i, // object id number, Excel seems to use 1-based index, local for the sheet
, 0x2101 // option flags, 0x2001 is what OpenOffice.org uses 0x2101, // option flags, 0x2001 is what OpenOffice.org uses
, 0 // reserved 0, // reserved
, 0 // reserved 0, // reserved
, 0 // reserved 0 // reserved
); );
// Add ftSbs Scroll bar subobject // Add ftSbs Scroll bar subobject
@ -2765,27 +2753,26 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
// Add ftLbsData (List box data) subobject // Add ftLbsData (List box data) subobject
$objData .= pack('vv', 0x0013, 0x1FEE); $objData .= pack('vv', 0x0013, 0x1FEE);
$objData .= pack('H*', '00000000010001030000020008005700'); $objData .= pack('H*', '00000000010001030000020008005700');
} } else {
else {
// Add ftCmo (common object data) subobject // Add ftCmo (common object data) subobject
$objData .= $objData .=
pack('vvvvvVVV' pack('vvvvvVVV',
, 0x0015 // 0x0015 = ftCmo 0x0015, // 0x0015 = ftCmo
, 0x0012 // length of ftCmo data 0x0012, // length of ftCmo data
, 0x0008 // object type, 0x0008 = picture 0x0008, // object type, 0x0008 = picture
, $i // object id number, Excel seems to use 1-based index, local for the sheet $i, // object id number, Excel seems to use 1-based index, local for the sheet
, 0x6011 // option flags, 0x6011 is what OpenOffice.org uses 0x6011, // option flags, 0x6011 is what OpenOffice.org uses
, 0 // reserved 0, // reserved
, 0 // reserved 0, // reserved
, 0 // reserved 0 // reserved
); );
} }
// ftEnd // ftEnd
$objData .= $objData .=
pack('vv' pack('vv',
, 0x0000 // 0x0000 = ftEnd 0x0000, // 0x0000 = ftEnd
, 0x0000 // length of ftEnd data 0x0000 // length of ftEnd data
); );
$length = strlen($objData); $length = strlen($objData);
@ -2805,7 +2792,6 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
// Write data validations? // Write data validations?
if (!empty($dataValidationCollection)) { if (!empty($dataValidationCollection)) {
// DATAVALIDATIONS record // DATAVALIDATIONS record
$record = 0x01B2; // Record identifier $record = 0x01B2; // Record identifier
$length = 0x0012; // Bytes to follow $length = 0x0012; // Bytes to follow
@ -2816,8 +2802,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$objId = 0xFFFFFFFF; // Object identifier of drop down arrow object, or -1 if not visible $objId = 0xFFFFFFFF; // Object identifier of drop down arrow object, or -1 if not visible
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
$data = pack('vVVVV', $grbit, $horPos, $verPos, $objId, $data = pack('vVVVV', $grbit, $horPos, $verPos, $objId, count($dataValidationCollection));
count($dataValidationCollection));
$this->_append($header.$data); $this->_append($header.$data);
// DATAVALIDATION records // DATAVALIDATION records
@ -2953,8 +2938,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$this->_parser->parse($formula1); $this->_parser->parse($formula1);
$formula1 = $this->_parser->toReversePolish(); $formula1 = $this->_parser->toReversePolish();
$sz1 = strlen($formula1); $sz1 = strlen($formula1);
} catch (PHPExcel_Exception $e) {
} catch(PHPExcel_Exception $e) {
$sz1 = 0; $sz1 = 0;
$formula1 = ''; $formula1 = '';
} }
@ -2970,8 +2954,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$this->_parser->parse($formula2); $this->_parser->parse($formula2);
$formula2 = $this->_parser->toReversePolish(); $formula2 = $this->_parser->toReversePolish();
$sz2 = strlen($formula2); $sz2 = strlen($formula2);
} catch (PHPExcel_Exception $e) {
} catch(PHPExcel_Exception $e) {
$sz2 = 0; $sz2 = 0;
$formula2 = ''; $formula2 = '';
} }