功能描述
基于 PHPWord 类,生成 word 及 pdf。
部署说明
下载 PHPWord.zip 解压并部署到 phpGrace/tools 文件夹下。
使用演示
<?php class indexController extends grace{ public function index(){ $PHPWord = tool('PHPWord'); $PHPWord-> setDefaultFontName('微软雅黑'); $section = $PHPWord->createSection(); //添加标题 $PHPWord->addFontStyle('titleStyle', array('bold'=>true, 'size'=> 20, 'align'=>'center', 'spaceAfter'=>100)); $PHPWord->addParagraphStyle('pStyle', array('align'=>'center', 'spaceAfter' => 100)); $section->addText("phpGrace", 'titleStyle', 'pStyle'); //正文内容 $PHPWord->addFontStyle('textStyle', array('size'=> 12, 'spaceAfter'=>100)); $section->addText("phpGrace 体积小,运行效率高!初始化速度可达1毫秒!优秀的框架不应该负重前行、费力启动,phpGrace 给您无比的轻快!", 'textStyle'); //生成 $objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007'); $objWriter->save('./test.docx'); $objWriter->save('./test.pdf'); } }
PHPWord 使用手册
http://www.docin.com/p-1437862599.html