当前位置: 首页>>代码示例>>PHP>>正文


PHP PhpPresentation\PhpPresentation类代码示例

本文整理汇总了PHP中PhpOffice\PhpPresentation\PhpPresentation的典型用法代码示例。如果您正苦于以下问题:PHP PhpPresentation类的具体用法?PHP PhpPresentation怎么用?PHP PhpPresentation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PhpPresentation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testTypeBar

 public function testTypeBar()
 {
     $seriesData = array('A' => 1, 'B' => 2, 'C' => 4, 'D' => 3, 'E' => 2);
     $oPhpPresentation = new PhpPresentation();
     $oSlide = $oPhpPresentation->getActiveSlide();
     $oShape = $oSlide->createChartShape();
     $oShape->setResizeProportional(false)->setHeight(550)->setWidth(700)->setOffsetX(120)->setOffsetY(80);
     $oBar = new Bar();
     $oSeries = new Series('Downloads', $seriesData);
     $oSeries->getDataPointFill(0)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_BLUE));
     $oSeries->getDataPointFill(1)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_DARKBLUE));
     $oSeries->getDataPointFill(2)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_DARKGREEN));
     $oSeries->getDataPointFill(3)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_DARKRED));
     $oSeries->getDataPointFill(4)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_DARKYELLOW));
     $oBar->addSeries($oSeries);
     $oShape->getPlotArea()->setType($oBar);
     $oXMLDoc = TestHelperDOCX::getDocument($oPhpPresentation, 'PowerPoint2007');
     $element = '/p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData';
     $this->assertTrue($oXMLDoc->elementExists($element, 'ppt/slides/slide1.xml'));
     $element = '/c:chartSpace/c:chart/c:plotArea/c:barChart';
     $this->assertTrue($oXMLDoc->elementExists($element, 'ppt/charts/' . $oShape->getIndexedFilename()));
     $element = '/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser';
     $this->assertTrue($oXMLDoc->elementExists($element, 'ppt/charts/' . $oShape->getIndexedFilename()));
     $element = '/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dPt/c:spPr';
     $this->assertTrue($oXMLDoc->elementExists($element, 'ppt/charts/' . $oShape->getIndexedFilename()));
     $element = '/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:tx/c:v';
     $this->assertEquals($oSeries->getTitle(), $oXMLDoc->getElement($element, 'ppt/charts/' . $oShape->getIndexedFilename())->nodeValue);
 }
开发者ID:hxsam,项目名称:PHPPresentation,代码行数:28,代码来源:ChartBarTest.php

示例2: allDrawings

 /**
  * Get an array of all drawings
  *
  * @param  PhpPresentation                 $pPhpPresentation
  * @return \PhpOffice\PhpPresentation\Shape\AbstractDrawing[] All drawings in PhpPresentation
  * @throws \Exception
  */
 public function allDrawings(PhpPresentation $pPhpPresentation)
 {
     // Get an array of all drawings
     $aDrawings = array();
     // Loop trough PhpPresentation
     $slideCount = $pPhpPresentation->getSlideCount();
     for ($i = 0; $i < $slideCount; ++$i) {
         // Loop trough images and add to array
         $iterator = $pPhpPresentation->getSlide($i)->getShapeCollection()->getIterator();
         while ($iterator->valid()) {
             if ($iterator->current() instanceof AbstractDrawing && !$iterator->current() instanceof Table) {
                 $aDrawings[] = $iterator->current();
             } elseif ($iterator->current() instanceof Group) {
                 $iterator2 = $iterator->current()->getShapeCollection()->getIterator();
                 while ($iterator2->valid()) {
                     if ($iterator2->current() instanceof AbstractDrawing && !$iterator2->current() instanceof Table) {
                         $aDrawings[] = $iterator2->current();
                     }
                     $iterator2->next();
                 }
             }
             $iterator->next();
         }
     }
     return $aDrawings;
 }
