當前位置: 首頁>>代碼示例>>C#>>正文


C# UserModel.XWPFRun類代碼示例

本文整理匯總了C#中NPOI.XWPF.UserModel.XWPFRun的典型用法代碼示例。如果您正苦於以下問題:C# XWPFRun類的具體用法?C# XWPFRun怎麽用?C# XWPFRun使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


XWPFRun類屬於NPOI.XWPF.UserModel命名空間,在下文中一共展示了XWPFRun類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: XWPFSDTContent

 public XWPFSDTContent(CT_SdtContentBlock block, IBody part, IRunBody parent)
 {
     
     foreach (object o in block.Items)
     {
         if (o is CT_P)
         {
             XWPFParagraph p = new XWPFParagraph((CT_P)o, part);
             bodyElements.Add(p);
             paragraphs.Add(p);
         }
         else if (o is CT_Tbl)
         {
             XWPFTable t = new XWPFTable((CT_Tbl)o, part);
             bodyElements.Add(t);
             tables.Add(t);
         }
         else if (o is CT_SdtBlock)
         {
             XWPFSDT c = new XWPFSDT(((CT_SdtBlock)o), part);
             bodyElements.Add(c);
             contentControls.Add(c);
         }
         else if (o is CT_R)
         {
             XWPFRun run = new XWPFRun((CT_R)o, parent);
             runs.Add(run);
             bodyElements.Add(run);
         }
     }
 }
開發者ID:mdjasim,項目名稱:npoi,代碼行數:31,代碼來源:XWPFSDTContent.cs

示例2: TestSetGetItalic

        public void TestSetGetItalic()
        {
            CT_RPr rpr = ctRun.AddNewRPr();
            rpr.AddNewI().val = (ST_OnOff.True);

            XWPFRun run = new XWPFRun(ctRun, p);
            Assert.AreEqual(true, run.IsItalic());

            run.SetItalic(false);
            Assert.AreEqual(ST_OnOff.False, rpr.i.val);
        }
開發者ID:xiepeixing,項目名稱:npoi,代碼行數:11,代碼來源:TestXWPFRun.cs

示例3: TestSetGetItalic

        public void TestSetGetItalic()
        {
            CT_RPr rpr = ctRun.AddNewRPr();
            rpr.AddNewI().val = true;

            XWPFRun run = new XWPFRun(ctRun, p);
            Assert.AreEqual(true, run.IsItalic);

            run.IsItalic = false;
            Assert.AreEqual(false, rpr.i.val);
        }
開發者ID:newlysoft,項目名稱:npoi,代碼行數:11,代碼來源:TestXWPFRun.cs

示例4: TestSetGetBold

        public void TestSetGetBold()
        {
            CT_RPr rpr = ctRun.AddNewRPr();
            rpr.AddNewB().val = true;

            XWPFRun run = new XWPFRun(ctRun, p);
            Assert.AreEqual(true, run.IsBold);

            run.IsBold = (false);
            Assert.AreEqual(false, run.IsBold);
            Assert.AreEqual(false, rpr.b.val);
        }
開發者ID:newlysoft,項目名稱:npoi,代碼行數:12,代碼來源:TestXWPFRun.cs

示例5: TestSetGetText

        public void TestSetGetText()
        {
            ctRun.AddNewT().Value = ("TEST STRING");
            ctRun.AddNewT().Value = ("TEST2 STRING");
            ctRun.AddNewT().Value = ("TEST3 STRING");

            Assert.AreEqual(3, ctRun.SizeOfTArray());
            XWPFRun run = new XWPFRun(ctRun, p);

            Assert.AreEqual("TEST2 STRING", run.GetText(1));

            run.SetText("NEW STRING", 0);
            Assert.AreEqual("NEW STRING", run.GetText(0));

            //Run.Text=("xxx",14);
            //Assert.Fail("Position wrong");
        }
開發者ID:newlysoft,項目名稱:npoi,代碼行數:17,代碼來源:TestXWPFRun.cs

