迅睿CMS框架是一款PHP8高性能·簡單易用的CMS開源開發(fā)框架,基于MIT開源許可協(xié)議發(fā)布,免費且不限制商業(yè)使用,是免費開源的產(chǎn)品,以萬端互聯(lián)為設計理念,支持的微信公眾號、小程序、APP客戶端、移動端網(wǎng)站、PC網(wǎng)站等多終端式管理系統(tǒng)。
聯(lián)系官方銷售客服
1835022288
028-61286886
按《Phpword生成word文檔》(http://223987.com/doc/1103.html) 操作,我把test.docx應該放在了 dayrui\App\Demo\Controllers目錄下,但是報錯:Could not copy 'test.docx' file to 'C:\Users\Admin\AppData\Local\Temp\Php747A.tmp'。
非常感謝。我才發(fā)現(xiàn),我前面使用絕對路徑的時候已經(jīng)生成了,其實一直生成在根目錄下面。
不使用模板的代碼,記錄一下,測試成功。
<?php namespace Phpcmf\Controllers; class Doc extends \Phpcmf\Common{ public function index() { $phpWord = new \PhpOffice\PhpWord\PhpWord(); if ($phpWord === null) { echo "Error: The PhpWord object is null."; exit; } else { $section = $phpWord->addSection(); $section->addText('Hello World!'); $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007'); $xmlWriter->save('helloWorld.docx'); } } }
非常感謝。我才發(fā)現(xiàn),我前面使用絕對路徑的時候已經(jīng)生成了,其實一直生成在根目錄下面。
不使用模板的代碼,記錄一下,測試成功。