当前位置:网站首页>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 使用秘籍】一网打尽 MySQL 时间和日期类型与相关操作函数(三)
- asp. Net read TXT file
- Redis6 data type and operation summary
- Idea remote debugging agent
- 49. Grouping of alphabetic ectopic words: give you a string array, please combine the alphabetic ectopic words together. You can return a list of results in any order. An alphabetic ectopic word is a
- 【 script secret pour l'utilisation de MySQL 】 un jeu en ligne sur l'heure et le type de date de MySQL et les fonctions d'exploitation connexes (3)
- Although the volume and price fall, why are the structural deposits of commercial banks favored by listed companies?
- leetcode 10. Regular expression matching regular expression matching (difficult)
- ZABBIX monitoring
- kafaka 日志收集
猜你喜欢
[server data recovery] a case of RAID5 data recovery stored in a brand of server
stm32逆向入门
Go array and slice
Write API documents first or code first?
Win10 - lightweight gadget
南理工在线交流群
These 18 websites can make your page background cool
Laravel framework operation error: no application encryption key has been specified
搭建一个仪式感点满的网站,并内网穿透发布到公网 2/2
Cloudcompare - point cloud slice
随机推荐
内网穿透工具 netapp
[public class preview]: basis and practice of video quality evaluation
Solve the problem of "unable to open source file" xx.h "in the custom header file on vs from the source
Jasypt configuration file encryption | quick start | actual combat
49. 字母异位词分组:给你一个字符串数组,请你将 字母异位词 组合在一起。可以按任意顺序返回结果列表。 字母异位词 是由重新排列源单词的字母得到的一个新单词,所有源单词中的字母通常恰好只用一次。
Idea设置方法注释和类注释
With 4 years of working experience, you can't tell five ways of communication between multithreads. Dare you believe it?
Programmer growth Chapter 8: do a good job of testing
Datapipeline was selected into the 2022 digital intelligence atlas and database development report of China Academy of communications and communications
私有地址有那些
搭建一个仪式感点满的网站,并内网穿透发布到公网 2/2
Aspx simple user login
Summit review | baowanda - an integrated data security protection system driven by compliance and security
go 字符串操作
[deep learning paper notes] hnf-netv2 for segmentation of brain tumors using multimodal MR imaging
RK3566添加LED
jasypt配置文件加密|快速入门|实战
[notes of in-depth study paper]uctransnet: rethink the jumping connection in u-net from the perspective of transformer channel
MySQL - database query - sort query, paging query
What is a network port