xml - OOXML : How is a table header (heading) encoded?

标签 xml openxml document xmldocument

我在 Word 2007 中创建了两个文档。它们都是空表。一个选中了“标题”选项。我无法确定切换 header 的两个文档之间有什么不同。

我能发现的唯一不同之处是 w:tblLook 元素上的 w:val 属性。在标题开关打开的情况下,它在文档上设置为 04A0。如果不勾选“航向”选项,该值为 0480。

文档指出 w:val 的有效值为:

0×0020  Apply first row conditional formatting
0×0040  Apply last row conditional formatting
0×0080  Apply first column conditional formatting
0×0100  Apply last column conditional formatting
0×0200  Do not apply row banding conditional formatting
0×0400  Do not apply column banding conditional formatting

因此,这个数字似乎表明在位掩码中设置了 32、128 和 1024。

这意味着设置了以下内容:

0×0400  Do not apply column banding conditional formatting
0×0080  Apply first column conditional formatting
0×0020  Apply first row conditional formatting

鉴于 0x0400 和 0x0080 似乎无关紧要,这是关键吗?:

0×0020  Apply first row conditional formatting

最佳答案

是的,0x0020(应用第一行条件格式)是 “标题”选项的键。

w:tblLook 元素的 w:val 属性是所谓的 过渡迁移功能,只应在文档中使用 过渡一致性类(MS Word 2007 生成此类文档)。

请参阅 ECMA Office Open XML 第 4 部分 - 过渡迁移特征规范

了解更多信息。 第 14.3.11 段 描述了 w:tblLook 的附加属性 (w:val)。 您可以在此处下载规范 ECMA .使用 ECMA-376 第 4 版第 4 部分链接。

在新版本的 Microsoft Office (> 2007) 中,仅使用 w:val 属性 为了向后兼容。有一个名为 w:firstRow="1" 的新属性,用于 0x0020 值(第一行条件格式)。请参阅以下链接 MSDN获取有关 w:firstRow 属性的更多信息。

如果将 MS Word 2007 文档与 MS Word 2010/2013 文档进行比较,您会发现 MS Word 2007 仅使用 w:val 属性,而 MS Word 2010/2013 使用 w:val和 属性 w:firstColumn, w:firstRow, w:lastRow, lastColumn, w:noHBand, w:noVBand

如果您在“严格打开 XML 文档”模式下保存 word 文档 (MS Word 2013),w:val 属性将被转换为 w:firstColumn、w:firstRow、w:lastRow、lastColumn、w:noHBand 和 w:noVBand 属性(因为新的严格文档不应使用 w:val)。

关于xml - OOXML : How is a table header (heading) encoded?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23134215/

相关文章:

Javascript:从具有相同标签名称的两个 XML 节点检索数据的可靠方法是什么?

c# - 使用 XML 文件中的数据生成 Word 文档 (docx)/基于模板将 XML 转换为 Word 文档

java - 如何在 Xerces 中使用语法验证文档

java - HttpClient 4.1.x 的文档在哪里?

python - Django同时发送xml请求

jquery - 如何使用 JQuery 获取属性等于某个值的所有节点?

.net - 如何通过 OpenXML 从 Excel 工作簿中删除/删除 ExtensionList?

ms-word - Word/OpenXML - 如何创建隐藏书签?

solr - 使用 Solr 索引文档的最佳策略

xml - 使用带有 XPATH 的 vb.net 读取 XML 属性