Test $this->_includeCharts before including charts in HTML Writer

This commit is contained in:
Mark Baker 2012-11-07 23:21:18 +00:00
parent 5a32eee110
commit 2d6f3979d9
1 changed files with 15 additions and 11 deletions

View File

@ -512,16 +512,18 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
private function _extendRowsForChartsAndImages(PHPExcel_Worksheet $pSheet, $row) { private function _extendRowsForChartsAndImages(PHPExcel_Worksheet $pSheet, $row) {
$rowMax = $row; $rowMax = $row;
$colMax = 'A'; $colMax = 'A';
foreach ($pSheet->getChartCollection() as $chart) { if ($this->_includeCharts) {
if ($chart instanceof PHPExcel_Chart) { foreach ($pSheet->getChartCollection() as $chart) {
$chartCoordinates = $chart->getTopLeftPosition(); if ($chart instanceof PHPExcel_Chart) {
$chartTL = PHPExcel_Cell::coordinateFromString($chartCoordinates['cell']); $chartCoordinates = $chart->getTopLeftPosition();
$chartCol = PHPExcel_Cell::columnIndexFromString($chartTL[0]); $chartTL = PHPExcel_Cell::coordinateFromString($chartCoordinates['cell']);
if ($chartTL[1] > $rowMax) { $chartCol = PHPExcel_Cell::columnIndexFromString($chartTL[0]);
$rowMax = $chartTL[1]; if ($chartTL[1] > $rowMax) {
} $rowMax = $chartTL[1];
if ($chartCol > PHPExcel_Cell::columnIndexFromString($colMax)) { }
$colMax = $chartTL[0]; if ($chartCol > PHPExcel_Cell::columnIndexFromString($colMax)) {
$colMax = $chartTL[0];
}
} }
} }
} }
@ -545,7 +547,9 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
for ($col = 'A'; $col != $colMax; ++$col) { for ($col = 'A'; $col != $colMax; ++$col) {
$html .= '<td>'; $html .= '<td>';
$html .= $this->_writeImageInCell($pSheet, $col.$row); $html .= $this->_writeImageInCell($pSheet, $col.$row);
$html .= $this->_writeChartInCell($pSheet, $col.$row); if ($this->_includeCharts) {
$html .= $this->_writeChartInCell($pSheet, $col.$row);
}
$html .= '</td>'; $html .= '</td>';
} }
++$row; ++$row;