Question

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.

Was it helpful?

Solution

Answering my own question again :)

I abandoned PHPPowerPoint and am using OpenTBS instead: http://www.tinybutstrong.com/plugins/opentbs/tbs_plugin_opentbs.html

This is an interesting PHP template based system that goes beyond simply building MS Office and OpenOffice files.

The way it works is you create a template file, then you use the library to substitute sections in your template. It's good enough for my purposes, and makes it easy to create template skeletons for different types of exports.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top