使用 Office Open XML 重复内容

发布于 2024-09-25 22:31:42 字数 1152 浏览 1 评论 0原文

我一直在研究 Office Open XML 文档规范的可能性。我对能够将自定义 XML 内容添加到文档并将其绑定到内容控件特别感兴趣。我想知道是否可以有重复的内容控制类型?

例如,假设我的 .docx 文件中有一些自定义 XML,如下所示:

<Work>
  .
  .
  <People>
    <Person>
      <Name>Jane Doe</Name>
      <EmailAddress>[email protected]</EmailAddress>
    </Person>
    <Person>
      <Name>John Doe</Name>
      <EmailAddress>[email protected]</EmailAddress>
    </Person>
  </People>
</Work>

是否有任何重复内容控件(类似于 ASP 转发器),我可以使用它来生成类似于

如果没有类型的控件,我想我可以对word文档本身进行一些处理以生成一个列表。有没有人这样做过并有一些有用的指示?

I've been checking out what is possible with the Office Open XML specification for documents. I'm particularly interested in being able to add custom XML content to a document and binding it to content controls. I was wondering if it is possible to have a repeating content control type?

For example, say I have some custom XML in my .docx file that looks like so:

<Work>
  .
  .
  <People>
    <Person>
      <Name>Jane Doe</Name>
      <EmailAddress>[email protected]</EmailAddress>
    </Person>
    <Person>
      <Name>John Doe</Name>
      <EmailAddress>[email protected]</EmailAddress>
    </Person>
  </People>
</Work>

Is there any repeating content control (similar to an ASP repeater) that I could use to generate output that looks something like

If there are no types of controls, I guess I could do some processing on the word document itself to generate a list. Has anyone done this and have some helpful pointers?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

归属感 2024-10-02 22:31:42

正如 0xA3 所说,没有这样的内置内容,它将由 WordprocessingML 操作。但以下是从数据库中提取数据以创建多个条目的示例: 将数据从数据库推送到 Word 文档

另外,关于一般数据绑定主题,这里有一个很好的入门教程:将 Word 2007 内容控件链接到自定义 XML

As 0xA3 says, there is nothing built-in like this, it would be WordprocessingML-manipulated. But here is an example of pulling data from a database to create multiple entries: Pushing Data from a Database into a Word Document.

Also, on the subject of databinding in general, here is a good starter tutorial: Linking Word 2007 Content Controls to Custom XML.

当梦初醒 2024-10-02 22:31:42

Word 2013 对内容控件进行了一些改进。包括重复内容控制。我还没有测试过。

http://msdn.microsoft.com/en-us/library /office/jj889465.aspx#WordCC_RepeatingSection

对于 Word 2007 和 2010,您必须执行一些额外处理来创建具有内容控制的行,并将它们与生成的 Xpath 查询绑定。您可以查看以下视频。

With Word 2013, there are some improvement for content controls. Including a repeating content control. I haven't test it.

http://msdn.microsoft.com/en-us/library/office/jj889465.aspx#WordCC_RepeatingSection

With Word 2007 and 2010, you have to do some extraprocessing for creating rows with content control and bind them with generated Xpath query. You can check the following video.

http://www.microsoft.com/uk/msdn/screencasts/screencast/261/Office-Open-XML-Content-Controls-and-Repeating-Data-Part-1-of-3.aspx

http://dev.plutext.org/svn /docx4j/trunk/docx4j/sample-docs/databinding/conventions.html 提出了执行此操作的约定。您确实需要预处理 docx 来克隆内容控件 n 次;目前有代码可以通过 Word 宏或 Java (docx4j) 来执行此操作。

http://dev.plutext.org/svn/docx4j/trunk/docx4j/sample-docs/databinding/conventions.html proposes a convention for doing this. You do need to pre-process the docx to clone the content control n times; currently there is code for doing this via a Word macro, or in Java (docx4j).

孤凫 2024-10-02 22:31:42

Word 2007/2010 中没有用于重复内容的内置内容控件。但我想到了以下可能性:

  • 使​​用 Open XML SDK 以编程方式创建完整内容。但没有数据绑定。
  • 使用Word 的MailMerge 功能来显示多个相似的数据集。
  • 使用 InfoPath,它对重复内容有更好的支持
  • 使用第三方解决方案,例如 Windward Reports。

更新:Word 2013 现在具有用于重复部分的内容控件。

There is no built-in Content Control for repeating content in Word 2007/2010. The following possibilities come to my mind though:

  • Create the full content programmatically using the Open XML SDK. No databinding though.
  • Use Word's MailMerge feature for displaying several similar data sets.
  • Use InfoPath which has better support for repeating content
  • Use a third-party solution such as Windward Reports.

Update: Word 2013 now has a content control for repeating sections.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文