编辑和保存时,Excel(开放xml格式)不保留自定义xml文件

时间:2018-10-01 10:30:47

标签: excel xml openxml preserve

我已经实现了一些客户端代码,以zip格式打开excel(.xlsx)文件,将自定义xml文件(bla.xml)添加到“ docPops”文件夹中,并将其另存为.xlsx文件。即使我复制粘贴excel文件,也保留了自定义xml文件,但是一旦编辑并保存更改,自定义文件就消失了。

遵循此处(What is the best way to store XML data in an Excel file)(第一个答案的第五条评论)的解决方法,我在“ _rels”文件夹中的参考文件中添加了以下条目,

<Relationship Id="rId4" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties" Target="docProps/bla.xml"/>

以及[Content_Types] .xml文件中的以下条目

<Override PartName="/docProps/bla.xml" ContentType="application/vnd.openxmlformats-officedocument.extended-properties+xml"/>

这会使文件损坏。

我该如何正确实现?

(这样做的目的-将excel上传到系统时,我在bla.xml文件中添加了一个哈希键,这样,如果有人下载了先前上传的文件并尝试重新上传,我可以检查该哈希键和检测为重复)

0 个答案:

没有答案