0

i'm currently working on a project where I need to create powerpoints online. I'm using https://github.com/PHPOffice/PHPPresentation for this. Almost everything works perfectly, besides generating charts. When I open the powerpoint, it says it needs repairing. After the repair all the content is lost.

I wondered if anybody else had the same problem and could help me solve this problem.

Code i tried:

    $oPHPPresentation = new PhpPresentation();
    $currentSlide = $oPHPPresentation->createSlide();
    $currentSlide->setName('Title of the slide');
    $lineChart = new Line();


    $seriesData = array('Monday' => 18, 'Tuesday' => 23, 'Wednesday' => 14, 'Thursday' => 12, 'Friday' => 20, 'Saturday' => 8, 'Sunday' => 10);
    $series = new Series('example', $seriesData);
    $series->setShowValue(false);
    $series->setShowPercentage(true); // This does nothing
    $series->setDlblNumFormat('0.00%'); // This does nothing

    $lineChart->addSeries($series);
    $shape = $currentSlide->createChartShape();
    $shape->getPlotArea()->setType($lineChart);

    $oWriterPPTX = IOFactory::createWriter($oPHPPresentation, 'PowerPoint2007');
    $oWriterPPTX->save(__DIR__ . "/sample.pptx");

Package: https://github.com/PHPOffice/PHPPresentation
framework: Laravel 5.1
php version: 7.0

Thanks in advance

pascal zoet
  • 165
  • 1
  • 12

1 Answers1

1

For the charts to work you have to work on the following :

go to your src folder under the library and open file "pptcharts". And take all the "%" sign away from 'val' and 'pos'. In general search all "%" sign and replace it with "" empty string. Do the same in "ppttheme". and in ppt chart line number 102 delete % sign at the end. Let me know if it works.

Hasan
  • 11
  • 1
  • 2
  • I had the same issue - and that fixed the problem. One important thing to note is that the version that you need to have on composer is `dev-master` – Duniyadnd Jul 07 '20 at 02:16