當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。