gpt4 book ai didi

excel - 这是 Excel 处理 Office Open XML 元数据中的错误吗?

转载 作者:行者123 更新时间:2023-12-04 20:47:17 24 4
gpt4 key购买 nike

似乎 Excel 对可以与单元格关联的元数据的处理已损坏,但我很想知道是否有其他人尝试(成功或其他方式)使用此功能。

由于似乎没有办法报告针对 Excel 的错误,我已经发布了对问题的完整描述,并在此处重现它的代码:
http://social.technet.microsoft.com/Forums/en-US/excel/thread/c7f9747a-1d03-4415-97d4-d9aa58b4d240但我会重复重要的细节。

简而言之,Excel 似乎正在删除并错误地重新索引我以编程方式与单元格关联的元数据。

一、对规范相关部分的总结:

从 OOXML 18.9 开始:有两种类型的元数据:“单元元数据”和“值元数据”。

单元元数据跟随单元移动。值(value)元数据通过公式等遵循值(value)。

从 OOXML 18.3.1.4 开始:c(单元格)元素具有 cm 和 vm 属性,它们都记录为“元数据部分中 [cell|value] 元数据的从零开始的索引...”

从 OOXML 18.9.17 开始:valueMetadata 是“ block 元素的集合,每个元素都定义了特定单元格的值元数据”。 “工作簿中的单元格索引到此集合中”。

valueMetadata 包含 bk 元素,而 bk 元素又包含 rc(元数据记录)元素

从 OOXML 18.9.15 开始:rc 元素具有 t(类型索引)和 v(值索引)属性。 t 是 metadataTypes 从 1 开始的索引,v 是 futureMetadata 元素中从 0 开始的索引,它与元数据类型的名称匹配。

这是一个可能看起来像的示例:

...
<c vm="0"> <!-- vm points to the first bk inside valueMetadata below -->
...
<x:valueMetadata>
<x:bk>
<x:rc t="1" v="0" /> <!-- t points to the first metadataType below. v points to the first bk in the futureMetadata below (whose name matches the metadataType to which t points) -->
</x:bk>
</x:valueMetadata>
...
<x:metadataTypes>
<x:metadataType name="MyMetaType" ... /> <!-- name dictates which futureMetadata valueMetadata's v attribute indexes into -->
</x:metadataTypes>
...
<x:futureMetadata name="MyMetaType" ...>
<x:bk>
<x:extLst>
<x:ext xmlns:x="http://schemas.openxmlformats.org/spreadsheetml/2006/main" uri="http://example.com/extension" p5:value="test value" xmlns:p5="http://example.com/extension" />
</x:extLst>
</x:bk>
</x:futureMetadata>
...

问题

据我所知,对于 n > 2 的值,如果您将 n 个单元格与元数据相关联,Excel 将删除最后一段元数据,以及索引为 1 的元数据,它会默默地这样做。然后索引为 0..n-3,除了第一个(0 索引)之外的所有关联都是错误的。这使得 future 的元数据完全无用。

对于 n == 1,Excel 仅删除最后一段元数据(索引 1)。如果我们为 c 元素的 vm 属性尝试从 1 开始的索引,我们会得到不同的行为。这可能不相关,因为它与规范相反,但稍微好一点的行为可能表示一个错误:
n    Deleted Indices (0-based)     Deleted Indices (0-based) 
when using 0-based indices when using 1-based indices
1 0 None
2 1 1
3 1,2 1
4 1,3 1
5 1,4 1
6 1,5 1

最佳答案

来自 here 的合适解决方法.

Bit late to the party but only recently started using OpenXML. Easiest fix is to avoid Metadata and just use extension lists. They can be customised and applied at the cell level.



因此,您不必摆弄元数据部分,您可以编写它来避免问题,您提到:
<c>
<extLst>
<ext uri="http://example.com/extension" p5:value="test value" xmlns:p5="http://example.com/extension">
<p5:anotherValue>127</p:anotherValue>
</ext>
</extLst>
</c>

关于excel - 这是 Excel 处理 Office Open XML 元数据中的错误吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10348114/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com