From 946ea73ddb325a344607846ebf692ff4ccd78703 Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Fri, 20 Jul 2012 22:35:53 +0100 Subject: [PATCH] Bugfixes to Chart Reader and Writer --- Classes/PHPExcel/Reader/Excel2007/Chart.php | 3 ++- Classes/PHPExcel/Shared/XMLWriter.php | 4 ++++ Classes/PHPExcel/Writer/Excel2007/Chart.php | 17 +++++++++++------ 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/Classes/PHPExcel/Reader/Excel2007/Chart.php b/Classes/PHPExcel/Reader/Excel2007/Chart.php index 3333c982..865fb3d7 100644 --- a/Classes/PHPExcel/Reader/Excel2007/Chart.php +++ b/Classes/PHPExcel/Reader/Excel2007/Chart.php @@ -64,7 +64,8 @@ class PHPExcel_Reader_Excel2007_Chart $namespacesChartMeta = $chartElements->getNamespaces(true); $chartElementsC = $chartElements->children($namespacesChartMeta['c']); - $XaxisLabel = $YaxisLabel = $legend = $title = null; + $XaxisLabel = $YaxisLabel = $legend = $title = NULL; + $dispBlanksAs = $plotVisOnly = NULL; foreach($chartElementsC as $chartElementKey => $chartElement) { switch ($chartElementKey) { diff --git a/Classes/PHPExcel/Shared/XMLWriter.php b/Classes/PHPExcel/Shared/XMLWriter.php index 18167762..2abf451a 100644 --- a/Classes/PHPExcel/Shared/XMLWriter.php +++ b/Classes/PHPExcel/Shared/XMLWriter.php @@ -114,6 +114,10 @@ class PHPExcel_Shared_XMLWriter extends XMLWriter { */ public function writeRawData($text) { + if (is_array($text)) { + $text = implode("\n",$text); + } + if (method_exists($this, 'writeRaw')) { return $this->writeRaw(htmlspecialchars($text)); } diff --git a/Classes/PHPExcel/Writer/Excel2007/Chart.php b/Classes/PHPExcel/Writer/Excel2007/Chart.php index 705a4072..286e97c1 100644 --- a/Classes/PHPExcel/Writer/Excel2007/Chart.php +++ b/Classes/PHPExcel/Writer/Excel2007/Chart.php @@ -955,14 +955,19 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa $dataValues = $plotSeriesValues->getDataValues(); if (!empty($dataValues)) { - foreach($dataValues as $plotSeriesKey => $plotSeriesValue) { - $objWriter->startElement('c:pt'); - $objWriter->writeAttribute('idx', $plotSeriesKey ); + if (!is_array($dataValues)) { + var_dump($dataValues); + } + if (is_array($dataValues)) { + foreach($dataValues as $plotSeriesKey => $plotSeriesValue) { + $objWriter->startElement('c:pt'); + $objWriter->writeAttribute('idx', $plotSeriesKey ); - $objWriter->startElement('c:v'); - $objWriter->writeRawData( $plotSeriesValue ); + $objWriter->startElement('c:v'); + $objWriter->writeRawData( $plotSeriesValue ); + $objWriter->endElement(); $objWriter->endElement(); - $objWriter->endElement(); + } } }