当前位置: 代码迷 >> 综合 >> phpword - 生成word的php类库相关问题总结
  详细解决方案

phpword - 生成word的php类库相关问题总结

热度:91   发布时间:2023-12-19 09:44:50.0

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('
  相关解决方案