addObject()函数不能与php中的.docx文件一起使用

时间:2017-06-22 12:00:14

标签: php phpword

我正在尝试使用phpword addObject()函数将.docx文件附加(嵌入)到word文档,它附加文件但是在点击附件时它没有打开。如果我为.doc文件执行此操作,则打开附件。我正在使用phpword库。

<?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 :(得分:0)