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.

R. Barzell
  • 666
  • 5
  • 24
  • Where do you add the chart to PowerPoint object? – vascowhite Mar 07 '14 at 13:13
  • I guess I'm not; this is just a re-worked sample, which I assumed was correct. It's funny too, because I wondered about that, and assumed setting it in $shape would do the trick, but then where was $shape being added. Could you point me to the right method? Also if you know anyplace where there's documentation on this thing, I'd be MUCH obliged! – R. Barzell Mar 07 '14 at 13:16
  • I'm not familiar with this class, but I would start by looking in the source for an addGraph or similarly named method. – vascowhite Mar 07 '14 at 15:00
  • Have a look at this http://phppowerpoint.codeplex.com/SourceControl/latest#trunk/Tests/07chart.php – vascowhite Mar 07 '14 at 15:07
  • @vascowhite that's the code I adapted, and I don't see anything which adds the $shape. I can try running it verbatim, although IIRC, it doesn't even run -- which is why I had to adapt it. I'm really tempted to call this library broken. In the time I spent trying to fix all its problems, I probably could have grokked the PresentationML documentation and did this thing manually. PHPExcel worked reasonably well, it's a shame this thing is so off the rails :( – R. Barzell Mar 07 '14 at 15:28

1 Answers1

0

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.

R. Barzell
  • 666
  • 5
  • 24
  • tinybutstrong isn't supported anymore, any solution out there for producing charts in a PPT file? –  Apr 12 '19 at 03:56