问题描述
我目前正在使用 PHPWord
创建一个程序,该程序将加载、编辑和保存 Word 文件,该文件是由其他人创建的模板。
在那个程序中,我打算将模板 Word 文件属性中 Creator 的值从其他人更改为我的名字。
但是,我遇到了以下两个问题。
以下是当前代码。
<?PHP
require_once './PHPWord/vendor/autoload.PHP';
$template_file = 'sample.docx';
$file_path = "./".$template_file;
$PHPWord = new \PHPOffice\PHPWord\PHPWord();
$templateProcessor = new \PHPOffice\PHPWord\TemplateProcessor($file_path);
$creater_name = "Taro TANAKA";
$properties = $PHPword->getDocumentProperties();
$properties->setCreater($creater_name);
ob_end_clean();
$templateProcessor->save($file_path);
?>
我希望能够加载模板 Word 文件并设置属性。
(我不想每次都触摸更新的 Word 文件,所以我要求使用 PHPWord
的解决方案。)
感谢您的回复。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)