2017-06-22 32 views
-1

我想附加(嵌入)一個.docx文件使用phpword addObject()函數的Word文檔,它附加文件,但點擊附加文件時,它不是打開。如果我爲.doc文件執行此操作,它會打開附加文件。我正在使用phpword庫。addObject()函數不能與.docx文件在php

<?php 
require_once '../PHPWord.php'; 

// New Word Document 
$PHPWord = new PHPWord(); 

// New portrait section 
$section = $PHPWord->createSection(); 

// Add text elements 
$section->addText('You can open this OLE object by double clicking on the icon:'); 
$section->addTextBreak(2); 

// Add object 
$section->addObject('Test.docx'); 
//if i use $section->addObject('Test.doc'); it's opening attached file. here Test.doc is word97-2003 format. 
// Save File 
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007'); 
$objWriter->save('Object.docx'); 
?> 
+1

分享您的代碼 –

+0

對不起,現在添加代碼。 – user1784677

回答