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


C# XSSFFont.RegisterTo方法代码示例

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


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

示例1: CloneStyleFrom

        /**
         * Clones all the style information from another
         *  XSSFCellStyle, onto this one. This
         *  XSSFCellStyle will then have all the same
         *  properties as the source, but the two may
         *  be edited independently.
         * Any stylings on this XSSFCellStyle will be lost!
         *
         * The source XSSFCellStyle could be from another
         *  XSSFWorkbook if you like. This allows you to
         *  copy styles from one XSSFWorkbook to another.
         */
        public void CloneStyleFrom(ICellStyle source)
        {
            if (source is XSSFCellStyle)
            {
                XSSFCellStyle src = (XSSFCellStyle)source;

                // Is it on our Workbook?
                if (src._stylesSource == _stylesSource)
                {
                    // Nice and easy
                    _cellXf = src.GetCoreXf();
                    _cellStyleXf = src.GetStyleXf();
                }
                else
                {
                    // Copy the style
                    try
                    {


                        // Remove any children off the current style, to
                        //  avoid orphaned nodes
                        if (_cellXf.IsSetAlignment())
                            _cellXf.UnsetAlignment();
                        if (_cellXf.IsSetExtLst())
                            _cellXf.UnsetExtLst();

                        // Create a new Xf with the same contents
                        _cellXf =
                              src.GetCoreXf().Copy();
                        // Swap it over
                        _stylesSource.ReplaceCellXfAt(_cellXfId, _cellXf);
                    }
                    catch (XmlException e)
                    {
                        throw new POIXMLException(e);
                    }

                    // Copy the format
                    String fmt = src.GetDataFormatString();
                    DataFormat=(
                          (new XSSFDataFormat(_stylesSource)).GetFormat(fmt)
                    );

                    // Copy the font
                    try
                    {
                        CT_Font ctFont = 
                              src.GetFont().GetCTFont().Clone();
                        XSSFFont font = new XSSFFont(ctFont);
                        font.RegisterTo(_stylesSource);
                        SetFont(font);
                    }
                    catch (XmlException e)
                    {
                        throw new POIXMLException(e);
                    }
                }

                // Clear out cached details
                _font = null;
                _cellAlignment = null;
            }
            else
            {
                throw new ArgumentException("Can only clone from one XSSFCellStyle to another, not between HSSFCellStyle and XSSFCellStyle");
            }
        }
开发者ID:qljiong,项目名称:npoi,代码行数:80,代码来源:XSSFCellStyle.cs

示例2: CreateFont

 /// <summary>
 /// Create a new Font and add it to the workbook's font table
 /// </summary>
 /// <returns></returns>
 public IFont CreateFont()
 {
     XSSFFont font = new XSSFFont();
     font.RegisterTo(stylesSource);
     return font;
 }
开发者ID:tonyqus,项目名称:npoi,代码行数:10,代码来源:XSSFWorkbook.cs


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