Chart Writing bugfix to refresh values

This commit is contained in:
Mark Baker 2012-07-21 11:52:20 +01:00
parent 8bcf795e16
commit 679f95773e
2 changed files with 21 additions and 24 deletions

View File

@ -273,14 +273,33 @@ class PHPExcel_Chart_DataSeriesValues
return $this;
}
private function _stripNulls($var) {
return $var !== NULL;
}
public function refresh(PHPExcel_Worksheet $worksheet) {
echo '$this->_dataSource:',PHP_EOL;
var_dump($this->_dataSource);
if ($this->_dataSource !== NULL) {
echo '$this->_dataValues:',PHP_EOL;
var_dump($this->_dataValues);
$calcEngine = PHPExcel_Calculation::getInstance();
$this->_dataValues = PHPExcel_Calculation::_unwrapResult(
$newDataValues = PHPExcel_Calculation::_unwrapResult(
$calcEngine->_calculateFormulaValue(
$this->_dataSource
'='.$this->_dataSource,
NULL,
$worksheet->getCell('A1')
)
);
echo '$newDataValues:',PHP_EOL;
var_dump($newDataValues);
$this->_dataValues = PHPExcel_Calculation_Functions::flattenArray($newDataValues);
$this->_dataValues = array_values(array_shift($newDataValues));
// $this->_dataValues = array_filter($this->_dataValues,array($this,'_stripNulls'));
echo '$this->_dataValues:',PHP_EOL;
var_dump($this->_dataValues);
}
}

View File

@ -975,17 +975,6 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
$dataValues = $plotSeriesValues->getDataValues();
if (!empty($dataValues)) {
// if (!is_array($dataValues)) {
// echo 'NOT AN ARRAY: ';
// var_dump($dataValues);
// $dataValues = PHPExcel_Calculation_Functions::flattenArray(
// PHPExcel_Calculation::getInstance()
// ->calculateFormula('='.$dataValues,
// NULL,
// $pSheet->getCell('A1')
// )
// );
// }
if (is_array($dataValues)) {
foreach($dataValues as $plotSeriesKey => $plotSeriesValue) {
$objWriter->startElement('c:pt');
@ -1031,17 +1020,6 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
$dataValues = $plotSeriesValues->getDataValues();
if (!empty($dataValues)) {
// if (!is_array($dataValues)) {
// echo 'NOT AN ARRAY: ';
// var_dump($dataValues);
// $dataValues = PHPExcel_Calculation_Functions::flattenArray(
// PHPExcel_Calculation::getInstance()
// ->calculateFormula('='.$dataValues,
// NULL,
// $pSheet->getCell('A1')
// )
// );
// }
if (is_array($dataValues)) {
foreach($dataValues as $plotSeriesKey => $plotSeriesValue) {
$objWriter->startElement('c:pt');