当前位置:网站首页>Solution to the prompt of could not close zip file during phpword use
Solution to the prompt of could not close zip file during phpword use
2022-07-05 13:42:00 【Zi Mu Lei】
lately thinkphp The project needs to use phpword To generate a docx The file of , Which USES phpword, First of all, let's say something about it phpword Installation and basic use of .
One 、phpword install
phpword It's through composer To install dependencies , Directly run the following code into the project directory
composer require phpoffice/phpword
Two 、 Basic operation method ( Template replacement )
<?php
namespace Home\Controller;
use Think\Controller;
use PhpOffice\PhpWord\TemplateProcessor;
require_once 'C:\wamp64\www\wenjiantest\ThinkPHP\Library\vendor\autoload.php';
//******//composer After installation autoload.php, Note that the path must be accurate
class DocumentController extends Controller{
public function index(){
$temp=new TemplateProcessor('C:\wamp64\www\wenjiantest\ThinkPHP\Library\vendor\templatee.docx');
$temp->setValue('user', ' Lei Feng's Lei ');
$temp->setValue('email', '[email protected]');
$temp->saveAs("test.docx");
}
}
3、 ... and 、 The main items
Today's point is this , Always prompt when doing the test Could not close zip file, I searched some solutions on the Internet , because phpword It is rarely used in China , So there is no accurate solution , Most of them say that the memory is full 、 Folder permissions and other issues , After adjustment, the same prompt remains , In fact, the problem is docx There is a problem writing the version of the template , Specific solutions :
Add template file template.doc Save as template.docx( Remember not to change the suffix directly , use word Open and save as docx It works )
I hope you can avoid pitfalls in the future development process .
边栏推荐
- [MySQL usage Script] catch all MySQL time and date types and related operation functions (3)
- Talk about seven ways to realize asynchronous programming
- 个人组件 - 消息提示
- 【Hot100】33. 搜索旋转排序数组
- Jenkins installation
- Personal component - message prompt
- 私有地址有那些
- The "Baidu Cup" CTF competition was held in February 2017, Web: explosion-2
- Difference between avc1 and H264
- Godson 2nd generation burn PMON and reload system
猜你喜欢
STM32 reverse entry
Could not set property ‘id‘ of ‘class XX‘ with value ‘XX‘ argument type mismatch 解决办法
"Baidu Cup" CTF competition in September, web:upload
"Baidu Cup" CTF competition in September, web:sql
What is a network port
French scholars: the explicability of counter attack under optimal transmission theory
【每日一题】1200. 最小绝对差
法国学者:最优传输理论下对抗攻击可解释性探讨
MySQL --- 数据库查询 - 排序查询、分页查询
RK3566添加LED
随机推荐
【华南理工大学】考研初试复试资料分享
go 数组与切片
What happened to the communication industry in the first half of this year?
Binder communication process and servicemanager creation process
Godson 2nd generation burn PMON and reload system
Laravel框架运行报错:No application encryption key has been specified
Address book (linked list implementation)
Talk about seven ways to realize asynchronous programming
SAE international strategic investment geometry partner
MySQL get time
Clock cycle
Log4j utilization correlation
Usage, installation and use of TortoiseSVN
jenkins安装
Go pointer
Aikesheng sqle audit tool successfully completed the evaluation of "SQL quality management platform grading ability" of the Academy of communications and communications
记录一下在深度学习-一些bug处理
Aspx simple user login
What are the private addresses
4年工作经验,多线程间的5种通信方式都说不出来,你敢信?