1、中文乱码
问题:section中使用addText中文乱码
方案:找到PHPWord Section.php文件 ,大概在111行,更改为
public function addText($text, $styleFont = null, $styleParagraph = null) {// $givenText = utf8_encode($text);// $givenText = iconv('gbk', 'utf-8', $text);$givenText = $text;$text = new PHPWord_Section_Text($givenText, $styleFont, $styleParagraph);$this->_elementCollection[] = $text;return $text;}
2、中文字体不支持,例如 黑体、楷体等字体
问题:中文字体不支持
解决:1、打开文件/Writer/Word2007/Base.php
2、找到函数 _writeTextStyle
添加:大概310行
// Fontif($font != 'Arial') {$objWriter->startElement('