关于PHPExcel图表的一些问题 [英] Some Questions about PHPExcel Charts
本文介绍了关于PHPExcel图表的一些问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用PHPExcel在Excel文件中生成图表。我有一些问题,即使在很多研发后,我找不到这些问题。
- 如何显示数据标签到图表?
- 如何控制条形图的宽度?
- 如何自定义条形图的颜色?
我试图显示带有布局类的标签:
$ 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
);
- 您可以定义要在图表中使用的dataseries标签
- PHPExcel设置默认列宽
- 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
- How can I show data labels to chart?
- How can I control the width of bar charts?
- 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
);
- you can define the dataseriesLabels to use in your chart
- PHPExcel set default Column Width
- PhpExcel Bar Chart
这篇关于关于PHPExcel图表的一些问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文