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


C# CT_Font.AddNewCharset方法代码示例

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


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

示例1: TestCharSet

        public void TestCharSet()
        {
            CT_Font ctFont = new CT_Font();
            CT_IntProperty prop = ctFont.AddNewCharset();
            prop.val = (FontCharset.ANSI.Value);

            ctFont.SetCharsetArray(0, prop);
            XSSFFont xssfFont = new XSSFFont(ctFont);
            Assert.AreEqual(FontCharset.ANSI.Value, xssfFont.Charset);

            xssfFont.SetCharSet(FontCharset.DEFAULT);
            Assert.AreEqual(FontCharset.DEFAULT.Value, ctFont.GetCharsetArray(0).val);

            // Try with a few less usual ones:
            // Set with the Charset itself
            xssfFont.SetCharSet(FontCharset.RUSSIAN);
            Assert.AreEqual(FontCharset.RUSSIAN.Value, xssfFont.Charset);
            // And Set with the Charset index
            xssfFont.SetCharSet(FontCharset.ARABIC.Value);
            Assert.AreEqual(FontCharset.ARABIC.Value, xssfFont.Charset);

            // This one isn't allowed
            Assert.AreEqual(null, FontCharset.ValueOf(9999));
            try
            {
                xssfFont.SetCharSet(9999);
                Assert.Fail("Shouldn't be able to Set an invalid charset");
            }
            catch (POIXMLException) { }


            // Now try with a few sample files

            // Normal charset
            XSSFWorkbook workbook = XSSFTestDataSamples.OpenSampleWorkbook("Formatting.xlsx");
            Assert.AreEqual(0,
                  ((XSSFCellStyle)workbook.GetSheetAt(0).GetRow(0).GetCell(0).CellStyle).GetFont().Charset
            );

            // GB2312 charact Set
            workbook = XSSFTestDataSamples.OpenSampleWorkbook("49273.xlsx");
            Assert.AreEqual(134,
                  ((XSSFCellStyle)workbook.GetSheetAt(0).GetRow(0).GetCell(0).CellStyle).GetFont().Charset
            );
        }
开发者ID:89sos98,项目名称:npoi,代码行数:45,代码来源:TestXSSFFont.cs

示例2: ToCTFont

        /**
         *
         * CTRPrElt --> CTFont adapter
         */
        protected static CT_Font ToCTFont(CT_RPrElt pr)
        {
            CT_Font ctFont = new CT_Font();

            if (pr.sizeOfBArray() > 0) ctFont.AddNewB().val = (pr.GetBArray(0).val);
            if (pr.sizeOfUArray() > 0) ctFont.AddNewU().val = (pr.GetUArray(0).val);
            if (pr.sizeOfIArray() > 0) ctFont.AddNewI().val = (pr.GetIArray(0).val);
            if (pr.sizeOfColorArray() > 0)
            {
                CT_Color c1 = pr.GetColorArray(0);
                CT_Color c2 = ctFont.AddNewColor();
                if (c1.IsSetAuto())
                {
                    c2.auto = (c1.auto);
                    c2.autoSpecified = true;
                }
                if (c1.IsSetIndexed())
                {
                    c2.indexed = (c1.indexed);
                    c2.indexedSpecified = true;
                }
                if (c1.IsSetRgb())
                {
                    c2.SetRgb(c1.GetRgb());
                    c2.rgbSpecified = true;
                }
                if (c1.IsSetTheme())
                {
                    c2.theme = (c1.theme);
                    c2.themeSpecified = true;
                }
                if (c1.IsSetTint())
                {
                    c2.tint = (c1.tint);
                    c2.tintSpecified = true;
                }
            }
 
            if (pr.sizeOfSzArray() > 0) ctFont.AddNewSz().val = (pr.GetSzArray(0).val);
            if (pr.sizeOfRFontArray() > 0) ctFont.AddNewName().val = (pr.GetRFontArray(0).val);
            if (pr.sizeOfFamilyArray() > 0) ctFont.AddNewFamily().val = (pr.GetFamilyArray(0).val);
            if (pr.sizeOfSchemeArray() > 0) ctFont.AddNewScheme().val = (pr.GetSchemeArray(0).val);
            if (pr.sizeOfCharsetArray() > 0) ctFont.AddNewCharset().val = (pr.GetCharsetArray(0).val);
            if (pr.sizeOfCondenseArray() > 0) ctFont.AddNewCondense().val = (pr.GetCondenseArray(0).val);
            if (pr.sizeOfExtendArray() > 0) ctFont.AddNewExtend().val = (pr.GetExtendArray(0).val);
            if (pr.sizeOfVertAlignArray() > 0) ctFont.AddNewVertAlign().val = (pr.GetVertAlignArray(0).val);
            if (pr.sizeOfOutlineArray() > 0) ctFont.AddNewOutline().val = (pr.GetOutlineArray(0).val);
            if (pr.sizeOfShadowArray() > 0) ctFont.AddNewShadow().val = (pr.GetShadowArray(0).val);
            if (pr.sizeOfStrikeArray() > 0) ctFont.AddNewStrike().val = (pr.GetStrikeArray(0).val);

            return ctFont;
        }
开发者ID:twxstar,项目名称:npoi,代码行数:56,代码来源:XSSFRichTextString.cs

