Editable Charts in Powerpoint

Jul 25, 2012 at 10:26 AM

I created charts using this library. But when i try to edit the Charts inside Office Powerpoint. I am not able to edit the data points. But i can edit the Chart type.

<?php
/** Error reporting */
error_reporting(E_ALL);

/** Include path **/
set_include_path(get_include_path() . PATH_SEPARATOR . '/Classes/');

/** PHPPowerPoint */
include 'Classes/PHPPowerPoint.php';

// Create new PHPPowerPoint object
$objPHPPowerPoint = new PHPPowerPoint();
$objPHPPowerPoint->getProperties()->setCreator("Maarten Balliauw")->
    setLastModifiedBy("Maarten Balliauw")->setTitle("Office 2007 PPTX Test Document")->
    setSubject("Office 2007 PPTX Test Document")->setDescription("Test document for Office 2007 PPTX, generated using PHP classes.")->
    setKeywords("office 2007 openxml php")->setCategory("Test result file");

// Remove first slide
$objPHPPowerPoint->removeSlideByIndex(0);

// Create templated slide

// Create templated slide
$currentSlide = createTemplatedSlide($objPHPPowerPoint);

// Generate sample data for bar chart
$series1Data = array('Mink 7 - experience design' => 69, 'MINKSTOCK - Google Docs' => 5, 'Snippet: Text Excerpt PHP Function | Mink 7' => 5, 'CloudMR' => 3, 'CloudMR' => 2);

// Create a bar chart (that should be inserted in a shape)
$bar3DChart = new PHPPowerPoint_Shape_Chart_Type_Bar3D();
$series1 = new PHPPowerPoint_Shape_Chart_Series('2009', $series1Data);
//$series1->setShowSeriesName(true);
$series1->getFont()->getColor()->setRGB('FF3333');
$series1->getDataPointFill(3)->setFillType(PHPPowerPoint_Style_Fill::FILL_SOLID)->setStartColor(new PHPPowerPoint_Style_Color('0066CC'));
$bar3DChart->addSeries($series1);

// Create a shape (chart)
$shape = $currentSlide->createChartShape();
$shape->setName('Top Visited Pages')
      ->setResizeProportional(false)
      ->setHeight(550)
      ->setWidth(800)
      ->setOffsetX(120)
      ->setOffsetY(80);
$shape->getShadow()->setVisible(true)
                   ->setDirection(45)
                   ->setDistance(40);
$shape->getFill()->setFillType(PHPPowerPoint_Style_Fill::FILL_GRADIENT_LINEAR)
                 ->setStartColor(new PHPPowerPoint_Style_Color('FFCCCCCC'))
                 ->setEndColor(new PHPPowerPoint_Style_Color('FFFFFFFF'))
                 ->setRotation(270);
$shape->getBorder()->setLineStyle(PHPPowerPoint_Style_Border::LINE_SINGLE);
$shape->getTitle()->setText('Top Visited Pages');
$shape->getTitle()->getFont()->setItalic(true);
$shape->getTitle()->getAlignment()->setHorizontal(PHPPowerPoint_Style_Alignment::HORIZONTAL_RIGHT);
$shape->getPlotArea()->getAxisX()->setTitle('Month');
$shape->getPlotArea()->getAxisY()->setTitle('Downloads');
$shape->getPlotArea()->setType($bar3DChart);
$shape->getView3D()->setRightAngleAxes(true);
$shape->getView3D()->setRotationX(20);
$shape->getView3D()->setRotationY(20);
$shape->getLegend()->getBorder()->setLineStyle(PHPPowerPoint_Style_Border::LINE_SINGLE);
$shape->getLegend()->getFont()->setItalic(true);

// Save PowerPoint 2007 file
$objWriter = PHPPowerPoint_IOFactory::createWriter($objPHPPowerPoint,
    'PowerPoint2007');
$objWriter->save(str_replace('.php', '.ppt', __file__));

function createTemplatedSlide(PHPPowerPoint $objPHPPowerPoint) {
    // Create slide
    $slide = $objPHPPowerPoint->createSlide();

    // Return slide
    return $slide;
}

Developer
Feb 1, 2013 at 2:16 PM
By default, including the data is set to FALSE for smaller files.

Try setting setIncludeSpreadsheet to TRUE.
$shape = $currentSlide->createChartShape();
$shape->setIncludeSpreadsheet(1);
May 14, 2013 at 6:43 AM
How to set the outer table border? can you help me! Thanks!