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


C# IWorkbook.CreateCellStyle方法代码示例

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


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

示例1: CellStyleCache

 public CellStyleCache(IWorkbook xlWorkbook)
 {
     this.xlWorkbook = xlWorkbook;
       this.cellStyles = new Dictionary<string, CellStyleWrapper>();
       this.cellStyle = xlWorkbook.CreateCellStyle();
       this.defaultCellStyle = xlWorkbook.CreateCellStyle();
 }
开发者ID:Stef569,项目名称:npoi-wrapper,代码行数:7,代码来源:CellStyleCache.cs

示例2: BetListExcelBuilder

        /// <summary>
        /// Initializes a new instance of the <see cref="BetListExcelBuilder" /> class.
        /// </summary>
        public BetListExcelBuilder()
        {
            _workbook = new HSSFWorkbook();

            _isDisposed = false;

            OddCellStyle = _workbook.CreateCellStyle();
            EvenCellStyle = _workbook.CreateCellStyle();
            OddCellStyleCenterAligned = _workbook.CreateCellStyle();
            EvenCellStyleCenterAligned = _workbook.CreateCellStyle();

            _nextCellIndex = -1;

            RTFHelper = new RTFHelper()
            {
                NegFont = _workbook.CreateFont(),
                NormalFont = _workbook.CreateFont(),
                PosFont = _workbook.CreateFont(),
                NegFontCrossed = _workbook.CreateFont(),
                NormalFontCrossed = _workbook.CreateFont(),
                PosFontCrossed = _workbook.CreateFont(),
                RTFRenderer = new RtfTextRender()
            };

            InitDefaultRTFHelper();
            InitDefaultCellStyles();
        }
开发者ID:huyjack178,项目名称:harrsion-project,代码行数:30,代码来源:BetListExcelBuilder.cs

示例3: InitCellStyle

        public void InitCellStyle(IWorkbook workbook)
        {
            var font = workbook.CreateFont();
            var title = workbook.CreateCellStyle();
            var content = workbook.CreateCellStyle();

            RegisterFont(font);
            RegisterTitleStyle(workbook, title);
            RegisterContentStyle(workbook, content);
        }
开发者ID:holer-h,项目名称:yjinglee.office,代码行数:10,代码来源:DefaultStyle.cs

示例4: RegisterCustomStyle

        public override void RegisterCustomStyle(IWorkbook workbook)
        {
            var format = workbook.CreateDataFormat();

            ICellStyle cellStyle = workbook.CreateCellStyle();
            RegisterContentStyle(workbook, cellStyle);
            cellStyle.DataFormat = format.GetFormat("0.00%");

            ICellStyle cellStyle2 = workbook.CreateCellStyle();
            RegisterContentStyle(workbook, cellStyle2);
            cellStyle2.DataFormat = format.GetFormat("¥0.00");
        }
开发者ID:holer-h,项目名称:yjinglee.office,代码行数:12,代码来源:DefaultStyle.cs

示例5: CreateCell

        internal static ICell CreateCell(IWorkbook workbook, IRow row, int column, decimal? content, bool isCentered)
        {
            ICellStyle style = workbook.CreateCellStyle();
            ICell cell = row.CreateCell(column);
            if (content == null)
            {
                cell.SetCellValue("");
            }
            else
            {
                cell.SetCellValue(Convert.ToDouble(content.Value));
            }
            if (isCentered)
            {
                style.Alignment = HorizontalAlignment.Center;

            }
            style.BorderBottom = BorderStyle.Thin;
            style.BorderTop = BorderStyle.Thin;
            style.BorderLeft = BorderStyle.Thin;
            style.BorderRight = BorderStyle.Thin;

            cell.CellStyle = style;
            return cell;
        }
开发者ID:chamilka,项目名称:drreport,代码行数:25,代码来源:CellManager.cs

示例6: WriteHeaderRow

 static void WriteHeaderRow(IWorkbook wb, ISheet sheet)
 {
     sheet.SetColumnWidth(0, 6000);
     sheet.SetColumnWidth(1, 6000);
     sheet.SetColumnWidth(2, 3600);
     sheet.SetColumnWidth(3, 3600);
     sheet.SetColumnWidth(4, 2400);
     sheet.SetColumnWidth(5, 2400);
     sheet.SetColumnWidth(6, 2400);
     sheet.SetColumnWidth(7, 2400);
     sheet.SetColumnWidth(8, 2400);
     IRow row = sheet.CreateRow(0);
     ICellStyle style = wb.CreateCellStyle();
     IFont font = wb.CreateFont();
     font.Boldweight = (short)FontBoldWeight.BOLD;
     style.SetFont(font);
     WriteHeaderCell(row, 0, "Raw Long Bits A", style);
     WriteHeaderCell(row, 1, "Raw Long Bits B", style);
     WriteHeaderCell(row, 2, "Value A", style);
     WriteHeaderCell(row, 3, "Value B", style);
     WriteHeaderCell(row, 4, "Exp Cmp", style);
     WriteHeaderCell(row, 5, "LT", style);
     WriteHeaderCell(row, 6, "EQ", style);
     WriteHeaderCell(row, 7, "GT", style);
     WriteHeaderCell(row, 8, "Check", style);
 }