示例6: TestAddCarriageReturn

        public void TestAddCarriageReturn()
        {
            ctRun.AddNewT().Value = ("TEST STRING");
            ctRun.AddNewCr();
            ctRun.AddNewT().Value = ("TEST2 STRING");
            ctRun.AddNewCr();
            ctRun.AddNewT().Value = ("TEST3 STRING");
            Assert.AreEqual(2, ctRun.SizeOfCrArray());

            XWPFRun run = new XWPFRun(new CT_R(), p);
            run.SetText("T1");
            run.AddCarriageReturn();
            run.AddCarriageReturn();
            run.SetText("T2");
            run.AddCarriageReturn();
            Assert.AreEqual(3, run.GetCTR().GetCrList().Count);
        }
開發者ID:hanwangkun,項目名稱:npoi,代碼行數:17,代碼來源:TestXWPFRun.cs

示例7: TestAddPageBreak

        public void TestAddPageBreak()
        {
            ctRun.AddNewT().Value = ("TEST STRING");
            ctRun.AddNewBr();
            ctRun.AddNewT().Value = ("TEST2 STRING");
            CT_Br breac = ctRun.AddNewBr();
            breac.clear = (ST_BrClear.left);
            ctRun.AddNewT().Value = ("TEST3 STRING");
            Assert.AreEqual(2, ctRun.SizeOfBrArray());

            XWPFRun run = new XWPFRun(new CT_R(), p);
            run.SetText("TEXT1");
            run.AddBreak();
            run.SetText("TEXT2");
            run.AddBreak(BreakType.TEXTWRAPPING);
            Assert.AreEqual(2, run.GetCTR().SizeOfBrArray());
        }
開發者ID:hanwangkun,項目名稱:npoi,代碼行數:17,代碼來源:TestXWPFRun.cs

示例8: TestAddTabsAndLineBreaks

        public void TestAddTabsAndLineBreaks()
        {
            ctRun.AddNewT().Value=("TEST STRING");
            ctRun.AddNewCr();
            ctRun.AddNewT().Value = (/*setter*/"TEST2 STRING");
            ctRun.AddNewTab();
            ctRun.AddNewT().Value = (/*setter*/"TEST3 STRING");
            Assert.AreEqual(1, ctRun.SizeOfCrArray());
            Assert.AreEqual(1, ctRun.SizeOfTabArray());

            XWPFRun run = new XWPFRun(new CT_R(), p);
            run.SetText("T1");
            run.AddCarriageReturn();
            run.SetText("T2");
            run.AddTab();
            run.SetText("T3");
            Assert.AreEqual(1, run.GetCTR().GetCrList().Count);
            Assert.AreEqual(1, run.GetCTR().GetTabList().Count);

            Assert.AreEqual("T1\nT2\tT3", run.ToString());
        }
開發者ID:newlysoft,項目名稱:npoi,代碼行數:21,代碼來源:TestXWPFRun.cs

示例9: TestSetGetColor

 public void TestSetGetColor()
 {
     XWPFRun run = new XWPFRun(ctRun, p);
     run.SetColor("0F0F0F");
     String clr = run.GetColor();
     Assert.AreEqual("0F0F0F", clr);
 }
開發者ID:newlysoft,項目名稱:npoi,代碼行數:7,代碼來源:TestXWPFRun.cs

示例10: TestSetGetTextForegroundBackground

        public void TestSetGetTextForegroundBackground()
        {
            CT_RPr rpr = ctRun.AddNewRPr();
            rpr.AddNewPosition().val = "4000";

            XWPFRun run = new XWPFRun(ctRun, p);
            Assert.AreEqual(4000, run.GetTextPosition());

            run.SetTextPosition(2400);
            Assert.AreEqual(2400, int.Parse(rpr.position.val));
        }
開發者ID:newlysoft,項目名稱:npoi,代碼行數:11,代碼來源:TestXWPFRun.cs

示例11: TestSetGetFontSize

        public void TestSetGetFontSize()
        {
            CT_RPr rpr = ctRun.AddNewRPr();
            rpr.AddNewSz().val = 14;

            XWPFRun run = new XWPFRun(ctRun, p);
            Assert.AreEqual(7, run.FontSize);

            run.FontSize = (24);
            Assert.AreEqual(48, (int)rpr.sz.val);
        }