开发者ID:hxsam,项目名称:PHPPresentation,代码行数:33,代码来源:Drawing.php

示例3: save

 /**
  * Save PhpPresentation to file
  *
  * @param  string    $pFilename
  * @throws \Exception
  */
 public function save($pFilename)
 {
     if (empty($pFilename)) {
         throw new \Exception("Filename is empty.");
     }
     if (!is_null($this->presentation)) {
         // Create new ZIP file and open it for writing
         $objZip = new \ZipArchive();
         // Try opening the ZIP file
         if ($objZip->open($pFilename, \ZipArchive::CREATE) !== true) {
             if ($objZip->open($pFilename, \ZipArchive::OVERWRITE) !== true) {
                 throw new \Exception("Could not open " . $pFilename . " for writing.");
             }
         }
         // Add media
         $slideCount = $this->presentation->getSlideCount();
         for ($i = 0; $i < $slideCount; ++$i) {
             for ($j = 0; $j < $this->presentation->getSlide($i)->getShapeCollection()->count(); ++$j) {
                 if ($this->presentation->getSlide($i)->getShapeCollection()->offsetGet($j) instanceof AbstractDrawing) {
                     $imgTemp = $this->presentation->getSlide($i)->getShapeCollection()->offsetGet($j);
                     $objZip->addFromString('media/' . $imgTemp->getFilename(), file_get_contents($imgTemp->getPath()));
                 }
             }
         }
         // Add PhpPresentation.xml to the document, which represents a PHP serialized PhpPresentation object
         $objZip->addFromString('PhpPresentation.xml', $this->writeSerialized($this->presentation, $pFilename));
         // Close file
         if ($objZip->close() === false) {
             throw new \Exception("Could not close zip file {$pFilename}.");
         }
     } else {
         throw new \Exception("PhpPresentation object unassigned.");
     }
 }
开发者ID:hxsam,项目名称:PHPPresentation,代码行数:40,代码来源:Serialized.php

示例4: testFeatureThumbnail

 public function testFeatureThumbnail()
 {
     $imagePath = PHPPRESENTATION_TESTS_BASE_DIR . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'PhpPresentationLogo.png';
     $oPhpPresentation = new PhpPresentation();
     $oPhpPresentation->getPresentationProperties()->setThumbnailPath($imagePath);
     $oXMLDoc = TestHelperDOCX::getDocument($oPhpPresentation, 'PowerPoint2007');
     $this->assertTrue($oXMLDoc->fileExists('docProps/thumbnail.jpeg'));
 }
开发者ID:phpoffice,项目名称:phppowerpoint,代码行数:8,代码来源:DocPropsThumbnailTest.php

示例5: testParent

 public function testParent()
 {
     $object = new Note();
     $this->assertNull($object->getParent());
     $oPhpPresentation = new PhpPresentation();
     $oSlide = $oPhpPresentation->createSlide();
     $oSlide->setNote($object);
     $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide', $object->getParent());
 }
开发者ID:hxsam,项目名称:PHPPresentation,代码行数:9,代码来源:NoteTest.php

示例6: testCompany

 public function testCompany()
 {
     $expected = 'aAbBcDeE';
     $oPhpPresentation = new PhpPresentation();
     $oPhpPresentation->getDocumentProperties()->setCompany($expected);
     $oXMLDoc = TestHelperDOCX::getDocument($oPhpPresentation, 'PowerPoint2007');
     $this->assertTrue($oXMLDoc->fileExists('docProps/app.xml'));
     $this->assertTrue($oXMLDoc->elementExists('/Properties/Company', 'docProps/app.xml'));
     $this->assertEquals($expected, $oXMLDoc->getElement('/Properties/Company', 'docProps/app.xml')->nodeValue);
 }
开发者ID:phpoffice,项目名称:phppowerpoint,代码行数:10,代码来源:DocPropsAppTest.php

