当前位置:网站首页>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/phpwordTwo 、 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 .
边栏推荐
- With 4 years of working experience, you can't tell five ways of communication between multithreads. Dare you believe it?
- 不知道这4种缓存模式,敢说懂缓存吗?
- The "Baidu Cup" CTF competition was held in February 2017, Web: explosion-2
- Log4j utilization correlation
- ZABBIX monitoring
- Integer = = the comparison will unpack automatically. This variable cannot be assigned empty
- Huawei push service content, read notes
- Flutter 3.0更新后如何应用到小程序开发中
- redis6主从复制及集群
- Rocky basic command 3
猜你喜欢

C object storage

These 18 websites can make your page background cool

FPGA 学习笔记:Vivado 2019.1 添加 IP MicroBlaze

法国学者:最优传输理论下对抗攻击可解释性探讨

一网打尽异步神器CompletableFuture

Flutter draws animation effects of wave movement, curves and line graphs

Catch all asynchronous artifact completable future
![[深度学习论文笔记]TransBTSV2: Wider Instead of Deeper Transformer for Medical Image Segmentation](/img/70/6de0346df8527af6c88db1ff89947b.png)
[深度学习论文笔记]TransBTSV2: Wider Instead of Deeper Transformer for Medical Image Segmentation
![[daily question] 1200 Minimum absolute difference](/img/2f/9214df63f6d5fafa1f7247c4529643.png)
[daily question] 1200 Minimum absolute difference

What about data leakage? " Watson k'7 moves to eliminate security threats
随机推荐
Android本地Sqlite数据库的备份和还原
[深度学习论文笔记]TransBTSV2: Wider Instead of Deeper Transformer for Medical Image Segmentation
Catch all asynchronous artifact completable future
【MySQL 使用秘籍】一網打盡 MySQL 時間和日期類型與相關操作函數(三)
leetcode 10. Regular expression matching regular expression matching (difficult)
Difference between avc1 and H264
Multi person cooperation project to see how many lines of code each person has written
Win10——轻量级小工具
[notes of in-depth study paper]uctransnet: rethink the jumping connection in u-net from the perspective of transformer channel
Log4j utilization correlation
MySQL --- 数据库查询 - 排序查询、分页查询
Address book (linked list implementation)
How to choose note taking software? Comparison and evaluation of notion, flowus and WOLAI
网络安全-HSRP协议
山东大学暑期实训一20220620
嵌入式软件架构设计-消息交互
mysql获得时间
MATLAB论文图表标准格式输出(干货)
asp.net 读取txt文件
Record in-depth learning - some bug handling