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


C# XWPFParagraph.GetText方法代码示例

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


在下文中一共展示了XWPFParagraph.GetText方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: XWPFTable

        public XWPFTable(CT_Tbl table, IBody part)
        {
            this.part = part;
            this.ctTbl = table;

            tableRows = new List<XWPFTableRow>();
            // is an empty table: I add one row and one column as default
            if (table.SizeOfTrArray() == 0)
                CreateEmptyTable(table);

            foreach (CT_Row row in table.GetTrList()) {
                StringBuilder rowText = new StringBuilder();
                row.Table = table;
                XWPFTableRow tabRow = new XWPFTableRow(row, this);
                tableRows.Add(tabRow);
                foreach (CT_Tc cell in row.GetTcList()) {
                    cell.TableRow = row;
                    foreach (CT_P ctp in cell.GetPList()) {
                        XWPFParagraph p = new XWPFParagraph(ctp, part);
                        if (rowText.Length > 0) {
                            rowText.Append('\t');
                        }
                        rowText.Append(p.GetText());
                    }
                }
                if (rowText.Length > 0) {
                    this.text.Append(rowText);
                    this.text.Append('\n');
                }
            }
        }
开发者ID:hanwangkun,项目名称:npoi,代码行数:31,代码来源:XWPFTable.cs

示例2: XWPFComment

        public XWPFComment(CT_Comment comment, XWPFDocument document)
        {
            text = new StringBuilder();
            id = comment.id.ToString();
            author = comment.author;

            foreach(CT_P ctp in comment.GetPList())
            {
                XWPFParagraph p = new XWPFParagraph(ctp, document);
                text.Append(p.GetText());
            }
        }
开发者ID:hanwangkun,项目名称:npoi,代码行数:12,代码来源:XWPFComment.cs

示例3: TestExisting

        public void TestExisting()
        {
            XWPFDocument doc = XWPFTestDataSamples.OpenSampleDocument("TestDocument.docx");
            XWPFParagraph p;
            XWPFRun run;


            // First paragraph is simple
            p = doc.GetParagraphArray(0);
            Assert.AreEqual("This is a test document.", p.GetText());
            Assert.AreEqual(2, p.Runs.Count);

            run = p.Runs[0];
            Assert.AreEqual("This is a test document", run.ToString());
            Assert.AreEqual(false, run.IsBold);
            Assert.AreEqual(false, run.IsItalic);
            Assert.AreEqual(false, run.IsStrike);
            Assert.AreEqual(null, run.GetCTR().rPr);

            run = p.Runs[1];
            Assert.AreEqual(".", run.ToString());
            Assert.AreEqual(false, run.IsBold);
            Assert.AreEqual(false, run.IsItalic);
            Assert.AreEqual(false, run.IsStrike);
            Assert.AreEqual(null, run.GetCTR().rPr);


            // Next paragraph is all in one style, but a different one
            p = doc.GetParagraphArray(1);
            Assert.AreEqual("This bit is in bold and italic", p.GetText());
            Assert.AreEqual(1, p.Runs.Count);

            run = p.Runs[0];
            Assert.AreEqual("This bit is in bold and italic", run.ToString());
            Assert.AreEqual(true, run.IsBold);
            Assert.AreEqual(true, run.IsItalic);
            Assert.AreEqual(false, run.IsStrike);
            Assert.AreEqual(true, run.GetCTR().rPr.IsSetB());
            Assert.AreEqual(false, run.GetCTR().rPr.b.IsSetVal());


            // Back to normal
            p = doc.GetParagraphArray(2);
            Assert.AreEqual("Back to normal", p.GetText());
            Assert.AreEqual(1, p.Runs.Count);

            run = p.Runs[(0)];
            Assert.AreEqual("Back to normal", run.ToString());
            Assert.AreEqual(false, run.IsBold);
            Assert.AreEqual(false, run.IsItalic);
            Assert.AreEqual(false, run.IsStrike);
            Assert.AreEqual(null, run.GetCTR().rPr);


            // Different styles in one paragraph
            p = doc.GetParagraphArray(3);
            Assert.AreEqual("This contains BOLD, ITALIC and BOTH, as well as RED and YELLOW text.", p.GetText());
            Assert.AreEqual(11, p.Runs.Count);

            run = p.Runs[(0)];
            Assert.AreEqual("This contains ", run.ToString());
            Assert.AreEqual(false, run.IsBold);
            Assert.AreEqual(false, run.IsItalic);
            Assert.AreEqual(false, run.IsStrike);
            Assert.AreEqual(null, run.GetCTR().rPr);

            run = p.Runs[(1)];
            Assert.AreEqual("BOLD", run.ToString());
            Assert.AreEqual(true, run.IsBold);
            Assert.AreEqual(false, run.IsItalic);
            Assert.AreEqual(false, run.IsStrike);

            run = p.Runs[2];
            Assert.AreEqual(", ", run.ToString());
            Assert.AreEqual(false, run.IsBold);
            Assert.AreEqual(false, run.IsItalic);
            Assert.AreEqual(false, run.IsStrike);
            Assert.AreEqual(null, run.GetCTR().rPr);

            run = p.Runs[(3)];
            Assert.AreEqual("ITALIC", run.ToString());
            Assert.AreEqual(false, run.IsBold);
            Assert.AreEqual(true, run.IsItalic);
            Assert.AreEqual(false, run.IsStrike);

            run = p.Runs[(4)];
            Assert.AreEqual(" and ", run.ToString());
            Assert.AreEqual(false, run.IsBold);
            Assert.AreEqual(false, run.IsItalic);
            Assert.AreEqual(false, run.IsStrike);
            Assert.AreEqual(null, run.GetCTR().rPr);

            run = p.Runs[(5)];
            Assert.AreEqual("BOTH", run.ToString());
            Assert.AreEqual(true, run.IsBold);
            Assert.AreEqual(true, run.IsItalic);
            Assert.AreEqual(false, run.IsStrike);

            run = p.Runs[(6)];
            Assert.AreEqual(", as well as ", run.ToString());
//.........这里部分代码省略.........
开发者ID:WendaoChen,项目名称:npoi,代码行数:101,代码来源:TestXWPFRun.cs


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