我想将ODF文件作为模板加载,对文档执行变量(字符串)替换,并输出带有替换字符串的新ODF文件。这可能与phpdocx有关,还是我应该寻找其他工具?
以下是我目前的情况:
$docx = new CreateDocx();
$docx->setTemplateSymbol('^');
$docx->enableCompatibilityMode();
$docx->addTemplate($source);
$docVarArray = $docx->getTemplateVariables();
// TODO phpdocx variable replacement here.
$docx->createDocx($destination);
...在$docx->addTemplate($source)
期间因错误而死:
PHP message: PHP Fatal error: Call to a member function appendChild() on a non-object in /path/libs/phpdocx/classes/CreateTemplate.inc on line 433
PHP message: PHP Stack trace:
PHP message: PHP 1. {main}() /path/script.php:0
PHP message: PHP 2. CreateDocx->addTemplate() /path/script.php:40
PHP message: PHP 3. CreateTemplate->openTemplate() /path/libs/phpdocx/classes/CreateDocx.inc:4119
PHP message: PHP 4. CreateTemplate::addRelationship() /path/libs/phpdocx/classes/CreateTemplate.inc:711" while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "POST /script.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php
我认为这是失败的,因为phpdocx期待一个MSWord文档。
谢谢!
答案 0 :(得分:0)
很抱歉,但这是不可能的,您的模板必须是docx文件。