在OpenXml中向表或图添加标题 [英] Add a Caption to a Table or Figure in OpenXml

查看:152
本文介绍了在OpenXml中向表或图添加标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在OpenXml中创建此结构:

I'm trying to create this structure in OpenXml:

<P>
 <Table />
 <Caption>Table 1 - Some Text 1 </Caption>
 <Picture />
 <Caption>Figure 1 - Some Text 2 </Caption>
</P>

在代码方面,我有:

var currentLine = new Paragraph();
currentLine.AppendChild(new Run(elem));  -> Where the elem is Table
...
currentLine.AppendChild(new Run(elem2)); -> Where the elem2 is Drawing

所以我只想念添加字幕的方式,就像我在MS Word References-> Insert Caption中所做的一样.

So I only miss the way to add captions, the same captions that I can do in MS Word References-> Insert Caption.

一些有关如何完成此操作的信息将不胜感激.

Some information how to accomplish this would be very appreciated.

推荐答案

使用此方法: http://www.microsoft.com/zh-cn/download/details.aspx?id=5124

(生产力工具)-检查word文档并查看其组成.

(Productivity tool) - to inspect word document and see what they are made up of.

在这里输入代码:

 SimpleField sf = new SimpleField(new Run(new Text("Figure 1")));

要实际链接任何内容,您需要设置sfinstruction属性.

To actually link anything, you need to set sf's instruction property.

这篇关于在OpenXml中向表或图添加标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