示例7: testCommentsAuthors

 public function testCommentsAuthors()
 {
     $oAuthor = new Comment\Author();
     $oComment = new Comment();
     $oComment->setAuthor($oAuthor);
     $oPhpPresentation = new PhpPresentation();
     $oPhpPresentation->getActiveSlide()->addShape($oComment);
     $pres = TestHelperDOCX::getDocument($oPhpPresentation, 'PowerPoint2007');
     $this->assertTrue($pres->elementExists('/Relationships/Relationship[@Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/commentAuthors"]', 'ppt/_rels/presentation.xml.rels'));
 }
开发者ID:phpoffice,项目名称:phppowerpoint,代码行数:10,代码来源:RelationshipsTest.php

示例8: testLastView

 public function testLastView()
 {
     $expectedElement = '/p:viewPr';
     $expectedLastView = PresentationProperties::VIEW_OUTLINE;
     $oPhpPresentation = new PhpPresentation();
     $oPhpPresentation->getPresentationProperties()->setLastView($expectedLastView);
     $oXMLDoc = TestHelperDOCX::getDocument($oPhpPresentation, 'PowerPoint2007');
     $this->assertTrue($oXMLDoc->fileExists('ppt/viewProps.xml'));
     $this->assertTrue($oXMLDoc->elementExists($expectedElement, 'ppt/viewProps.xml'));
     $this->assertEquals($expectedLastView, $oXMLDoc->getElementAttribute($expectedElement, 'lastView', 'ppt/viewProps.xml'));
 }
开发者ID:phpoffice,项目名称:phppowerpoint,代码行数:11,代码来源:PptViewPropsTest.php

示例9: testDocumentProperties

 public function testDocumentProperties()
 {
     $expected = 'aAbBcDeE';
     $oPhpPresentation = new PhpPresentation();
     $oPhpPresentation->getDocumentProperties()->setCreator($expected);
     $oPhpPresentation->getDocumentProperties()->setTitle($expected);
     $oPhpPresentation->getDocumentProperties()->setDescription($expected);
     $oPhpPresentation->getDocumentProperties()->setSubject($expected);
     $oPhpPresentation->getDocumentProperties()->setKeywords($expected);
     $oPhpPresentation->getDocumentProperties()->setCategory($expected);
     $oXMLDoc = TestHelperDOCX::getDocument($oPhpPresentation, 'PowerPoint2007');
     $this->assertTrue($oXMLDoc->fileExists('docProps/core.xml'));
     $this->assertTrue($oXMLDoc->elementExists('/cp:coreProperties/dc:creator', 'docProps/core.xml'));
     $this->assertEquals($expected, $oXMLDoc->getElement('/cp:coreProperties/dc:creator', 'docProps/core.xml')->nodeValue);
     $this->assertTrue($oXMLDoc->elementExists('/cp:coreProperties/dc:title', 'docProps/core.xml'));
     $this->assertEquals($expected, $oXMLDoc->getElement('/cp:coreProperties/dc:title', 'docProps/core.xml')->nodeValue);
     $this->assertTrue($oXMLDoc->elementExists('/cp:coreProperties/dc:description', 'docProps/core.xml'));
     $this->assertEquals($expected, $oXMLDoc->getElement('/cp:coreProperties/dc:description', 'docProps/core.xml')->nodeValue);
     $this->assertTrue($oXMLDoc->elementExists('/cp:coreProperties/dc:subject', 'docProps/core.xml'));
     $this->assertEquals($expected, $oXMLDoc->getElement('/cp:coreProperties/dc:subject', 'docProps/core.xml')->nodeValue);
     $this->assertTrue($oXMLDoc->elementExists('/cp:coreProperties/cp:keywords', 'docProps/core.xml'));
     $this->assertEquals($expected, $oXMLDoc->getElement('/cp:coreProperties/cp:keywords', 'docProps/core.xml')->nodeValue);
     $this->assertTrue($oXMLDoc->elementExists('/cp:coreProperties/cp:category', 'docProps/core.xml'));
     $this->assertEquals($expected, $oXMLDoc->getElement('/cp:coreProperties/cp:category', 'docProps/core.xml')->nodeValue);
 }
