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


C# HSSFWorkbook.FindFont方法代碼示例

本文整理匯總了C#中NPOI.HSSF.UserModel.HSSFWorkbook.FindFont方法的典型用法代碼示例。如果您正苦於以下問題:C# HSSFWorkbook.FindFont方法的具體用法?C# HSSFWorkbook.FindFont怎麽用?C# HSSFWorkbook.FindFont使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在NPOI.HSSF.UserModel.HSSFWorkbook的用法示例。


在下文中一共展示了HSSFWorkbook.FindFont方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Test45338

        public void Test45338()
        {
            HSSFWorkbook wb = new HSSFWorkbook();
            Assert.AreEqual(4, wb.NumberOfFonts);

            ISheet s = wb.CreateSheet();
            s.CreateRow(0);
            s.CreateRow(1);
            ICell c1 = s.GetRow(0).CreateCell(0);
            ICell c2 = s.GetRow(1).CreateCell(0);

            Assert.AreEqual(4, wb.NumberOfFonts);

            IFont f1 = wb.GetFontAt((short)0);
            Assert.AreEqual(400, f1.Boldweight);

            // Check that asking for the same font
            //  multiple times gives you the same thing.
            // Otherwise, our Tests wouldn't work!
            Assert.AreEqual(
                    wb.GetFontAt((short)0),
                    wb.GetFontAt((short)0)
            );
            Assert.AreEqual(
                    wb.GetFontAt((short)2),
                    wb.GetFontAt((short)2)
            );
            Assert.IsTrue(
                    wb.GetFontAt((short)0)
                    !=
                    wb.GetFontAt((short)2)
            );

            // Look for a new font we have
            //  yet to Add
            Assert.IsNull(
                wb.FindFont(
                    (short)11, (short)123, (short)22,
                    "Thingy", false, true, (short)2, (byte)2
                )
            );

            IFont nf = wb.CreateFont();
            Assert.AreEqual(5, wb.NumberOfFonts);

            Assert.AreEqual(5, nf.Index);
            Assert.AreEqual(nf, wb.GetFontAt((short)5));

            nf.Boldweight = ((short)11);
            nf.Color = ((short)123);
            nf.FontHeight = ((short)22);
            nf.FontName = ("Thingy");
            nf.IsItalic = (false);
            nf.IsStrikeout = (true);
            nf.TypeOffset = ((short)2);
            nf.Underline = ((byte)2);

            Assert.AreEqual(5, wb.NumberOfFonts);
            Assert.AreEqual(nf, wb.GetFontAt((short)5));

            // Find it now
            Assert.IsNotNull(
                wb.FindFont(
                    (short)11, (short)123, (short)22,
                    "Thingy", false, true, (short)2, (byte)2
                )
            );
            Assert.AreEqual(
                5,
                wb.FindFont(
                       (short)11, (short)123, (short)22,
                       "Thingy", false, true, (short)2, (byte)2
                   ).Index
            );
            Assert.AreEqual(nf,
                   wb.FindFont(
                       (short)11, (short)123, (short)22,
                       "Thingy", false, true, (short)2, (byte)2
                   )
            );
        }
開發者ID:xoposhiy,項目名稱:npoi,代碼行數:81,代碼來源:TestBugs.cs


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