关于PHPExcel图表的一些问题 [英] Some Questions about PHPExcel Charts

查看:379
本文介绍了关于PHPExcel图表的一些问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用PHPExcel在Excel文件中生成图表。我有一些问题,即使在很多研发后,我找不到这些问题。


  1. 如何显示数据标签到图表?

  2. 如何控制条形图的宽度?

  3. 如何自定义条形图的颜色?

我试图显示带有布局类的标签:

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

但没有成功。
我还探索了 DataSeries 类和图表类,但找不到任何解决方案。

解决方案



/ div>

有了这个:

  $ dataseriesLabels = array(
new PHPExcel_Chart_DataSeriesValues('String','工作表!$ B $ 1',NULL,1),
新PHPExcel_Chart_DataSeriesValues('String','Worksheet!$ C $ 1',NULL,1),
new PHPExcel_Chart_DataSeriesValues $ 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. 您可以定义要在图表中使用的dataseries标签

  2. PHPExcel设置默认列宽

  3. PhpExcel条形图


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.

解决方案

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

这篇关于关于PHPExcel图表的一些问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