当前位置: 首页>>代码示例>>C#>>正文


C# XWPFDocument.GetFootnoteByID方法代码示例

本文整理汇总了C#中NPOI.XWPF.UserModel.XWPFDocument.GetFootnoteByID方法的典型用法代码示例。如果您正苦于以下问题:C# XWPFDocument.GetFootnoteByID方法的具体用法?C# XWPFDocument.GetFootnoteByID怎么用?C# XWPFDocument.GetFootnoteByID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NPOI.XWPF.UserModel.XWPFDocument的用法示例。


在下文中一共展示了XWPFDocument.GetFootnoteByID方法的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));
                  }
               }
            }*/
        }
开发者ID:hjlfmy,项目名称:npoi,代码行数:85,代码来源:XWPFParagraph.cs

示例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("]");
                        }
                    }
                }
            }
        }
开发者ID:htlp,项目名称:npoi,代码行数:65,代码来源:XWPFParagraph.cs


注:本文中的NPOI.XWPF.UserModel.XWPFDocument.GetFootnoteByID方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。