0

I have a web page with a chart (FusionChart) that I'm trying to download as a PowerPoint slide with a chart -- one that PowerPoint recognizes as a chart so it will allow the user to edit chart properties (ie: no image).

To this end, I downloaded PHPPowerPoint. After multiple distributions, include path hell, and much wailing and gnashing of teeth, I finally got the thing to work. Kind of. It produces the following:

enter image description here

As you can see, the chart is misplaced and it's empty. Here's the chart zoomed, so you can see it more clearly:

enter image description here

Given all the things wrong with this library and its complete lack of documentation, I'm inclined to think it's broken. However, people appear to be using this, so it's safer to assume I did something wrong.

A code snippet is below. Am I doing anything wrong? Alternatively, are there any free alternatives to PHPPowerPoint? All I care is about exporting a chart, so very limited functionality (Bar, Column & Pie graphs with a title) is all I need.

$objPHPPowerPoint = new PHPPowerPoint();
$objPHPPowerPoint->removeSlideByIndex(0);
$currentSlide = $objPHPPowerPoint->createSlide();
$series = new PHPPowerPoint_Shape_Chart_Series('', array(
    'A' => 69, 
    'B' => 5, 
    'C' => 5, 
    'D' => 3, 
    'E' => 2
));
$series->setShowSeriesName(true);
$bar3DChart = new PHPPowerPoint_Shape_Chart_Type_Bar3D();   
$bar3DChart->addSeries($series);
$shape = $currentSlide->createChartShape();
$shape->setResizeProportional(false);
$shape->setOffsetX(0);
$shape->setOffsetY(0);
$shape->setHeight(550);
$shape->setWidth(800);
$shape->getTitle()->setText($matrix[0][$graphCol]);
$shape->getPlotArea()->setType($bar3DChart);
$objWriter = PHPPowerPoint_IOFactory::createWriter($objPHPPowerPoint,'PowerPoint2007');
$objWriter->save('php://output');

Thanks in advance.

4

1 回答 1

0

再次回答我自己的问题:)

我放弃了 PHPPowerPoint,改用 OpenTBS:http ://www.tinybutstrong.com/plugins/opentbs/tbs_plugin_opentbs.html

这是一个有趣的基于 PHP 模板的系统,它不仅仅是构建 MS Office 和 OpenOffice 文件。

它的工作方式是创建一个模板文件,然后使用该库替换模板中的部分。这对我的目的来说已经足够好了,并且可以很容易地为不同类型的导出创建模板骨架。

于 2014-03-08T00:24:49.087 回答