Exemple #1
0
 /**
  * Write Type Bar3D
  *
  * @param  PHPPowerPoint_Shared_XMLWriter       $objWriter    XML Writer
  * @param  PHPPowerPoint_Shape_Chart_Type_Bar3D $subject
  * @param  boolean                              $includeSheet
  * @throws Exception
  */
 protected function _writeTypeBar3D(PHPPowerPoint_Shared_XMLWriter $objWriter, PHPPowerPoint_Shape_Chart_Type_Bar3D $subject, $includeSheet = false)
 {
     // c:bar3DChart
     $objWriter->startElement('c:bar3DChart');
     // c:barDir
     $objWriter->startElement('c:barDir');
     $objWriter->writeAttribute('val', 'col');
     $objWriter->endElement();
     // c:grouping
     $objWriter->startElement('c:grouping');
     $objWriter->writeAttribute('val', 'clustered');
     $objWriter->endElement();
     // Write series
     $seriesIndex = 0;
     foreach ($subject->getData() as $series) {
         // c:ser
         $objWriter->startElement('c:ser');
         // c:idx
         $objWriter->startElement('c:idx');
         $objWriter->writeAttribute('val', $seriesIndex);
         $objWriter->endElement();
         // c:order
         $objWriter->startElement('c:order');
         $objWriter->writeAttribute('val', $seriesIndex);
         $objWriter->endElement();
         // c:tx
         $objWriter->startElement('c:tx');
         $coords = $includeSheet ? 'Sheet1!$' . PHPExcel_Cell::stringFromColumnIndex(1 + $seriesIndex) . '$1' : '';
         $this->_writeSingleValueOrReference($objWriter, $includeSheet, $series->getTitle(), $coords);
         $objWriter->endElement();
         // Fills for points?
         $dataPointFills = $series->getDataPointFills();
         foreach ($dataPointFills as $key => $value) {
             // c:dPt
             $objWriter->startElement('c:dPt');
             // c:idx
             $this->_writeElementWithValAttribute($objWriter, 'c:idx', $key);
             // c:spPr
             $objWriter->startElement('c:spPr');
             // Write fill
             $this->_writeFill($objWriter, $value);
             $objWriter->endElement();
             $objWriter->endElement();
         }
         // c:dLbls
         $objWriter->startElement('c:dLbls');
         // c:txPr
         $objWriter->startElement('c:txPr');
         // a:bodyPr
         $objWriter->writeElement('a:bodyPr', null);
         // a:lstStyle
         $objWriter->writeElement('a:lstStyle', null);
         // a:p
         $objWriter->startElement('a:p');
         // a:pPr
         $objWriter->startElement('a:pPr');
         // a:defRPr
         $objWriter->startElement('a:defRPr');
         $objWriter->writeAttribute('b', $series->getFont()->getBold() ? 'true' : 'false');
         $objWriter->writeAttribute('i', $series->getFont()->getItalic() ? 'true' : 'false');
         $objWriter->writeAttribute('strike', $series->getFont()->getStrikethrough() ? 'sngStrike' : 'noStrike');
         $objWriter->writeAttribute('sz', $series->getFont()->getSize() * 100);
         $objWriter->writeAttribute('u', $series->getFont()->getUnderline());
         if ($series->getFont()->getSuperScript() || $series->getFont()->getSubScript()) {
             if ($series->getFont()->getSuperScript()) {
                 $objWriter->writeAttribute('baseline', '30000');
             } elseif ($series->getFont()->getSubScript()) {
                 $objWriter->writeAttribute('baseline', '-25000');
             }
         }
         // Font - a:solidFill
         $objWriter->startElement('a:solidFill');
         // a:srgbClr
         $objWriter->startElement('a:srgbClr');
         $objWriter->writeAttribute('val', $series->getFont()->getColor()->getRGB());
         $objWriter->endElement();
         $objWriter->endElement();
         // Font - a:latin
         $objWriter->startElement('a:latin');
         $objWriter->writeAttribute('typeface', $series->getFont()->getName());
         $objWriter->endElement();
         $objWriter->endElement();
         $objWriter->endElement();
         // a:endParaRPr
         $objWriter->startElement('a:endParaRPr');
         $objWriter->writeAttribute('lang', 'en-US');
         $objWriter->writeAttribute('dirty', '0');
         $objWriter->endElement();
         $objWriter->endElement();
         $objWriter->endElement();
         // c:showVal
         $this->_writeElementWithValAttribute($objWriter, 'c:showVal', $series->getShowValue() ? '1' : '0');
         // c:showCatName
         $this->_writeElementWithValAttribute($objWriter, 'c:showCatName', $series->getShowCategoryName() ? '1' : '0');
         // c:showSerName
         $this->_writeElementWithValAttribute($objWriter, 'c:showSerName', $series->getShowSeriesName() ? '1' : '0');
         // c:showPercent
         $this->_writeElementWithValAttribute($objWriter, 'c:showPercent', $series->getShowPercentage() ? '1' : '0');
         // c:showLeaderLines
         $this->_writeElementWithValAttribute($objWriter, 'c:showLeaderLines', $series->getShowLeaderLines() ? '1' : '0');
         $objWriter->endElement();
         // c:spPr
         $objWriter->startElement('c:spPr');
         // Write fill
         $this->_writeFill($objWriter, $series->getFill());
         $objWriter->endElement();
         // Write X axis data
         $axisXData = array_keys($series->getValues());
         // c:cat
         $objWriter->startElement('c:cat');
         $this->_writeMultipleValuesOrReference($objWriter, $includeSheet, $axisXData, 'Sheet1!$A$2:$A$' . (1 + count($axisXData)));
         $objWriter->endElement();
         // Write Y axis data
         $axisYData = array_values($series->getValues());
         // c:val
         $objWriter->startElement('c:val');
         $coords = $includeSheet ? 'Sheet1!$' . PHPExcel_Cell::stringFromColumnIndex($seriesIndex + 1) . '$2:$' . PHPExcel_Cell::stringFromColumnIndex($seriesIndex + 1) . '$' . (1 + count($axisYData)) : '';
         $this->_writeMultipleValuesOrReference($objWriter, $includeSheet, $axisYData, $coords);
         $objWriter->endElement();
         $objWriter->endElement();
         ++$seriesIndex;
     }
     // c:gapWidth
     $objWriter->startElement('c:gapWidth');
     $objWriter->writeAttribute('val', '75');
     $objWriter->endElement();
     // c:shape
     $objWriter->startElement('c:shape');
     $objWriter->writeAttribute('val', 'box');
     $objWriter->endElement();
     // c:axId
     $objWriter->startElement('c:axId');
     $objWriter->writeAttribute('val', '52743552');
     $objWriter->endElement();
     // c:axId
     $objWriter->startElement('c:axId');
     $objWriter->writeAttribute('val', '52749440');
     $objWriter->endElement();
     // c:axId
     $objWriter->startElement('c:axId');
     $objWriter->writeAttribute('val', '0');
     $objWriter->endElement();
     $objWriter->endElement();
 }
