我需要使用 php 自动生成带有数学表达式的 word 文档。最好使用 Microsoft 方程、MathType 或 word 的 07+ 方程编辑器。我尝试使用 phpword 的函数 addObject() 将 MathType *.eps 文件作为 OLE 插入,但它的文件类型不支持。我应该怎么做?
$word = new \PhpOffice\PhpWord\PhpWord();
$section = $word->addSection();
$section->addObject('formulas/Eqn1.eps');
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($word, 'Word2007');
$objWriter->save('docs/helloWorld.docx');
错误:PhpOffice\PhpWord\Exception\InvalidObjectException
如果我尝试添加为数学:
$section->addText('
<w:p w:rsidR="00D14CAF" w:rsidRDefault="00A07C15">
<m:oMathPara>
<m:oMath>
<m:r>
<w:rPr>
<w:rFonts w:ascii="Cambria Math" w:hAnsi="Cambria Math"/>
</w:rPr>
<m:t>XXXXXXXXXXXXXX</m:t>
</m:r>
</m:oMath>
</m:oMathPara>
<w:bookmarkStart w:id="0" w:name="_GoBack"/>
<w:bookmarkEnd w:id="0"/>
</w:p>
');
*.docx 无法打开(错误)