From 762f12624bad98588bd307e0a4d647cbc570019f Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Sun, 13 May 2012 18:15:09 +0000 Subject: [PATCH] Bugfix: Work item 17471 - OOCalc cells contain same data bug? Plus a couple of charting bugs git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@90420 2327b42d-5241-43d6-9e2a-de5ac946f064 --- Classes/PHPExcel/CachedObjectStorage/APC.php | 8 ++++ Classes/PHPExcel/Chart.php | 2 +- Classes/PHPExcel/Reader/OOCalc.php | 48 ++++++++------------ Classes/PHPExcel/Writer/Excel2007/Chart.php | 2 +- 4 files changed, 28 insertions(+), 32 deletions(-) diff --git a/Classes/PHPExcel/CachedObjectStorage/APC.php b/Classes/PHPExcel/CachedObjectStorage/APC.php index fca364a..e7c4919 100644 --- a/Classes/PHPExcel/CachedObjectStorage/APC.php +++ b/Classes/PHPExcel/CachedObjectStorage/APC.php @@ -38,6 +38,7 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach /** * Prefix used to uniquely identify cache data for this worksheet * + * @access private * @var string */ private $_cachePrefix = null; @@ -45,6 +46,7 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach /** * Cache timeout * + * @access private * @var integer */ private $_cacheTime = 600; @@ -54,6 +56,7 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach * Store cell data in cache for the current cell object if it's "dirty", * and the 'nullify' the current cell object * + * @access private * @return void * @throws Exception */ @@ -74,6 +77,7 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach /** * Add or Update a cell in cache identified by coordinate address * + * @access public * @param string $pCoord Coordinate address of the cell to update * @param PHPExcel_Cell $cell Cell to update * @return void @@ -96,6 +100,7 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach /** * Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell? * + * @access public * @param string $pCoord Coordinate address of the cell to check * @return void * @return boolean @@ -122,6 +127,7 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach /** * Get cell at a specific coordinate * + * @access public * @param string $pCoord Coordinate of the cell * @throws Exception * @return PHPExcel_Cell Cell that was found, or null if not found @@ -159,6 +165,7 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach /** * Delete a cell in cache identified by coordinate address * + * @access public * @param string $pCoord Coordinate address of the cell to delete * @throws Exception */ @@ -174,6 +181,7 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach /** * Clone the cell collection * + * @access public * @param PHPExcel_Worksheet $parent The new worksheet * @return void */ diff --git a/Classes/PHPExcel/Chart.php b/Classes/PHPExcel/Chart.php index b9c9655..d7d6581 100644 --- a/Classes/PHPExcel/Chart.php +++ b/Classes/PHPExcel/Chart.php @@ -448,7 +448,7 @@ class PHPExcel_Chart public function refresh() { if ($this->_worksheet !== NULL) { - $this->$_plotArea->refresh($this->_worksheet); + $this->_plotArea->refresh($this->_worksheet); } } diff --git a/Classes/PHPExcel/Reader/OOCalc.php b/Classes/PHPExcel/Reader/OOCalc.php index 8be2559..3cc057a 100644 --- a/Classes/PHPExcel/Reader/OOCalc.php +++ b/Classes/PHPExcel/Reader/OOCalc.php @@ -626,18 +626,25 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader // echo 'Adjusted Formula: '.$cellDataFormula.'
'; } + $repeats = (isset($cellDataTableAttributes['number-columns-repeated'])) ? + $cellDataTableAttributes['number-columns-repeated'] : 1; if ($type !== NULL) { - $objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->setValueExplicit((($hasCalculatedValue) ? $cellDataFormula : $dataValue),$type); - if ($hasCalculatedValue) { -// echo 'Forumla result is '.$dataValue.'
'; - $objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->setCalculatedValue($dataValue); - } - if (($cellDataOfficeAttributes['value-type'] == 'date') || - ($cellDataOfficeAttributes['value-type'] == 'time')) { - $objPHPExcel->getActiveSheet()->getStyle($columnID.$rowID)->getNumberFormat()->setFormatCode($formatting); - } - if ($hyperlink !== NULL) { - $objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->getHyperlink()->setUrl($hyperlink); + for ($i = 0; $i < $repeats; ++$i) { + if ($i > 0) { + ++$columnID; + } + $objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->setValueExplicit((($hasCalculatedValue) ? $cellDataFormula : $dataValue),$type); + if ($hasCalculatedValue) { +// echo 'Forumla result is '.$dataValue.'
'; + $objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->setCalculatedValue($dataValue); + } + if (($cellDataOfficeAttributes['value-type'] == 'date') || + ($cellDataOfficeAttributes['value-type'] == 'time')) { + $objPHPExcel->getActiveSheet()->getStyle($columnID.$rowID)->getNumberFormat()->setFormatCode($formatting); + } + if ($hyperlink !== NULL) { + $objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->getHyperlink()->setUrl($hyperlink); + } } } @@ -655,25 +662,6 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader $objPHPExcel->getActiveSheet()->mergeCells($cellRange); } - if (isset($cellDataTableAttributes['number-columns-repeated'])) { -// echo 'Repeated '.$cellDataTableAttributes['number-columns-repeated'].' times
'; - $columnID = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($columnID) + $cellDataTableAttributes['number-columns-repeated'] - 2); - - if ($type !== NULL) { - $objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->setValueExplicit((($hasCalculatedValue) ? $cellDataFormula : $dataValue),$type); - if ($hasCalculatedValue) { -// echo 'Forumla result is '.$dataValue.'
'; - $objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->setCalculatedValue($dataValue); - } - if (($cellDataOfficeAttributes['value-type'] == 'date') || - ($cellDataOfficeAttributes['value-type'] == 'time')) { - $objPHPExcel->getActiveSheet()->getStyle($columnID.$rowID)->getNumberFormat()->setFormatCode($formatting); - } - if ($hyperlink !== NULL) { - $objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->getHyperlink()->setUrl($hyperlink); - } - } - } ++$columnID; } ++$rowID; diff --git a/Classes/PHPExcel/Writer/Excel2007/Chart.php b/Classes/PHPExcel/Writer/Excel2007/Chart.php index 4319a98..d27c7af 100644 --- a/Classes/PHPExcel/Writer/Excel2007/Chart.php +++ b/Classes/PHPExcel/Writer/Excel2007/Chart.php @@ -136,7 +136,7 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa $objWriter->startElement('a:p'); $caption = $title->getCaption(); - if (is_array($caption)) + if ((is_array($caption)) && (count($caption) > 0)) $caption = $caption[0]; $this->getParentWriter()->getWriterPart('stringtable')->writeRichTextForCharts($objWriter, $caption, 'a');