我正在使用下面的代码来使用PHP Powerpoint库创建一个图表。
$currentSlide = createTemplatedSlide($objPHPPowerPoint);
$seriesData = array('ABC'=>97,'BCD'=>97,'CDE'=>97,'DEF'=>97,'EFG'=>97,'FGH'=>97);
$lineChart = new PHPPowerPoint_Shape_Chart_Type_Line();
$series = new PHPPowerPoint_Shape_Chart_Series('Benchmark', $seriesData);
$series->setShowSeriesName(false);
$lineChart->addSeries($series);
$shape = $currentSlide->createChartShape();
$shape->setName('Benchmark')
->setResizeProportional(false)
->setHeight(480)
->setWidth(940)
->setOffsetX(10)
->setOffsetY(100);
$shape->getShadow()->setVisible(false)
$shape->getFill()->setFillType(PHPPowerPoint_Style_Fill::FILL_GRADIENT_LINEAR)
->setStartColor(new PHPPowerPoint_Style_Color('ddd9c3'))
->setEndColor(new PHPPowerPoint_Style_Color('ddd9c3'))
->setRotation(270);
$shape->getBorder()->setLineStyle(PHPPowerPoint_Style_Border::LINE_SINGLE);
$shape->getTitle()->setText('');
$shape->getTitle()->getFont()->setItalic(true);
$shape->getPlotArea()->setType($lineChart);
$shape->getView3D()->setRotationX(30);
$shape->getView3D()->setPerspective(30);这张图表正像预期的那样出来(随附截图),但我想定制3件事:
屏幕截图

发布于 2013-10-12 03:33:56
我在网上找到了这个图书馆的两个版本。一个在github上,另一个在codeplex上。Github上的那个看起来很新,但是缺少任何类型的文档。Codeplex已经过时,但实际上有代码示例。
tl;博士-不(无论如何在我的测试中),不,和不。
长版本
在浏览代码和查看它创建的XML时,我注意到了以下几点:
生成的XML (解压缩生成的.pptx文件后的图表/chart1.xml):
<c:valAx>
<c:axId val="52749440"/>
<c:scaling>
<c:orientation val="minMax"/>
</c:scaling>
<c:axPos val="l"/>
<c:numFmt formatCode="" sourceLinked="0"/>
<c:majorTickMark val="none"/>
<c:tickLblPos val="nextTo"/>
<c:txPr>
<a:bodyPr/>
<a:lstStyle/>
<a:p>
<a:pPr>
<a:defRPr/>
</a:pPr>
<a:r>
<a:rPr lang="en-US" dirty="0"/>
<a:t>Y Axis!</a:t>
</a:r>
<a:endParaRPr lang="en-US" dirty="0"/>
</a:p>
</c:txPr>
<c:crossAx val="52743552"/>
<c:crosses val="autoZero"/>
<c:crossBetween val="between"/>
</c:valAx>我通过添加以下行来设置Axis标签:
$shape->getPlotArea()->getAxisX()->setTitle('X Axis!');
$shape->getPlotArea()->getAxisY()->setTitle('Y Axis!');在脚本中的这一行之后:
$shape->getPlotArea()->setType($lineChart);最近可用的Powerpoint编写类是为2007年提供的,这些类非常过时。XML结构可能需要更新并添加一些附加特性。我将查看一些关于OOXML格式的文档,看看在不从头重写编写类的情况下添加这些文档是多么容易。
https://stackoverflow.com/questions/16749043
复制相似问题