开发者ID:xoposhiy,项目名称:npoi,代码行数:26,代码来源:NumberComparingSpreadsheetGenerator.cs

示例7: GetBaseStyle

 private ICellStyle GetBaseStyle(IWorkbook workbook)
 {
     var style = workbook.CreateCellStyle();
     style.BorderBottom = style.BorderLeft = style.BorderRight = style.BorderTop = BorderStyle.Thin;
     style.FillPattern = FillPattern.SolidForeground;
     return style;
 }
开发者ID:McLeanBH,项目名称:XbimExchange,代码行数:7,代码来源:ExcelCellVisualValue.cs

示例8: SetValueAndFormat

 static void SetValueAndFormat(IWorkbook workbook, ICell cell, double value, short formatId)
 {
     cell.SetCellValue(value);
     ICellStyle cellStyle = workbook.CreateCellStyle();
     cellStyle.DataFormat = formatId;
     cell.CellStyle = cellStyle;
 }
开发者ID:ctddjyds,项目名称:npoi,代码行数:7,代码来源:Program.cs

示例9: BorderAndFontSetting

        private ICellStyle BorderAndFontSetting(IWorkbook wb, Tk5FieldInfoEx metaInfo, Model model)
        {
            ICellStyle cellStyle = wb.CreateCellStyle();

            if (fUseBorder)
            {
                cellStyle.BorderTop = BorderStyle.Thin;
                cellStyle.BorderRight = BorderStyle.Thin;
                cellStyle.BorderBottom = BorderStyle.Thin;
                cellStyle.BorderLeft = BorderStyle.Thin;
            }

            if (model == Model.Content)
            {
                IFont fontContent = ExcelUtil.FontSetting(wb, fContent);

                cellStyle.SetFont(fontContent);

                if (metaInfo.Extension != null)
                {
                    ExcelUtil.AlignSetting(metaInfo.Extension.Align, cellStyle);
                }
                else
                {
                    ExcelUtil.AlignSetting(fContent.Align, cellStyle);
                }
            }
            else
            {
                ExcelUtil.AlignSetting(fHeader.Align, cellStyle);
                IFont fontHeader = ExcelUtil.FontSetting(wb, fHeader);
                cellStyle.SetFont(fontHeader);
            }
            return cellStyle;
        }
开发者ID:ZLLselfRedeem,项目名称:zllinmitu,代码行数:35,代码来源:ExcelExporter.cs

示例10: CreateBoldStyle

        private ICellStyle CreateBoldStyle(IWorkbook workbook)
        {
            var style = workbook.CreateCellStyle();

            var font = workbook.CreateFont();
            font.Boldweight = 1000;
            style.SetFont(font);

            return style;
        }
开发者ID:breslavsky,项目名称:queue,代码行数:10,代码来源:StandardCellStyles.cs

示例11: GrayBackground

 internal static void GrayBackground(IWorkbook workbook, ICell cell, bool isCentered)
 {
     ICellStyle style = workbook.CreateCellStyle();
     style.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Grey25Percent.Index;
     style.FillPattern = FillPattern.SolidForeground;
     if (isCentered)
     {
         style.Alignment = HorizontalAlignment.Center;
     }
     style.BorderBottom = BorderStyle.Thin;
     style.BorderTop = BorderStyle.Thin;
     style.BorderLeft = BorderStyle.Thin;
     style.BorderRight = BorderStyle.Thin;
     cell.CellStyle = style;
 }
开发者ID:chamilka,项目名称:drreport,代码行数:15,代码来源:CellStyle.cs

