Some Questions about PHPExcel Charts

寵の児 提交于 2019-12-20 04:57:31

问题


I am using PHPExcel for generating charts in Excel Files. I have some question whoes answer I couldn't find even after lot of R&D those are

  1. How can I show data labels to chart?
  2. How can I control the width of bar charts?
  3. How can I customize colors of bar charts?

I tried to show labels with layout class like :

  $layout = new PHPExcel_Chart_Layout();
  $layout->setShowVal(TRUE);

But no success. I have also explored DataSeries class and Chart Class but couldn't find any solution. Any body here who have already done such tasks, Please guide.

Best Regards.


回答1:


With this:

$dataseriesLabels = array(
    new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$B$1', NULL, 1),
    new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1),
    new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1),
);

$series = new PHPExcel_Chart_DataSeries(
    PHPExcel_Chart_DataSeries::TYPE_BARCHART,       // plotType
    PHPExcel_Chart_DataSeries::GROUPING_STANDARD,   // plotGrouping
    range(0, count($dataSeriesValues)-1),           // plotOrder
    $dataseriesLabels,                              // plotLabel
    $xAxisTickValues,                               // plotCategory
    $dataSeriesValues                               // plotValues
);
  1. you can define the dataseriesLabels to use in your chart
  2. PHPExcel set default Column Width
  3. PhpExcel Bar Chart



回答2:


Read my answer there may be it will help with charts and yes better to create what you need and than use it with load and save(as template)

PHPExcel removes chart style when template is loaded



来源:https://stackoverflow.com/questions/19094890/some-questions-about-phpexcel-charts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!