• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# ICellStyle类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ICellStyle的典型用法代码示例。如果您正苦于以下问题:C# ICellStyle类的具体用法?C# ICellStyle怎么用?C# ICellStyle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ICellStyle类属于命名空间,在下文中一共展示了ICellStyle类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: InsertCell

 private static int InsertCell(IRow row, int cellIndex, string value, ICellStyle cellStyle)
 {
     var cell = row.CreateCell(cellIndex);
     cell.SetCellValue(value);
     cell.CellStyle = cellStyle;
     cellIndex++;
     return cellIndex;
 }
开发者ID:zhh007,项目名称:CKGen,代码行数:8,代码来源:ExcelHelper.cs


示例2: columnMerge

 internal static void columnMerge(ISheet sheet, ICellStyle cellStyle, int row, int startColumn, int endColumn)
 {
     sheet.AddMergedRegion(new NPOI.SS.Util.CellRangeAddress(row, row, startColumn, endColumn));
     cellStyle.BorderBottom = BorderStyle.Thin;
     cellStyle.BorderTop = BorderStyle.Thin;
     cellStyle.BorderLeft = BorderStyle.Thin;
     cellStyle.BorderRight = BorderStyle.Thin;
 }
开发者ID:chamilka,项目名称:drreport,代码行数:8,代码来源:CellManager.cs


示例3: ValidationAdder

 public ValidationAdder(ISheet fSheet, ICellStyle style_1, ICellStyle style_2,
         ICellStyle cellStyle, int validationType)
 {
     _sheet = fSheet;
     _style_1 = style_1;
     _style_2 = style_2;
     _cellStyle = cellStyle;
     _validationType = validationType;
     _currentRowIndex = fSheet.PhysicalNumberOfRows;
 }
开发者ID:xoposhiy,项目名称:npoi,代码行数:10,代码来源:BaseTestDataValidation.cs


示例4: Resolve

 /// <summary>
 /// 解析为Npoi单元格样式
 /// </summary>
 public ICellStyle Resolve() {
     _result = _workbook.CreateCellStyle();
     _result.Alignment = GetHorizontalAlignment();
     _result.VerticalAlignment = GetVerticalAlignment();
     SetBackgroundColor();
     SetFillPattern();
     SetBorderColor();
     SetFont();
     _result.WrapText = _style.IsWrap;
     return _result;
 }
开发者ID:BeiMeng,项目名称:GitApplication,代码行数:14,代码来源:CellStyleResolver.cs


示例5: AttachedCellStyle

        public static void AttachedCellStyle(this IWorkbook owner, string propertyName, ICellStyle value)
        {
            Dictionary<string, ICellStyle> values;
            if (!_table.TryGetValue(owner, out values))
            {
                values = new Dictionary<string, ICellStyle>();
                _table.Add(owner, values);
            }

            values[propertyName] = value;
        }
开发者ID:newlysoft,项目名称:NPOI.CSS,代码行数:11,代码来源:AttachedPropertyExtension.cs


示例6: WriteCell

        protected ICell WriteCell(IRow row, int column, Action<ICell> setValue, ICellStyle style = null)
        {
            var cell = row.CreateCell(column);
            setValue(cell);
            if (style != null)
            {
                cell.CellStyle = style;
            }

            return cell;
        }
开发者ID:breslavsky,项目名称:queue,代码行数:11,代码来源:BaseReport.cs


示例7: SetStyle

        public void SetStyle(
            int hauteur,
            int longeur,
            int beginHauteurCadre,
            int beginLongeurCadre,
            int hauteurCadre,
            int longeurCadre,
            ICellStyle style,
            bool forcedRightBorder)
        {
            if (hauteur == beginHauteurCadre && longeur == beginLongeurCadre)
            {
                SetLeftTopCornerStyle(style);
            }
            else if (hauteur == beginHauteurCadre && longeur == longeurCadre)
            {
                SetRightTopCornerStyle(style);
            }
            else if (hauteur == beginHauteurCadre)
            {
                SetOnlyTopStyle(style);
            }
            else if (hauteur == hauteurCadre && longeur == beginLongeurCadre)
            {
                SetBottomLeftCornerStyle(style);
            }
            else if (hauteur == hauteurCadre && longeur == longeurCadre)
            {
                SetBottomRightCornerStyle(style);
            }
            else if (hauteur == hauteurCadre)
            {
                SetOnlyBottomStyle(style);
            }
            else if (longeur == beginLongeurCadre)
            {
                SetOnlyLeftStyle(style);
            }
            else if (longeur == longeurCadre)
            {
                SetOnlyRightStyle(style);
            }

            if (forcedRightBorder)
            {
                style.BorderRight = _tailleBorder;
            }
            else
            {
                style.BorderRight = style.BorderRight;
            }
        }
