2017-04-21 166 views
0

我在PHP文件下面的代碼:如何將西裏爾字母粘貼到word文檔(phpword)?

     $PHPWord = new PHPWord(); 
         header('Content-Type: text/html; charset=utf-8'); 
         $template = $PHPWord->loadTemplate('protected/controllers/template.docx'); 
         $template->setValue('Value2', '102'); 
         $template->setValue('Value3', 'ИНН'); 

這裏ИНН「是西里爾。當我粘貼值'Value3'時,它將這些ÐÐÐ符號粘貼到word文檔。我需要在word文檔中插入ИНН單詞。我該怎麼做?

+0

您使用的是什麼版本的PHPWord?這與Yii有什麼關係?如果是這樣,哪個版本?運行此代碼時您使用佈局嗎?你如何保存它以及格式? – szako

+0

我建議給更多的細節,並添加「phpword」標籤的帖子。 – szako

回答

0

最新版本(v0.13.0)僅使用此代碼生成所需的行爲。 php文件是utf-8編碼的。

require_once 'vendor/autoload.php'; 

$templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor('template.docx'); 
$templateProcessor->setValue('Value2', '102'); 
$templateProcessor->setValue('Value3', 'ИНН'); 
$templateProcessor->saveAs('test_utf8.docx'); 

This是結果的屏幕截圖。

相關問題