示例12: CreateRowItem

        private static void CreateRowItem(this ISheet target, IWorkbook workbook, DataTable dataSource)
        {
            IRow row = null;
            ICell cell = null;
            ICellStyle cellStyle = null;
            IDrawing drawing = null;
            IPicture picture = null;

            cellStyle = workbook.CreateCellStyle();
            cellStyle.Alignment = HorizontalAlignment.CENTER;
            cellStyle.VerticalAlignment = VerticalAlignment.CENTER;

            for (int rowIndex = 0; rowIndex < dataSource.Rows.Count; rowIndex++)
            {
                row = target.CreateRow(rowIndex + 1);

                for (int columnIndex = 0; columnIndex < dataSource.Columns.Count; columnIndex++)
                {
                    cell = row.CreateCell(columnIndex);

                    if (dataSource.Columns[columnIndex].DataType == typeof(byte[]))
                    {
                        byte[] image = dataSource.Rows[rowIndex][columnIndex] as byte[];

                        if (image != null && image.Length > 0)
                        {
                            int pictureIndex = workbook.AddPicture(dataSource.Rows[rowIndex][columnIndex] as byte[], PictureType.JPEG);

                            drawing = target.CreateDrawingPatriarch();
                            HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 0, 0, columnIndex, rowIndex + 1, columnIndex, rowIndex + 1);
                            picture = drawing.CreatePicture(anchor, pictureIndex);
                            picture.Resize();
                        }
                    }

                    else
                    {
                        cell.SetCellValue(dataSource.Rows[rowIndex][columnIndex].ToString());
                    }

                    cell.CellStyle = cellStyle;
                }
            }
        }
开发者ID:kainhong,项目名称:CurrencyStore,代码行数:44,代码来源:AdoNetExtension.cs

示例13: GetCellStyle

        /// <summary>
        /// 创建表格头单元格
        /// </summary>
        /// <param name="sheet"></param>
        /// <returns></returns>
        public static ICellStyle GetCellStyle(IWorkbook workbook, bool isHeaderRow = false)
        {
            ICellStyle style = workbook.CreateCellStyle();

            if (isHeaderRow)
            {
                style.FillPattern = FillPattern.SolidForeground;
                style.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Grey25Percent.Index;
                IFont f = workbook.CreateFont();
                f.Boldweight = (short)FontBoldWeight.Bold;
                style.SetFont(f);
            }

            style.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
            style.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
            style.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;
            style.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin;
            return style;
        }
开发者ID:chinawaycyc,项目名称:ExcelOperate,代码行数:24,代码来源:Common.cs

示例14: SetBorderStyle

        public static void SetBorderStyle(IWorkbook workbook, IRow row, int columns)
        {
            row.Height = 14 * 30;
            IFont font18 = workbook.CreateFont();
            font18.FontName = "宋体";
            font18.FontHeightInPoints = 10;

            for (int i = 0; i < columns; i++)
            {
                ICellStyle style12 = workbook.CreateCellStyle();
                style12.SetFont(font18);
                //style12.Alignment = HorizontalAlignment.CENTER;
                style12.VerticalAlignment = VerticalAlignment.CENTER;

                style12.BorderBottom = NPOI.SS.UserModel.BorderStyle.THIN;
                style12.BorderLeft = NPOI.SS.UserModel.BorderStyle.THIN;
                style12.BorderRight = NPOI.SS.UserModel.BorderStyle.THIN;
                style12.BorderTop = NPOI.SS.UserModel.BorderStyle.THIN;
                row.GetCell(i).CellStyle = style12;
            }
        }
开发者ID:chinayinhui,项目名称:LYLQ,代码行数:21,代码来源:ExcelHelper.cs

示例15: SetHeaderStyle

        public static void SetHeaderStyle(IWorkbook workbook, IRow row, int columns)
        {
            row.Height = 16 * 30;
            IFont font18 = workbook.CreateFont();
            font18.FontName = "宋体";
            font18.FontHeightInPoints = 12;
            font18.Boldweight = (short)NPOI.SS.UserModel.FontBoldWeight.BOLD;

            for (int i = 0; i < columns; i++)
            {
                ICellStyle style12 = workbook.CreateCellStyle();
                style12.SetFont(font18);
                // style12.Alignment = HorizontalAlignment.CENTER;
                style12.VerticalAlignment = VerticalAlignment.CENTER;

                style12.BorderBottom = NPOI.SS.UserModel.BorderStyle.THIN;
                style12.BorderLeft = NPOI.SS.UserModel.BorderStyle.THIN;
                style12.BorderRight = NPOI.SS.UserModel.BorderStyle.THIN;
                style12.BorderTop = NPOI.SS.UserModel.BorderStyle.THIN;
                //style12.FillBackgroundColor = NPOI.HSSF.Util.HSSFColor.Yellow.Index2;
                row.GetCell(i).CellStyle = style12;
            }
        }
开发者ID:chinayinhui,项目名称:LYLQ,代码行数:23,代码来源:ExcelHelper.cs


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