开发者ID:baptisteMillot,项目名称:Synoptique,代码行数:52,代码来源:Cadre.cs


示例8: CreateRowCell

 public IRow CreateRowCell(ISheet sheet, int rowIdx, int fromColIdx, int toColIdx, ICellStyle cellStyle)
 {
     IRow row = sheet.CreateRow(rowIdx);
     for (int i = fromColIdx; i <= toColIdx; i++)
     {
         ICell cell = row.CreateCell(i);
         if (cellStyle != null)
         {
             cell.CellStyle = cellStyle;
         }
     }
     return row;
 }
开发者ID:shew990,项目名称:github,代码行数:13,代码来源:NPOIHelper.cs


示例9: ApplyStyle

        /// <summary>
        /// Applies the style by copying the fluent style to the NPOI style object,.
        /// </summary>
        /// <param name="workbook">The workbook.</param>
        /// <param name="destination">The destination NPOI style object to apply the FluentStyle to.</param>
        public void ApplyStyle(IWorkbook workbook, ICellStyle destination)
        {
            // If users sets format string this overrides the DataFormat property.
            if (Format != null)
            {
                var dataFormat = workbook.CreateDataFormat();
                DataFormat = dataFormat.GetFormat(Format);
            }

            if (Alignment != null) destination.Alignment = Alignment.Value;
            if (BorderBottom != null) destination.BorderBottom = BorderBottom.Value;
            if (BorderDiagonal != null) destination.BorderDiagonal = BorderDiagonal.Value;
            if (BorderDiagonalColor != null) destination.BorderDiagonalColor = BorderDiagonalColor.Value;
            if (BorderDiagonalLineStyle != null) destination.BorderDiagonalLineStyle = BorderDiagonalLineStyle.Value;
            if (BorderLeft != null) destination.BorderLeft = BorderLeft.Value;
            if (BorderRight != null) destination.BorderRight = BorderRight.Value;
            if (BorderTop != null) destination.BorderTop = BorderTop.Value;
            if (BottomBorderColor != null) destination.BottomBorderColor = BottomBorderColor.Value;
            if (DataFormat != null) destination.DataFormat = DataFormat.Value;
            if (FillBackgroundColor != null) destination.FillBackgroundColor = FillBackgroundColor.Value;
            if (FillForegroundColor != null) destination.FillForegroundColor = FillForegroundColor.Value;
            if (FillPattern != null) destination.FillPattern = FillPattern.Value;
            if (Indention != null) destination.Indention = Indention.Value;
            if (LeftBorderColor != null) destination.LeftBorderColor = LeftBorderColor.Value;
            if (RightBorderColor != null) destination.RightBorderColor = RightBorderColor.Value;
            if (Rotation != null) destination.Rotation = Rotation.Value;
            if (ShrinkToFit != null) destination.ShrinkToFit = ShrinkToFit.Value;
            if (TopBorderColor != null) destination.TopBorderColor = TopBorderColor.Value;
            if (VerticalAlignment != null) destination.VerticalAlignment = VerticalAlignment.Value;
            if (WrapText != null) destination.WrapText = WrapText.Value;

            if (FontIsNeeded)
            {
                var font = workbook.CreateFont();

                if (FontWeight != null) font.Boldweight = (short)FontWeight.Value;
                if (Charset != null) font.Charset = Charset.Value;
                if (Color != null) font.Color = Color.Value;
                if (FontHeight != null) font.FontHeight = FontHeight.Value;
                if (FontHeightInPoints != null) font.FontHeightInPoints = FontHeightInPoints.Value;
                if (FontName != null) font.FontName = FontName;
                if (Italic != null) font.IsItalic = Italic.Value;
                if (Strikeout != null) font.IsStrikeout = Strikeout.Value;
                if (SuperScript != null) font.TypeOffset = SuperScript.Value;
                if (Underline != null) font.Underline = Underline.Value;

                destination.SetFont(font);
            }
        }
开发者ID:PhilipDaniels,项目名称:TestParser,代码行数:54,代码来源:FluentStyle.cs


示例10: SetCellStyle

        public void SetCellStyle(ICell cell, ICellStyle npoiCellStyle)
        {
            CellStyleWrapper cellStyle = new CellStyleWrapper(npoiCellStyle);
              string cellStyleKey = cellStyle.GetKey();

              if (cellStyles.ContainsKey(cellStyleKey)) {
            // reuse cached styles
            CellStyleWrapper cachedCellStyle = cellStyles[cellStyleKey];
            cell.CellStyle = cachedCellStyle.CellStyle;
              } else {
            // If the style does not exist create a new one
            ICellStyle newCellStyle = xlWorkbook.CreateCellStyle();
            CopyCellStyle(xlWorkbook, npoiCellStyle, newCellStyle);
            Add(new CellStyleWrapper(newCellStyle));
            cell.CellStyle = newCellStyle;
              }
        }
开发者ID:Stef569,项目名称:npoi-wrapper,代码行数:17,代码来源:CellStyleCache.cs


示例11: CopyCellStyle

 /// <summary>
 /// Copy c1 into c2
 /// </summary>
 public static void CopyCellStyle(IWorkbook wb, ICellStyle c1, ICellStyle c2)
 {
     c2.Alignment = c1.Alignment;
       c2.BorderBottom = c1.BorderBottom;
       c2.BorderLeft = c1.BorderLeft;
       c2.BorderRight = c1.BorderRight;
       c2.BorderTop = c1.BorderTop;
       c2.BottomBorderColor = c1.BottomBorderColor;
       c2.DataFormat = c1.DataFormat;
       c2.FillBackgroundColor = c1.FillBackgroundColor;
       c2.FillForegroundColor = c1.FillForegroundColor;
       c2.FillPattern = c1.FillPattern;
       c2.SetFont(wb.GetFontAt(c1.FontIndex));
       // HIDDEN ?
       c2.Indention = c1.Indention;
       c2.LeftBorderColor = c1.LeftBorderColor;
       // LOCKED ?
       c2.RightBorderColor = c1.RightBorderColor;
       c2.Rotation = c1.Rotation;
       c2.TopBorderColor = c1.TopBorderColor;
       c2.VerticalAlignment = c1.VerticalAlignment;
       c2.WrapText = c1.WrapText;
 }
开发者ID:Stef569,项目名称:npoi-wrapper,代码行数:26,代码来源:CellStyleCache.cs


示例12: GetStyleWithFormat

        internal ICellStyle GetStyleWithFormat(ICellStyle baseStyle, string dataFormat)
        {
            ICellStyle newStyle = CreateCellStyle();
            newStyle.CloneStyleFrom(baseStyle);

            if (StringMethods.IsNullOrWhiteSpace(dataFormat))
                return newStyle;

            // check if this is a built-in format
            var builtinFormatId = GetBuiltIndDataFormat(dataFormat);

            if (builtinFormatId != -1)
            {
                newStyle.DataFormat = builtinFormatId;
            }
            else
            {
                // not a built-in format, so create a new one
                var newDataFormat = CreateDataFormat();
                newStyle.DataFormat = newDataFormat.GetFormat(dataFormat);
            }

            return newStyle;
        }
开发者ID:Infodinamica,项目名称:exportable,代码行数:24,代码来源:ExcelEngine.cs


示例13: 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


示例14: setCellStyle

 private void setCellStyle(IRow irow, int cellno, ICellStyle ics)
 {
     for (int i = 0; i < cellno; i++)
     {
         irow.GetCell(i).CellStyle = ics;
     }
 }
开发者ID:sloww,项目名称:jcordersheetcreator,代码行数:7,代码来源:DataTools.cs


示例15: PutNamesWithValidations

            private void PutNamesWithValidations(ISheet ws, ICellStyle cs1, ICellStyle cs2, ICellStyle cs3, params string[][] names)
            {
                var rn0 = ws.PhysicalNumberOfRows;
                var rn = rn0;
                for (var i = 0; i < names.Length; ++i)
                {
                    var rnc = rn++;
                    var r = ws.CreateRow(rnc);
                    if (1 < names[i].Length)
                    {
                        r.RowStyle = cs3;
                        var vh = ws.GetDataValidationHelper();
                        var vl = names[i].Skip(1).ToList();
                        vl.Sort();
                        var vd = vh.CreateValidation(
                            vh.CreateExplicitListConstraint(vl.ToArray()),
                            new CellRangeAddressList(rnc, rnc, 1, _excelVer.LastColumnIndex)
                            );
                        vd.ShowErrorBox = false;
                        vd.ShowPromptBox = true;
                        ws.AddValidationData(vd);
                    }

                    var c = r.CreateCell(0);
                    c.SetCellValue(names[i][0]);
                    if (0 == i)
                    {
                        c.CellStyle = cs1;
                        r.RowStyle = cs1;
                    }
                    else
                    {
                        c.CellStyle = cs2;
                    }
                }
                if (1 < names.Length) ws.GroupRow(rn0 + 1, rn - 1);
                //ws.SetRowGroupCollapsed(rn0 + 1, true);
                ws.AddMergedRegion(new CellRangeAddress(rn0, rn0, 0, _excelVer.LastColumnIndex));
            }
开发者ID:269378737,项目名称:go81,代码行数:39,代码来源:TemplateExcel.cs


示例16: PutNames

 private void PutNames(ISheet ws, ICellStyle cs1, ICellStyle cs2, ICellStyle cs3, params string[] names)
 {
     PutNamesWithValidations(ws, cs1, cs2, cs3, names.Select(s => new[] { s }).ToArray());
 }
开发者ID:269378737,项目名称:go81,代码行数:4,代码来源:TemplateExcel.cs


示例17: SetDefaultCellStyle

 private static void SetDefaultCellStyle(this IWorkbook wb, ICellStyle cs)
 {
     wb.GetDefaultCellStyle().CloneStyleFrom(cs);
 }
开发者ID:269378737,项目名称:go81,代码行数:4,代码来源:TemplateExcel.cs


示例18: AppendFormat

 /// <summary>
 /// Append the required format depending on the COBieAllowedType
 /// </summary>
 /// <param name="type">COBieAllowedType</param>
 /// <param name="cellStyle">ICellStyle, style to ally formate to</param>
 private void AppendFormat(COBieAllowedType type, ICellStyle cellStyle)
 {
     string formatString = null;
     switch (type)
     {
         case COBieAllowedType.ISODate:
             formatString = "yyyy-MM-dd";
             break;
         case COBieAllowedType.ISODateTime:
             formatString = "yyyy-MM-ddThh:mm:ss";
             break;
         case COBieAllowedType.AlphaNumeric:
             break;
         case COBieAllowedType.Email:
             break;
         case COBieAllowedType.Numeric:
             break;
         case COBieAllowedType.Text:
             break;
         case COBieAllowedType.AnyType:
             break;
         default:
             break;
     }
     if (formatString != null)
     {
         IDataFormat dataFormat = ExcelWorkbook.CreateDataFormat();
         cellStyle.DataFormat = dataFormat.GetFormat(formatString);
     }
 }
开发者ID:McLeanBH,项目名称:XbimExchange,代码行数:35,代码来源:COBieXLSXSerialiser.cs