开发者ID:phpoffice,项目名称:phppowerpoint,代码行数:25,代码来源:DocPropsCoreTest.php

示例10: testGroup

 public function testGroup()
 {
     $oPhpPresentation = new PhpPresentation();
     $oSlide = $oPhpPresentation->getActiveSlide();
     $oGroup = $oSlide->createGroup();
     $oDrawing = new Drawing();
     $this->assertInternalType('array', $oDrawing->allDrawings($oPhpPresentation));
     $this->assertEmpty($oDrawing->allDrawings($oPhpPresentation));
     $oGroup->createDrawingShape();
     $oGroup->createDrawingShape();
     $oGroup->createDrawingShape();
     $this->assertInternalType('array', $oDrawing->allDrawings($oPhpPresentation));
     $this->assertCount(3, $oDrawing->allDrawings($oPhpPresentation));
 }
开发者ID:hxsam,项目名称:PHPPresentation,代码行数:14,代码来源:DrawingTest.php

示例11: testMemoryDrawing

 public function testMemoryDrawing()
 {
     $oPhpPresentation = new PhpPresentation();
     $oSlide = $oPhpPresentation->getActiveSlide();
     $oShape = new MemoryDrawing();
     $gdImage = @imagecreatetruecolor(140, 20);
     $textColor = imagecolorallocate($gdImage, 255, 255, 255);
     imagestring($gdImage, 1, 5, 5, 'Created with PhpPresentation', $textColor);
     $oShape->setImageResource($gdImage)->setRenderingFunction(MemoryDrawing::RENDERING_JPEG)->setMimeType(MemoryDrawing::MIMETYPE_DEFAULT);
     $oSlide->addShape($oShape);
     $pres = TestHelperDOCX::getDocument($oPhpPresentation, 'ODPresentation');
     $element = '/manifest:manifest/manifest:file-entry[5]';
     $this->assertTrue($pres->elementExists($element, 'META-INF/manifest.xml'));
     $this->assertEquals('Pictures/' . $oShape->getIndexedFilename(), $pres->getElementAttribute($element, 'manifest:full-path', 'META-INF/manifest.xml'));
 }
开发者ID:hxsam,项目名称:PHPPresentation,代码行数:15,代码来源:ManifestTest.php

