ev / ev-powerpoint-bundle
这是一个Symfony2 Bundle,可以帮助您读取和写入PowerPoint文件,归功于PHPPowerPoint库
2.0
2020-08-11 15:25 UTC
Requires
- php: >=5.3.3
- phpoffice/phppresentation: 0.6.0
- symfony/framework-bundle: >= 4.0.0
README
这是一个Symfony2 Bundle,可以帮助您读取和写入PowerPoint文件,归功于PHPPowerPoint库
功能
- 在Symfony 2中轻松使用PHPPowerPoint库
安装
在composer.json文件中,添加
{ "require": { "phpoffice/phppowerpoint": "dev-master", "ev/ev-powerpoint-bundle": "1.0.*@dev" } }
在app/AppKernel.php文件中,添加
public function registerBundles() { return array( // ... new EV\PowerPointBundle\EVPowerPointBundle(), // ... ); }
PHPPowerPoint使用示例
基本使用
在控制器中
// Acme\MainBundle\Controller\ExportController.php public function powerpointAction() { $powerPointFactory = $this->get('ev_powerpoint'); $objPowerPoint = $powerPointFactory->createPHPPowerPoint(); // Create slide $currentSlide = $objPowerPoint->getActiveSlide(); // Create a shape (text) $shape = $currentSlide->createRichTextShape() ->setHeight(300) ->setWidth(600) ->setOffsetX(170) ->setOffsetY(180); $textRun = $shape->createTextRun('Thank you for using EVPowerPointBundle!'); $textRun->getFont()->setBold(true) ->setSize(60) ->setColor( new Color( 'FFE06B20' ) ); $writer = $powerPointFactory->createWriter($objPowerPoint, 'PowerPoint2007'); return $powerPointFactory->createStreamedResponseWithOptions($writer, array( 'auto_headers' => true, 'filename' => 'powerpoint_'.time() )); }