示例3: Clone

 public CT_Font Clone()
 {
     CT_Font ctFont = new CT_Font();
     if (this.name.Count != 0)
     {
         CT_FontName newName = ctFont.AddNewName();
         newName.val = this.GetNameArray(0).val;
     }
     if (this.charset.Count != 0)
     {
         CT_IntProperty newCharset = ctFont.AddNewCharset();
         newCharset.val = this.GetCharsetArray(0).val;
     }
     if (this.family.Count != 0)
     {
         CT_IntProperty newFamily = ctFont.AddNewFamily();
         newFamily.val = this.GetFamilyArray(0).val;
     }
     if (this.b.Count != 0)
     {
         CT_BooleanProperty newB = ctFont.AddNewB();
         newB.val = this.GetBArray(0).val;
     }
     if (this.i.Count != 0)
     {
         CT_BooleanProperty newI = ctFont.AddNewI();
         newI.val = this.GetIArray(0).val;
     }
     if (this.strike.Count != 0)
     {
         CT_BooleanProperty newstrike = ctFont.AddNewStrike();
         newstrike.val = this.GetStrikeArray(0).val;
     }
     if (this.outline != null)
     {
         ctFont.outline = new CT_BooleanProperty();
         ctFont.outline.val = this.outline.val;
     }
     if (this.shadow != null)
     {
         ctFont.shadow = new CT_BooleanProperty();
         ctFont.shadow.val = this.shadow.val;
     }
     if (this.condense != null)
     {
         ctFont.condense = new CT_BooleanProperty();
         ctFont.condense.val = this.condense.val;
     }
     if (this.extend != null)
     {
         ctFont.extend = new CT_BooleanProperty();
         ctFont.extend.val = this.extend.val;
     }
     if (this.color.Count != 0)
     {
         CT_Color newColor = ctFont.AddNewColor();
         newColor.theme = this.GetColorArray(0).theme;
     }
     if (this.sz.Count != 0)
     {
         CT_FontSize newSz = ctFont.AddNewSz();
         newSz.val = this.GetSzArray(0).val;
     }
     if (this.u.Count != 0)
     {
         CT_UnderlineProperty newU = ctFont.AddNewU();
         newU.val = this.GetUArray(0).val;
     }
     if (this.vertAlign.Count != 0)
     {
         CT_VerticalAlignFontProperty newVertAlign = ctFont.AddNewVertAlign();
         newVertAlign.val = this.GetVertAlignArray(0).val;
     }
     if (this.scheme.Count != 0)
     {
         CT_FontScheme newFs = ctFont.AddNewScheme();
         newFs.val = this.GetSchemeArray(0).val;
     }
     return ctFont;
 }
开发者ID:ngnono,项目名称:npoi,代码行数:80,代码来源:CT_Font.cs

示例4: Clone

        public CT_Font Clone()
        {
            CT_Font ctFont = new CT_Font();

            if (this.name!=null)
            {
                  CT_FontName newName = ctFont.AddNewName();
                    newName.val = this.name.val;
            }
            if (this.charset!=null)
            {
                foreach (CT_IntProperty ctCharset in this.charset)
                {
                    CT_IntProperty newCharset = ctFont.AddNewCharset();
                    newCharset.val = ctCharset.val;
                }
            }
            if (this.family!=null)
            {
                foreach (CT_IntProperty ctFamily in this.family)
                {
                    CT_IntProperty newFamily = ctFont.AddNewFamily();
                    newFamily.val = ctFamily.val;
                }
            }
            if (this.b != null)
            {
                foreach (CT_BooleanProperty ctB in this.b)
                {
                    CT_BooleanProperty newB = ctFont.AddNewB();
                    newB.val = ctB.val;
                }
            }
            if (this.i != null)
            {
                foreach (CT_BooleanProperty ctI in this.i)
                {
                    CT_BooleanProperty newI = ctFont.AddNewB();
                    newI.val = ctI.val;
                }
            }
            if (this.strike != null)
            {
                foreach (CT_BooleanProperty ctStrike in this.strike)
                {
                    CT_BooleanProperty newstrike = ctFont.AddNewStrike();
                    newstrike.val = ctStrike.val;
                }
            }
            if (this.outline != null)
            {
                ctFont.outline = new CT_BooleanProperty();
                ctFont.outline.val = this.outline.val;
            }
            if (this.shadow != null)
            {
                ctFont.shadow = new CT_BooleanProperty();
                ctFont.shadow.val = this.shadow.val;
            }
            if (this.condense != null)
            {
                ctFont.condense = new CT_BooleanProperty();
                ctFont.condense.val = this.condense.val;
            }
            if (this.extend != null)
            {
                ctFont.extend = new CT_BooleanProperty();
                ctFont.extend.val = this.extend.val;
            }
            if (this.color != null)
            {
                foreach (CT_Color ctColor in this.color)
                {
                    CT_Color newColor = ctFont.AddNewColor();
                    newColor.theme = ctColor.theme;
                }
            }
            if (this.sz != null)
            {
                foreach (CT_FontSize ctSz in this.sz)
                {
                    CT_FontSize newSz = ctFont.AddNewSz();
                    newSz.val = ctSz.val;
                }
            }
            if (this.u != null)
            {
                foreach (CT_UnderlineProperty ctU in this.u)
                {
                    CT_UnderlineProperty newU = ctFont.AddNewU();
                    newU.val = ctU.val;
                }
            }
            if (this.vertAlign != null)
            {
                foreach (CT_VerticalAlignFontProperty ctVertAlign in this.vertAlign)
                {
                    CT_VerticalAlignFontProperty newVertAlign = ctFont.AddNewVertAlign();
                    newVertAlign.val = ctVertAlign.val;
                }
//.........这里部分代码省略.........
开发者ID:hjlfmy,项目名称:npoi,代码行数:101,代码来源:CT_Font.cs


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