示例12: writePresentationRelationships

 /**
  * Write presentation relationships to XML format
  *
  * @param  PhpPresentation $pPhpPresentation
  * @return string        XML Output
  * @throws \Exception
  */
 public function writePresentationRelationships(PhpPresentation $pPhpPresentation)
 {
     // Create XML writer
     $objWriter = $this->getXMLWriter();
     // XML header
     $objWriter->startDocument('1.0', 'UTF-8', 'yes');
     // Relationships
     $objWriter->startElement('Relationships');
     $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
     // Relation id
     $relationId = 1;
     $parentWriter = $this->getParentWriter();
     if ($parentWriter instanceof PowerPoint2007) {
         // Add slide masters
         $masterSlides = $parentWriter->getLayoutPack()->getMasterSlides();
         foreach ($masterSlides as $masterSlide) {
             // Relationship slideMasters/slideMasterX.xml
             $this->writeRelationship($objWriter, $relationId++, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster', 'slideMasters/slideMaster' . $masterSlide['masterid'] . '.xml');
         }
     }
     // Add slide theme (only one!)
     // Relationship theme/theme1.xml
     $this->writeRelationship($objWriter, $relationId++, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme', 'theme/theme1.xml');
     // Relationships with slides
     $slideCount = $pPhpPresentation->getSlideCount();
     for ($i = 0; $i < $slideCount; ++$i) {
         $this->writeRelationship($objWriter, $relationId++, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide', 'slides/slide' . ($i + 1) . '.xml');
     }
     $this->writeRelationship($objWriter, $relationId++, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/presProps', 'presProps.xml');
     $this->writeRelationship($objWriter, $relationId++, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/viewProps', 'viewProps.xml');
     $this->writeRelationship($objWriter, $relationId++, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/tableStyles', 'tableStyles.xml');
     $objWriter->endElement();
     // Return
     return $objWriter->getData();
 }
开发者ID:hxsam,项目名称:PHPPresentation,代码行数:42,代码来源:Rels.php

示例13: testSave

 /**
  * Test save
  */
 public function testSave()
 {
     $filename = tempnam(sys_get_temp_dir(), 'PhpPresentation');
     $imageFile = PHPPRESENTATION_TESTS_BASE_DIR . '/resources/images/PhpPresentationLogo.png';
     $oPhpPresentation = new PhpPresentation();
     $slide = $oPhpPresentation->getActiveSlide();
     $slide->createRichTextShape();
     $slide->createLineShape(10, 10, 10, 10);
     $slide->createChartShape()->getPlotArea()->setType(new \PhpOffice\PhpPresentation\Shape\Chart\Type\Bar3D());
     $slide->createDrawingShape()->setName('Drawing')->setPath($imageFile);
     $slide->createTableShape()->createRow();
     $object = new ODPresentation($oPhpPresentation);
     $object->save($filename);
     $this->assertTrue(file_exists($filename));
     unlink($filename);
 }
开发者ID:hxsam,项目名称:PHPPresentation,代码行数:19,代码来源:ODPresentationTest.php

示例14: testMethod

 /**
  */
 public function testMethod()
 {
     $oPhpPresentation = new PhpPresentation();
     $oPhpPresentation->addSlide(new Slide());
     $object = new Iterator($oPhpPresentation);
     $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide', $object->current());
     $this->assertEquals(0, $object->key());
     $this->assertNull($object->next());
     $this->assertEquals(1, $object->key());
     $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide', $object->current());
     $this->assertTrue($object->valid());
     $this->assertNull($object->next());
     $this->assertFalse($object->valid());
     $this->assertNull($object->rewind());
     $this->assertEquals(0, $object->key());
 }
开发者ID:hxsam,项目名称:PHPPresentation,代码行数:18,代码来源:IteratorTest.php

示例15: testTypeArea

 public function testTypeArea()
 {
     $seriesData = array('A' => 1, 'B' => 2, 'C' => 4, 'D' => 3, 'E' => 2);
     $oPhpPresentation = new PhpPresentation();
     $oSlide = $oPhpPresentation->getActiveSlide();
     $oShape = $oSlide->createChartShape();
     $oShape->setResizeProportional(false)->setHeight(550)->setWidth(700)->setOffsetX(120)->setOffsetY(80);
     $oArea = new Area();
     $oSeries = new Series('Downloads', $seriesData);
     $oSeries->getFill()->setStartColor(new Color('FFAABBCC'));
     $oArea->addSeries($oSeries);
     $oShape->getPlotArea()->setType($oArea);
     $oXMLDoc = TestHelperDOCX::getDocument($oPhpPresentation, 'PowerPoint2007');
     $element = '/p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData';
     $this->assertTrue($oXMLDoc->elementExists($element, 'ppt/slides/slide1.xml'));
     $element = '/c:chartSpace/c:chart/c:plotArea/c:areaChart';
     $this->assertTrue($oXMLDoc->elementExists($element, 'ppt/charts/' . $oShape->getIndexedFilename()));
     $element = '/c:chartSpace/c:chart/c:plotArea/c:areaChart/c:ser';
     $this->assertTrue($oXMLDoc->elementExists($element, 'ppt/charts/' . $oShape->getIndexedFilename()));
 }
开发者ID:hxsam,项目名称:PHPPresentation,代码行数:20,代码来源:ChartAreaTest.php


注:本文中的PhpOffice\PhpPresentation\PhpPresentation类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。