本文整理汇总了C#中NPOI.XWPF.UserModel.XWPFDocument.GetEndnoteByID方法的典型用法代码示例。如果您正苦于以下问题:C# XWPFDocument.GetEndnoteByID方法的具体用法?C# XWPFDocument.GetEndnoteByID怎么用?C# XWPFDocument.GetEndnoteByID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NPOI.XWPF.UserModel.XWPFDocument
的用法示例。
在下文中一共展示了XWPFDocument.GetEndnoteByID方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: XWPFParagraph
public XWPFParagraph(CT_P prgrph, IBody part)
{
this.paragraph = prgrph;
this.part = part;
this.document = part.GetXWPFDocument();
if (document == null)
{
throw new NullReferenceException();
}
// Build up the character runs
runs = new List<XWPFRun>();
BuildRunsInOrderFromXml(paragraph.Items);
// Look for bits associated with the runs
foreach (XWPFRun run in runs)
{
CT_R r = run.GetCTR();
if (document != null)
{
foreach (object o in r.Items)
{
if (o is CT_FtnEdnRef)
{
CT_FtnEdnRef ftn = (CT_FtnEdnRef)o;
footnoteText.Append("[").Append(ftn.id).Append(": ");
XWPFFootnote footnote = document.GetFootnoteByID(int.Parse(ftn.id));
if (footnote == null)
footnote = document.GetEndnoteByID(int.Parse(ftn.id));
//ftn.DomNode.LocalName.Equals("footnoteReference") ?
// document.GetFootnoteByID(ftn.Id.IntValue()) :
// document.GetEndnoteByID(ftn.Id.IntValue());
bool first = true;
foreach (XWPFParagraph p in footnote.Paragraphs)
{
if (!first)
{
footnoteText.Append("\n");
first = false;
}
footnoteText.Append(p.Text);
}
footnoteText.Append("]");
}
}
}
}
// Get all our child nodes in order, and process them
// into XWPFRuns where we can
/*XmlCursor c = paragraph.NewCursor();
c.SelectPath("child::*");
while (c.ToNextSelection()) {
XmlObject o = c.Object;
if(o is CT_R) {
Runs.Add(new XWPFRun((CT_R)o, this));
}
if(o is CT_Hyperlink) {
CT_Hyperlink link = (CT_Hyperlink)o;
foreach(CTR r in link.RList) {
Runs.Add(new XWPFHyperlinkRun(link, r, this));
}
}
if(o is CT_SdtRun) {
CT_SdtContentRun run = ((CT_SdtRun)o).SdtContent;
foreach(CTR r in Run.RList) {
Runs.Add(new XWPFRun(r, this));
}
}
if(o is CT_RunTrackChange) {
foreach(CTR r in ((CT_RunTrackChange)o).RList) {
Runs.Add(new XWPFRun(r, this));
}
}
if(o is CT_SimpleField) {
foreach(CTR r in ((CT_SimpleField)o).RList) {
Runs.Add(new XWPFRun(r, this));
}
}
}*/
}
示例2: XWPFParagraph
public XWPFParagraph(CT_P prgrph, IBody part)
{
this.paragraph = prgrph;
this.part = part;
this.document = part.GetXWPFDocument();
if (document == null)
{
throw new NullReferenceException();
}
// Build up the character runs
runs = new List<XWPFRun>();
iRuns = new List<IRunElement>();
BuildRunsInOrderFromXml(paragraph.Items);
// Look for bits associated with the runs
foreach (XWPFRun run in runs)
{
CT_R r = run.GetCTR();
if (document != null)
{
for (int i = 0; i < r.Items.Count; i++)
{
object o = r.Items[i];
if (o is CT_FtnEdnRef)
{
CT_FtnEdnRef ftn = (CT_FtnEdnRef)o;
footnoteText.Append("[").Append(ftn.id).Append(": ");
XWPFFootnote footnote = null;
if (r.ItemsElementName.Count > i && r.ItemsElementName[i] == RunItemsChoiceType.endnoteReference)
{
footnote = document.GetEndnoteByID(int.Parse(ftn.id));
if (footnote == null)
footnote = document.GetFootnoteByID(int.Parse(ftn.id));
}
else
{
footnote = document.GetFootnoteByID(int.Parse(ftn.id));
if (footnote == null)
footnote = document.GetEndnoteByID(int.Parse(ftn.id));
}
if (footnote != null)
{
bool first = true;
foreach (XWPFParagraph p in footnote.Paragraphs)
{
if (!first)
{
footnoteText.Append("\n");
first = false;
}
footnoteText.Append(p.Text);
}
}
footnoteText.Append("]");
}
}
}
}
}