PhpExcel Bar Chart

2019-08-26 02:46发布

问题:

I want to change the color of each bar in my bar chart , the chart is like: There are four products product 1 product 2 product 3 product 4

There are two bars for each product, one is total value and one is overall value. Total value should have Black color. overall value should according to its product. Right now its coming only two colors Blue for total value red for overall value.

So please help me for creating such bar chart who has different colors for different product.

Thanks in Advance.

回答1:

At the moment, PHPExcel charts don't support customised colours for dataseries, but only uses MS Excel's varyColors's option.

As for alternatives, there is no other PHP library that supports Excel charts; but you can do so using COM (if you're running on Windows), PUNO with Open/Libre Office, or (I believe) Ilia Alshanetsky's PHP extension for libXL



回答2:

$sheet->getStyle('A1')->applyFromArray(
    array(
        'fill' => array(
            'type' => PHPExcel_Style_Fill::FILL_SOLID,
            'color' => array('rgb' => 'FF0000')
        )
    )
);