我正在尝试在 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 参考资料 -> 插入标题中可以执行的标题相同。
一些如何实现这一点的信息将非常感激。
Rui
这是我用来创建字幕的方法。基本上,创建一个 SimpleField 并将其附加到段落中。
public Paragraph CreateCaption( string caption, string name )
{
Run run = new Run( new Text() { Text= name + " ", Space = SpaceProcessingModeValues.Preserve } );
SimpleField simpleField = new SimpleField( new Run( new RunProperties( new NoProof() ), new Text() { Text= " ", Space = SpaceProcessingModeValues.Preserve } ) );
simpleField.Instruction = @"SEQ " + name;
Run runLabel = new Run( new Text() { Text= " " + caption, Space = SpaceProcessingModeValues.Preserve } );
ParagraphProperties captionPr = new ParagraphProperties( new ParagraphStyleId() { Val = "Caption" } );
Paragraph paragraph = new Paragraph();
paragraph.ParagraphProperties = captionPr;
paragraph.Append( run );
paragraph.Append( simpleField );
paragraph.Append( runLabel );
return paragraph;
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)