phpword

How to edit word documents with php?

大憨熊 提交于 2019-12-09 18:49:19
问题 I have an existing word document in my computer and like to edit this file from my website (using PHP). I was able to find PHPWORD but this deals with new documents only. I don't want to code PHP for the whole document, instead wish to use it for the stuff that varies. Does anybody know any way out? 回答1: https://github.com/PHPOffice/PHPWord PHPWord also features a Reader which can be used to edit existing documents. 回答2: @nssmart, Yes,mark a section on your word document with a variable such

How can I read a Doc file with PhpWord?

夙愿已清 提交于 2019-12-07 20:26:44
问题 recently i download php word which i download from github but i dont know how to read word file via this ? there is no help in this lib. i saw a file like same as php excel bbut dont know how to use . below file: simple01 sample.php <?php error_reporting(E_ALL); if(php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) { define('EOL', PHP_EOL); } else { define('EOL', '<br />'); } require_once '../src/PHPWord.php'; // New Word Document echo date('H:i:s') , " Create new PHPWord object" ,

PHPWord how to add text break / new line while in a text run

北战南征 提交于 2019-12-07 04:35:44
问题 How can I add a text break or go to the next line/row while in a text run? I tried to just do $section->addTextBreak(2); while in the text run but it just added the breaks to the section after the text run. I also tried $textrun->addTextBreak(2); but it gave me a fatal error. Any responses would be greatly appreciated. 回答1: I'm afraid that this will not be possible with current version. I don't have deep understanding of this library, but from looking at the code, I found out that the textRun

manipulating template in PHPWord

谁说胖子不能爱 提交于 2019-12-06 18:39:14
问题 I am using a word document generator for PHP for the reports module of the web-app i am developing. I choose PHPWord because the free version of PHPDocX has very limited functionality plus it has a footer that it is only a free version. I have a template given by the client. What I want is I want to load the template and add dynamic elements to it like additional text or tables. My code is here: <?php require_once '../PHPWord.php'; $PHPWord = new PHPWord(); $document = $PHPWord->loadTemplate(

PHPWord read word documents preserving the styles

泄露秘密 提交于 2019-12-06 11:52:51
问题 I have successfully extracted the text content in a word file using phpWord and the following code: <?php require_once 'vendor/autoload.php'; // Read contents $name = 'linux'; $source = "{$name}.docx"; echo date('H:i:s'), " Reading contents from {$source} <hr>"; $phpWord = \PhpOffice\PhpWord\IOFactory::load($source); $sections = $phpWord->getSections(); foreach ($sections as $key => $value) { $sectionElement = $value->getElements(); foreach ($sectionElement as $elementKey => $elementValue) {

开源PHP Office项目资源

夙愿已清 提交于 2019-12-06 07:54:51
在Office 15即将发布之际,开发人员可能会更关注那些在开源的PHPoffice,一般的程序员、设计师他们距离Office办公套件也是蛮遥远的,但是如果真的 要用了总不可能去下载一个吧即使是WPS也需要时间,所以不如在自己的服务器上建立一个建议的PHP Office。   这里的替代品(既简单又复杂),可能更加适合你。   从此我们在线观看文档不再需要豆丁和百度文库了!    PHPExcel   几乎支持所有常用Excel的功能的PHPExcel,格式支持.XLS或者这.XLSX。功能支持包括表格的任何元数据、添加工作表/行/列,合并单元格,操作公式等等,并且完美兼容MS Office中的Excel。支持打印哦,亲!   官方地址: http://phpexcel.codeplex.com/   github: https://github.com/PHPOffice/PHPExcel.git    SimpleExcel   用简单的方式解析打开Excel XML 、 CSV格式,仅需要支持PHP5+即可!   官方地址: http://faisalman.github.com/simple-excel-php/   github:git://github.com/faisalman/simple-excel-php    php-excel   php

phpWord - Cannot add PreserveText in Section

杀马特。学长 韩版系。学妹 提交于 2019-12-06 07:12:11
问题 Not got a lot of experience with phpWord and coming across the following error: Fatal error: Uncaught exception 'BadMethodCallException' with message 'Cannot add PreserveText in Section.' Its happening when using the below line: $phpWord = \PhpOffice\PhpWord\IOFactory::load($document_location . $document_name . '.docx'); The document definitely exists and I can save the document and readfile as well. Any insight would be greatly appreciated. 回答1: I had the same Problem (also asked here) and

ZipArchive::close(): Failure to create temporary file: Permission denied nginx

半城伤御伤魂 提交于 2019-12-05 23:31:10
问题 I would love a good suggestion how to fix the following. For a platform I have to create php word documents and it so happens that on the Apache dev environment this code executes perfectly; yet on the nginx platform I keep on receiving the error as the topic suggests: ZipArchive::close(): Failure to create temporary file: Permission denied The build up is pretty simple: $phpWord = new \PhpOffice\PhpWord\PhpWord(); //code block as in the documentation $objWriter = \PhpOffice\PhpWord\IOFactory

PHPWord how to add text break / new line while in a text run

我是研究僧i 提交于 2019-12-05 09:28:23
How can I add a text break or go to the next line/row while in a text run? I tried to just do $section->addTextBreak(2); while in the text run but it just added the breaks to the section after the text run. I also tried $textrun->addTextBreak(2); but it gave me a fatal error. Any responses would be greatly appreciated. j0hny I'm afraid that this will not be possible with current version. I don't have deep understanding of this library, but from looking at the code, I found out that the textRun class consist only of addText and addLink methods. But I also need this feature along with several

manipulating template in PHPWord

纵然是瞬间 提交于 2019-12-05 00:05:10
I am using a word document generator for PHP for the reports module of the web-app i am developing. I choose PHPWord because the free version of PHPDocX has very limited functionality plus it has a footer that it is only a free version. I have a template given by the client. What I want is I want to load the template and add dynamic elements to it like additional text or tables. My code is here: <?php require_once '../PHPWord.php'; $PHPWord = new PHPWord(); $document = $PHPWord->loadTemplate('Template.docx'); $document->setValue('Value1', 'Great'); $section = $PHPWord->createSection();