開發者ID:newlysoft,項目名稱:npoi,代碼行數:11,代碼來源:TestXWPFRun.cs

示例12: TestRuns

        public void TestRuns()
        {
            XWPFDocument doc = new XWPFDocument();
            XWPFParagraph p = doc.CreateParagraph();

            CT_R run = new CT_R();
            XWPFRun r = new XWPFRun(run, doc.CreateParagraph());
            p.AddRun(r);
            p.AddRun(r);

            Assert.IsNotNull(p.GetRun(run));
            Assert.IsNull(p.GetRun(null));
        }
開發者ID:newlysoft,項目名稱:npoi,代碼行數:13,代碼來源:TestXWPFParagraph.cs

示例13: AddRun

 /**
  * Adds a new Run to the Paragraph
  * 
  * @param r
  */
 public void AddRun(XWPFRun r)
 {
     if (!runs.Contains(r))
     {
         runs.Add(r);
     }
 }
開發者ID:hjlfmy,項目名稱:npoi,代碼行數:12,代碼來源:XWPFParagraph.cs

示例14: TestSetGetStrike

        public void TestSetGetStrike()
        {
            CT_RPr rpr = ctRun.AddNewRPr();
            rpr.AddNewStrike().val = true;

            XWPFRun run = new XWPFRun(ctRun, p);
            Assert.AreEqual(true, run.IsStrike);

            run.SetStrike(false);
            Assert.AreEqual(false, rpr.strike.val);
        }
開發者ID:newlysoft,項目名稱:npoi,代碼行數:11,代碼來源:TestXWPFRun.cs

示例15: BuildRunsInOrderFromXml

        /**
         * Identifies (in order) the parts of the paragraph /
         *  sub-paragraph that correspond to character text
         *  runs, and builds the appropriate runs for these.
         */
        private void BuildRunsInOrderFromXml(ArrayList items)
        {
            foreach (object o in items)
            {
                if (o is CT_R)
                {
                    XWPFRun r = new XWPFRun((CT_R)o, this);
                    runs.Add(r);
                    iRuns.Add(r);
                }
                if (o is CT_Hyperlink1)
                {
                    CT_Hyperlink1 link = (CT_Hyperlink1)o;
                    foreach (CT_R r in link.GetRList())
                    {
                        //runs.Add(new XWPFHyperlinkRun(link, r, this));
                        XWPFHyperlinkRun hr = new XWPFHyperlinkRun(link, r, this);
                        runs.Add(hr);
                        iRuns.Add(hr);

                    }
                }
                if (o is CT_SdtBlock)
                {
                    XWPFSDT cc = new XWPFSDT((CT_SdtBlock)o, part);
                    iRuns.Add(cc);
                }
                if (o is CT_SdtRun)
                {
                    XWPFSDT cc = new XWPFSDT((CT_SdtRun)o, part);
                    iRuns.Add(cc);
                }
                if (o is CT_RunTrackChange)
                {
                    foreach (CT_R r in ((CT_RunTrackChange)o).GetRList())
                    {
                        XWPFRun cr = new XWPFRun(r, this);
                        runs.Add(cr);
                        iRuns.Add(cr);
                    }
                }
                if (o is CT_SimpleField)
                {
                    foreach (CT_R r in ((CT_SimpleField)o).GetRList())
                    {
                        XWPFRun cr = new XWPFRun(r, this);
                        runs.Add(cr);
                        iRuns.Add(cr);
                    }
                }
                if (o is CT_SmartTagRun)
                {
                    // Smart Tags can be nested many times. 
                    // This implementation does not preserve the tagging information
                    BuildRunsInOrderFromXml((o as CT_SmartTagRun).Items);
                }
            }
        }
開發者ID:htlp,項目名稱:npoi,代碼行數:63,代碼來源:XWPFParagraph.cs


注:本文中的NPOI.XWPF.UserModel.XWPFRun類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。