示例19: SetFormatProperties

 /**
  * Sets the format properties of the given style based on the given map.
  *
  * @param style cell style
  * @param workbook parent workbook
  * @param properties map of format properties (String -> Object)
  * @see #getFormatProperties(CellStyle)
  */
 private static void SetFormatProperties(ICellStyle style, IWorkbook workbook, Dictionary<String, Object> properties)
 {
     style.Alignment=(HorizontalAlignment)(GetShort(properties, ALIGNMENT));
     style.BorderBottom=(BorderStyle)(GetShort(properties, BORDER_BOTTOM));
     style.BorderLeft=(BorderStyle)(GetShort(properties, BORDER_LEFT));
     style.BorderRight=(BorderStyle)(GetShort(properties, BORDER_RIGHT));
     style.BorderTop=(BorderStyle)(GetShort(properties, BORDER_TOP));
     style.BottomBorderColor=(GetShort(properties, BOTTOM_BORDER_COLOR));
     style.DataFormat=(GetShort(properties, DATA_FORMAT));
     style.FillBackgroundColor=(GetShort(properties, FILL_BACKGROUND_COLOR));
     style.FillForegroundColor=(GetShort(properties, FILL_FOREGROUND_COLOR));
     style.FillPattern=(FillPatternType)(GetShort(properties, FILL_PATTERN));
     style.SetFont(workbook.GetFontAt(GetShort(properties, FONT)));
     style.IsHidden=(GetBoolean(properties, HIDDEN));
     style.Indention=(GetShort(properties, INDENTION));
     style.LeftBorderColor=(GetShort(properties, LEFT_BORDER_COLOR));
     style.IsLocked=(GetBoolean(properties, LOCKED));
     style.RightBorderColor=(GetShort(properties, RIGHT_BORDER_COLOR));
     style.Rotation=(GetShort(properties, ROTATION));
     style.TopBorderColor=(GetShort(properties, TOP_BORDER_COLOR));
     style.VerticalAlignment=(VerticalAlignment)(GetShort(properties, VERTICAL_ALIGNMENT));
     style.WrapText=(GetBoolean(properties, WRAP_TEXT));
 }
开发者ID:missxiaohuang,项目名称:Weekly,代码行数:31,代码来源:CellUtil.cs


示例20: GetFormatProperties

 /**
  * Returns a map containing the format properties of the given cell style.
  *
  * @param style cell style
  * @return map of format properties (String -> Object)
  * @see #setFormatProperties(org.apache.poi.ss.usermodel.CellStyle, org.apache.poi.ss.usermodel.Workbook, java.util.Map)
  */
 private static Dictionary<String, Object> GetFormatProperties(ICellStyle style)
 {
     Dictionary<String, Object> properties = new Dictionary<String, Object>();
     PutShort(properties, ALIGNMENT, (short)style.Alignment);
     PutShort(properties, BORDER_BOTTOM, (short)style.BorderBottom);
     PutShort(properties, BORDER_LEFT, (short)style.BorderLeft);
     PutShort(properties, BORDER_RIGHT, (short)style.BorderRight);
     PutShort(properties, BORDER_TOP, (short)style.BorderTop);
     PutShort(properties, BOTTOM_BORDER_COLOR, style.BottomBorderColor);
     PutShort(properties, DATA_FORMAT, style.DataFormat);
     PutShort(properties, FILL_BACKGROUND_COLOR, style.FillBackgroundColor);
     PutShort(properties, FILL_FOREGROUND_COLOR, style.FillForegroundColor);
     PutShort(properties, FILL_PATTERN, (short)style.FillPattern);
     PutShort(properties, FONT, style.FontIndex);
     PutBoolean(properties, HIDDEN, style.IsHidden);
     PutShort(properties, INDENTION, style.Indention);
     PutShort(properties, LEFT_BORDER_COLOR, style.LeftBorderColor);
     PutBoolean(properties, LOCKED, style.IsLocked);
     PutShort(properties, RIGHT_BORDER_COLOR, style.RightBorderColor);
     PutShort(properties, ROTATION, style.Rotation);
     PutShort(properties, TOP_BORDER_COLOR, style.TopBorderColor);
     PutShort(properties, VERTICAL_ALIGNMENT, (short)style.VerticalAlignment);
     PutBoolean(properties, WRAP_TEXT, style.WrapText);
     return properties;
 }
开发者ID:missxiaohuang,项目名称:Weekly,代码行数:32,代码来源:CellUtil.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ICertificatePal类代码示例发布时间:2022-05-24
下一篇:
C# ICell类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap