2 回答
TA贡献1864条经验 获得超2个赞
我可以使用以下代码更新 custom.xml:
$zip = new \ZipArchive;
// Open this Zip File
if ($zip->open('helloWorld.docx') == true) {
// Get custom xml content
$xmlContent = $zip->getFromName('docProps/custom.xml');
// Update docPros/custom.xml content
$updatedXmlContent = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Properties
xmlns="http://schemas.openxmlformats.org/officeDocument/2006/custom-properties"
xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">
<property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="2" name="Id">
<vt:lpwstr>121</vt:lpwstr>
</property>
<property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="3" name="Notes">
<vt:lpwstr>Lorem ipsum</vt:lpwstr>
</property>
<property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="4" name="User">
<vt:lpwstr>12</vt:lpwstr>
</property>
</Properties>';
//Replace the content with the new content created above.
$zip->addFromString('docProps/custom.xml', $updatedXmlContent);
$zip->close();
}
TA贡献1796条经验 获得超4个赞
- 2 回答
- 0 关注
- 165 浏览
添加回答
举报