我有一个从 Excel 电子表格生成的 xml 文件。 此 xml 表示电子表格的行和列。
例如:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<data-set xmlns="dummy.xsd">
<record>
<LastName>Smith</LastName>
<Sales>16753</Sales>
<Country>UK</Country>
<Quarter>Qtr 3</Quarter>
</record>
<record>
<LastName>Johnson</LastName>
<Sales>14808</Sales>
<Country>USA</Country>
<Quarter>Qtr 4</Quarter>
</record>
<record>
<LastName>Williams</LastName>
<Sales>10644</Sales>
<Country>UK</Country>
<Quarter>Qtr 2</Quarter>
</record>
<data-set>
我希望能够遍历每一行并将它的每一部分显示到一个单词组件中,以便我可以用单词格式对其进行格式化。
所以我会有类似的东西(使用 [[..]] 符号化组件和重复结构)
[[
[[
[[Lastname]] - [[Sales]] - [[Contry]] - [[Repeat]]
]]
[[
[[Lastname]] - [[Sales]] - [[Contry]] - [[Repeat]]
]]
]]
我已经打开了开发人员面板,并使用 XML 映射的(添加新部分...) 函数加载我的 xml > Pane 。
当我右键单击 XML 层次结构的标记并执行 *Insert Content Control > Repeating"时,这会创建一个包含以下文本的单词组件:
"Enter any content that you want to repeat, including other content controls. You can also insert this control around table rows in order to repeat parts of a table."
如果我在其中放入一些记录字段,它(Insert Content Control > PlainText)表明:
"Plain text controls cannot be inserted aroud the current selection"
我还尝试在 *Developer > Add-Ins > XML Schema > Add Schema 中放置一个模式”
最佳答案
我终于做到了:
- 激活“功能区”中的“开发人员 Pane ”
- 打开“XML 映射面板”
- 选择“开发人员 > XML 映射 > 自定义 XML 部分 > 添加新部分 (...)”并选择 XML
- 然后在“Custom XML Part”列表中选择 XML 文件,然后右键单击列表中的一个项目并选择“Insert Content Control > Repeating” 这应该在文档中创建一种“双标签”
- 然后,不要激活“设计模式”(“开发者 > 设计模式”)(否则它会报错)
- 将鼠标光标置于页面中已创建的“双标签”内(在“输入您要重复的任何内容,包括其他内容控件”的位置。您也可以在表格行周围插入此控件为了重复表格的某些部分。")
- 然后右键单击“XML 映射 Pane ”中的项目字段,然后选择“插入内容控件 > 纯文本” 这将创建一个新的“单标签”,代表单词页面中的字段(嵌套在代表“foreach”的“双标签”中)
- 关闭设计模式(如果需要,再打开和关闭)。项目应显示并包含插入的字段
唯一的问题是它非常慢。我试图映射一个 100 行的 XML(只有 2 列)并且花了将近 5 分钟。
关于xml - 将 XML 列表映射到 Word 重复组件 (Word 2013),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28450586/