Exemple #2
0
echo date('H:i:s') . " Set properties\n";
$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
echo date('H:i:s') . " Remove first slide\n";
$objPHPPowerPoint->removeSlideByIndex(0);
// Create templated slide
echo date('H:i:s') . " Create templated slide\n";
$currentSlide = createTemplatedSlide($objPHPPowerPoint);
// local function
// Generate sample data for first chart
echo date('H:i:s') . " Generate sample data for first chart\n";
$series1Data = array('Jan' => 133, 'Feb' => 99, 'Mar' => 191, 'Apr' => 205, 'May' => 167, 'Jun' => 201, 'Jul' => 240, 'Aug' => 226, 'Sep' => 255, 'Oct' => 264, 'Nov' => 283, 'Dec' => 293);
$series2Data = array('Jan' => 266, 'Feb' => 198, 'Mar' => 271, 'Apr' => 305, 'May' => 267, 'Jun' => 301, 'Jul' => 340, 'Aug' => 326, 'Sep' => 344, 'Oct' => 364, 'Nov' => 383, 'Dec' => 379);
// Create a bar chart (that should be inserted in a shape)
echo date('H:i:s') . " Create a bar chart (that should be inserted in a chart shape)\n";
$bar3DChart = new PHPPowerPoint_Shape_Chart_Type_Bar3D();
$series1 = new PHPPowerPoint_Shape_Chart_Series('2009', $series1Data);
$series1->setShowSeriesName(true);
$series1->getFont()->getColor()->setRGB('00FF00');
$series1->getDataPointFill(2)->setFillType(PHPPowerPoint_Style_Fill::FILL_SOLID)->setStartColor(new PHPPowerPoint_Style_Color('FF00FF00'));
$series2 = new PHPPowerPoint_Shape_Chart_Series('2010', $series2Data);
$series2->setShowSeriesName(true);
$series2->getFont()->getColor()->setRGB('FF0000');
$bar3DChart->addSeries($series1);
$bar3DChart->addSeries($series2);
// Create a shape (chart)
echo date('H:i:s') . " Create a shape (chart)\n";
$shape = $currentSlide->createChartShape();
$shape->setName('PHPPowerPoint Monthly Downloads')->setResizeProportional(false)->setHeight(550)->setWidth(700)->setOffsetX(120)->setOffsetY(80);
$shape->getShadow()->setVisible(true)->setDirection(45)->setDistance(10);
$shape->getFill()->setFillType(PHPPowerPoint_Style_Fill::FILL_GRADIENT_LINEAR)->setStartColor(new PHPPowerPoint_Style_Color('FFCCCCCC'))->setEndColor(new PHPPowerPoint_Style_Color('FFFFFFFF'))->setRotation(270);
Exemple #3
0
echo date('H:i:s') . " Set properties\n";
$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
echo date('H:i:s') . " Remove first slide\n";
$objPHPPowerPoint->removeSlideByIndex(0);
// Create templated slide
echo date('H:i:s') . " Create templated slide\n";
$currentSlide = createTemplatedSlide($objPHPPowerPoint);
// local function
// Generate sample data for first chart
echo date('H:i:s') . " Generate sample data for first chart\n";
$series1Data = array('Jan' => 133, 'Feb' => 99, 'Mar' => 191, 'Apr' => 205, 'May' => 167, 'Jun' => 201, 'Jul' => 240, 'Aug' => 226, 'Sep' => 255, 'Oct' => 264, 'Nov' => 283, 'Dec' => 293);
$series2Data = array('Jan' => 266, 'Feb' => 198, 'Mar' => 271, 'Apr' => 305, 'May' => 267, 'Jun' => 301, 'Jul' => 340, 'Aug' => 326, 'Sep' => 344, 'Oct' => 364, 'Nov' => 383, 'Dec' => 379);
// Create a bar chart (that should be inserted in a shape)
echo date('H:i:s') . " Create a bar chart (that should be inserted in a chart shape)\n";
$bar3DChart = new PHPPowerPoint_Shape_Chart_Type_Bar3D();
$bar3DChart->addSeries(new PHPPowerPoint_Shape_Chart_Series('2009', $series1Data));
$bar3DChart->addSeries(new PHPPowerPoint_Shape_Chart_Series('2010', $series2Data));
// Create a shape (chart)
echo date('H:i:s') . " Create a shape (chart)\n";
$shape = $currentSlide->createChartShape();
$shape->setName('PHPPowerPoint Monthly Downloads')->setResizeProportional(false)->setHeight(550)->setWidth(700)->setOffsetX(120)->setOffsetY(80)->setIncludeSpreadsheet(true);
$shape->getShadow()->setVisible(true)->setDirection(45)->setDistance(10);
$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('PHPPowerPoint Monthly Downloads');
$shape->getTitle()->getFont()->setItalic(true);
$shape->getPlotArea()->getAxisX()->setTitle('Month');
$shape->getPlotArea()->getAxisY()->setTitle('Downloads');
$shape->getPlotArea()->setType($bar3DChart);
$shape->getView3D()->setRightAngleAxes(true);