當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。