-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Closed
Description
When setting the fill color property on a data series within a line chart and exporting it using the XLSX writer the chart becomes corrupt. The XLSX Chart writer has a bug on line:
| if ($plotLabel) { |
It should not add the
<c:spPr /> tag with colour properties here. It should add them to the <c:spPr /> tag generated for the line which occurs here:https://github.com/PHPOffice/PhpSpreadsheet/blob/develop/src/PhpSpreadsheet/Writer/Xlsx/Chart.php#L1140
My workaround is to use a custom writer and I applied my fixes as below:
Line 1079:
$plotLabel = $plotGroup->getPlotLabelByIndex($plotSeriesIdx);
if ($plotLabel && $groupType !== DataSeries::TYPE_LINECHART &&
$groupType !== DataSeries::TYPE_STOCKCHART
) {
$fillColor = $plotLabel->getFillColor();
if ($fillColor !== null) {
$objWriter->startElement('c:spPr');
$objWriter->startElement('a:solidFill');
$objWriter->startElement('a:srgbClr');
$objWriter->writeAttribute('val', $fillColor);
$objWriter->endElement();
$objWriter->endElement();
$objWriter->endElement();
}
}Line 1143:
if ($groupType == DataSeries::TYPE_STOCKCHART) {
$objWriter->startElement('a:noFill');
$objWriter->endElement();
} elseif ($plotLabel && $plotLabel->getFillColor() !== null) {
$objWriter->startElement('a:solidFill');
$objWriter->startElement('a:srgbClr');
$objWriter->writeAttribute('val', $plotLabel->getFillColor());
$objWriter->endElement();
$objWriter->endElement();
}This probably isn't the best solution though as I don't know what impact it has on other chart types yet. I only know if affects line charts.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels