Home  >  Article  >  Backend Development  >  phpword中文字符乱码解决办法_PHP教程

phpword中文字符乱码解决办法_PHP教程

WBOY
WBOYOriginal
2016-07-13 10:57:261066browse

本文章晋级人大家介绍phpword中文字符乱码解决办法,希望此文章对各位所有帮助哦。

最近领导要求用php生成word,网上找了很多类啊,函数啊。最终相中phpword。无奈不是国人开发,对中文支持很不友好。经过研究,终于解决了中文乱码,分享出来。

1、用模板word生成word中文乱码解决方案:

打开phpword/Template.php文件,找到$replace = utf8_encode($replace);将其改为$replace =iconv('gbk', 'utf-8', $replace); 即可。

2、直接生成word文档,调用addText对象时中文乱码解决方案:

打开phpword/Section.php文件,找到$givenText = utf8_encode($text);将其改为$givenText = iconv('gbk', 'utf-8', $text);即可。

3、貌似其他方法也类似第解决。

4、注意php文件采用gbk哦。反正我的显示中文了。在网上找了好久,研究了半天才搞定。

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/632089.htmlTechArticle本文章晋级人大家介绍phpword中文字符乱码解决办法,希望此文章对各位所有帮助哦。 最近领导要求用php生成word,网上找了很多类啊,函数...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn