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


C# IWorkbook.CreateFont方法代码示例

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


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

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

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

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

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

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

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

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

示例8: createStyles

        /**
     * create a library of cell styles
     */
        private static Dictionary<String, ICellStyle> createStyles(IWorkbook wb)
        {
            Dictionary<String, ICellStyle> styles = new Dictionary<String, ICellStyle>();
            IDataFormat df = wb.CreateDataFormat();

            ICellStyle style;
            IFont headerFont = wb.CreateFont();
            headerFont.Boldweight = (short)(FontBoldWeight.BOLD);
            style = CreateBorderedStyle(wb);
            style.Alignment = HorizontalAlignment.CENTER;
            style.FillForegroundColor = (IndexedColors.LIGHT_CORNFLOWER_BLUE.Index);
            style.FillPattern = FillPatternType.SOLID_FOREGROUND;
            style.SetFont(headerFont);
            styles.Add("header", style);

            style = CreateBorderedStyle(wb);
            style.Alignment = HorizontalAlignment.CENTER;
            style.FillForegroundColor = (IndexedColors.LIGHT_CORNFLOWER_BLUE.Index);
            style.FillPattern = FillPatternType.SOLID_FOREGROUND;
            style.SetFont(headerFont);
            style.DataFormat = (df.GetFormat("d-mmm"));
            styles.Add("header_date", style);

            IFont font1 = wb.CreateFont();
            font1.Boldweight = (short)(FontBoldWeight.BOLD);
            style = CreateBorderedStyle(wb);
            style.Alignment = HorizontalAlignment.CENTER;
            style.SetFont(font1);
            styles.Add("cell_b", style);

            style = CreateBorderedStyle(wb);
            style.Alignment = HorizontalAlignment.CENTER;
            style.SetFont(font1);
            styles.Add("cell_b_centered", style);

            style = CreateBorderedStyle(wb);
            style.Alignment = HorizontalAlignment.CENTER;
            style.SetFont(font1);
            style.DataFormat = (df.GetFormat("d-mmm"));
            styles.Add("cell_b_date", style);

            style = CreateBorderedStyle(wb);
            style.Alignment = HorizontalAlignment.CENTER;
            style.SetFont(font1);
            style.FillForegroundColor = (IndexedColors.GREY_25_PERCENT.Index);
            style.FillPattern = FillPatternType.SOLID_FOREGROUND;
            style.DataFormat = (df.GetFormat("d-mmm"));
            styles.Add("cell_g", style);

            IFont font2 = wb.CreateFont();
            font2.Color = (IndexedColors.BLUE.Index);
            font2.Boldweight = (short)(FontBoldWeight.BOLD);
            style = CreateBorderedStyle(wb);
            style.Alignment = HorizontalAlignment.CENTER;
            style.SetFont(font2);
            styles.Add("cell_bb", style);

            style = CreateBorderedStyle(wb);
            style.Alignment = HorizontalAlignment.CENTER;
            style.SetFont(font1);
            style.FillForegroundColor = (IndexedColors.GREY_25_PERCENT.Index);
            style.FillPattern = FillPatternType.SOLID_FOREGROUND;
            style.DataFormat = (df.GetFormat("d-mmm"));
            styles.Add("cell_bg", style);

            IFont font3 = wb.CreateFont();
            font3.FontHeightInPoints = ((short)14);
            font3.Color = (IndexedColors.DARK_BLUE.Index);
            font3.Boldweight = (short)(FontBoldWeight.BOLD);
            style = CreateBorderedStyle(wb);
            style.Alignment = HorizontalAlignment.CENTER;
            style.SetFont(font3);
            style.WrapText = (true);
            styles.Add("cell_h", style);

            style = CreateBorderedStyle(wb);
            style.Alignment = HorizontalAlignment.CENTER;
            style.WrapText = (true);
            styles.Add("cell_normal", style);

            style = CreateBorderedStyle(wb);
            style.Alignment = HorizontalAlignment.CENTER;
            style.WrapText = (true);
            styles.Add("cell_normal_centered", style);

            style = CreateBorderedStyle(wb);
            style.Alignment = HorizontalAlignment.CENTER;
            style.WrapText = (true);
            style.DataFormat = (df.GetFormat("d-mmm"));
            styles.Add("cell_normal_date", style);

            style = CreateBorderedStyle(wb);
            style.Alignment = HorizontalAlignment.CENTER;
            style.Indention = ((short)1);
            style.WrapText = (true);
            styles.Add("cell_indented", style);

//.........这里部分代码省略.........
开发者ID:hanwangkun,项目名称:npoi,代码行数:101,代码来源:Program.cs

示例9: Getcellstyle

        public static ICellStyle Getcellstyle(IWorkbook wb, stylexls str)
        {
            ICellStyle cellStyle = wb.CreateCellStyle();

            //定义几种字体
            //也可以一种字体,写一些公共属性,然后在下面需要时加特殊的
            IFont font10 = wb.CreateFont();
            font10.FontHeightInPoints = 10;
            font10.FontName = "宋体";
            font10.Boldweight = 700;

            IFont font12 = wb.CreateFont();
            font12.FontHeightInPoints = 10;
            font12.FontName = "宋体";
            font12.Boldweight = 700;

            IFont fontw = wb.CreateFont();
            fontw.FontName = "宋体";
            fontw.Boldweight = 700;

            IFont font14 = wb.CreateFont();
            font14.FontHeightInPoints = 14;
            font14.FontName = "宋体";
            font14.Boldweight = 700;

            IFont font = wb.CreateFont();
            font.FontHeightInPoints = 10;
            font.FontName = "宋体";

            IFont fontHT = wb.CreateFont();
            fontHT.FontHeightInPoints = 10;
            fontHT.FontName = "宋体";
            //font.Underline = 1;下划线

            IFont fontcolorblue = wb.CreateFont();
            fontcolorblue.Color = HSSFColor.OliveGreen.Blue.Index;
            fontcolorblue.IsItalic = true;//下划线
            fontcolorblue.FontName = "宋体";

            //边框
            cellStyle.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
            cellStyle.BorderLeft = NPOI.SS.UserModel.BorderStyle.None;
            cellStyle.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;
            cellStyle.BorderTop = NPOI.SS.UserModel.BorderStyle.None;
            //边框颜色
            cellStyle.BottomBorderColor = HSSFColor.OliveGreen.Black.Index;
            cellStyle.TopBorderColor = HSSFColor.OliveGreen.Black.Index;

            //背景图形,我没有用到过。感觉很丑
            //cellStyle.FillBackgroundColor = HSSFColor.OLIVE_GREEN.BLUE.index;
            //cellStyle.FillForegroundColor = HSSFColor.OLIVE_GREEN.BLUE.index;

            // cellStyle.FillPattern = FillPatternType.NO_FILL;
            //cellStyle.FillBackgroundColor = NPOI.HSSF.Util.HSSFColor.Blue.Index2;

            //水平对齐
            cellStyle.Alignment = HorizontalAlignment.Left;

            //垂直对齐
            cellStyle.VerticalAlignment = VerticalAlignment.Center;

            //自动换行
            cellStyle.WrapText = true;

            //缩进;当设置为1时,前面留的空白太大了。希旺官网改进。或者是我设置的不对
            cellStyle.Indention = 0;

            //上面基本都是设共公的设置
            //下面列出了常用的字段类型
            switch (str)
            {
                case stylexls.投缴头:
                    cellStyle.FillForegroundColor = HSSFColor.PaleBlue.Index;
                    cellStyle.FillPattern = FillPattern.SolidForeground;
                    cellStyle.SetFont(font12);
                    cellStyle.VerticalAlignment = VerticalAlignment.Top;
                    //水平对齐
                    cellStyle.Alignment = HorizontalAlignment.Center;
                    break;
                case stylexls.月报头:
                    cellStyle.FillForegroundColor = HSSFColor.Rose.Index;
                    cellStyle.FillPattern = FillPattern.SolidForeground;
                    cellStyle.SetFont(font10);
                    cellStyle.VerticalAlignment = VerticalAlignment.Top;
                    //水平对齐
                    cellStyle.Alignment = HorizontalAlignment.Center;
                    break;
                case stylexls.月报底:
                    cellStyle.FillForegroundColor = HSSFColor.Rose.Index;
                    cellStyle.FillPattern = FillPattern.SolidForeground;
                    cellStyle.SetFont(font10);
                    cellStyle.VerticalAlignment = VerticalAlignment.Top;
                    //水平对齐
                    cellStyle.Alignment = HorizontalAlignment.Left;
                    break;
                case stylexls.月报内容:
                    cellStyle.FillForegroundColor = HSSFColor.White.Index;
                    cellStyle.FillPattern = FillPattern.SolidForeground;
                    cellStyle.SetFont(font10);
                    cellStyle.VerticalAlignment = VerticalAlignment.Top;
//.........这里部分代码省略.........
开发者ID:wangyi3330,项目名称:wpfTest,代码行数:101,代码来源:ToEcxel.cs

示例10: createStyles

        private static Dictionary<String, ICellStyle> createStyles(IWorkbook wb)
        {
            Dictionary<String, ICellStyle> styles = new Dictionary<String, ICellStyle>();
            IDataFormat df = wb.CreateDataFormat();

            ICellStyle style;
            IFont headerFont = wb.CreateFont();
            headerFont.Boldweight = (short)(FontBoldWeight.Bold);
            style = CreateBorderedStyle(wb);
            style.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;
            style.FillForegroundColor = (IndexedColors.LightCornflowerBlue.Index);
            style.FillPattern = FillPattern.SolidForeground;
            style.SetFont(headerFont);
            styles.Add("header", style);

            style = CreateBorderedStyle(wb);
            style.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;
            style.FillForegroundColor = (IndexedColors.LightCornflowerBlue.Index);
            style.FillPattern = FillPattern.SolidForeground;
            style.SetFont(headerFont);
            style.DataFormat = (df.GetFormat("d-mmm"));
            styles.Add("header_date", style);

            IFont font1 = wb.CreateFont();
            font1.Boldweight = (short)(FontBoldWeight.Bold);
            style = CreateBorderedStyle(wb);
            style.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;
            style.SetFont(font1);
            styles.Add("cell_b", style);

            style = CreateBorderedStyle(wb);
            style.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;
            style.SetFont(font1);
            styles.Add("cell_b_centered", style);

            style = CreateBorderedStyle(wb);
            style.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;
            style.SetFont(font1);
            style.DataFormat = (df.GetFormat("d-mmm"));
            styles.Add("cell_b_date", style);

            style = CreateBorderedStyle(wb);
            style.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;
            style.SetFont(font1);
            style.FillForegroundColor = (IndexedColors.Grey25Percent.Index);
            style.FillPattern = FillPattern.SolidForeground;
            style.DataFormat = (df.GetFormat("d-mmm"));
            styles.Add("cell_g", style);

            IFont font2 = wb.CreateFont();
            font2.Color = (IndexedColors.Blue.Index);
            font2.Boldweight = (short)(FontBoldWeight.Bold);
            style = CreateBorderedStyle(wb);
            style.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;
            style.SetFont(font2);
            styles.Add("cell_bb", style);

            style = CreateBorderedStyle(wb);
            style.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;
            style.SetFont(font1);
            style.FillForegroundColor = (IndexedColors.Grey25Percent.Index);
            style.FillPattern = FillPattern.SolidForeground;
            style.DataFormat = (df.GetFormat("d-mmm"));
            styles.Add("cell_bg", style);

            IFont font3 = wb.CreateFont();
            font3.FontHeightInPoints = ((short)14);
            font3.Color = (IndexedColors.DarkBlue.Index);
            font3.Boldweight = (short)(FontBoldWeight.Bold);
            style = CreateBorderedStyle(wb);
            style.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;
            style.SetFont(font3);
            style.WrapText = (true);
            styles.Add("cell_h", style);

            style = CreateBorderedStyle(wb);
            style.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;
            style.WrapText = (true);
            styles.Add("cell_normal", style);

            style = CreateBorderedStyle(wb);
            style.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;
            style.WrapText = (true);
            styles.Add("cell_normal_centered", style);

            style = CreateBorderedStyle(wb);
            style.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;
            style.WrapText = (true);
            style.DataFormat = (df.GetFormat("d-mmm"));
            styles.Add("cell_normal_date", style);

            style = CreateBorderedStyle(wb);
            style.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;
            style.Indention = ((short)1);
            style.WrapText = (true);
            styles.Add("cell_indented", style);

            style = CreateBorderedStyle(wb);
            style.FillForegroundColor = (IndexedColors.Blue.Index);
            style.FillPattern = FillPattern.SolidForeground;
//.........这里部分代码省略.........
开发者ID:mxx42,项目名称:VkParser,代码行数:101,代码来源:Form1.cs

示例11: CreateStyles

        /**
 * cell styles used for formatting calendar sheets
 */
        private static Dictionary<String, ICellStyle> CreateStyles(IWorkbook wb)
        {
            Dictionary<String, ICellStyle> styles = new Dictionary<String, ICellStyle>();

            ICellStyle style=null;
            IFont titleFont = wb.CreateFont();
            titleFont.FontHeightInPoints = (short)14;
            titleFont.FontName = "Trebuchet MS";
            style = wb.CreateCellStyle();
            style.SetFont(titleFont);
            style.BorderBottom = BorderStyle.DOTTED;
            style.BottomBorderColor = IndexedColors.GREY_40_PERCENT.Index;
            styles.Add("title", style);

            IFont itemFont = wb.CreateFont();
            itemFont.FontHeightInPoints = (short)9;
            itemFont.FontName = "Trebuchet MS";
            style = wb.CreateCellStyle();
            style.Alignment = (HorizontalAlignment.LEFT);
            style.SetFont(itemFont);
            styles.Add("item_left", style);

            style = wb.CreateCellStyle();
            style.Alignment = HorizontalAlignment.RIGHT;
            style.SetFont(itemFont);
            styles.Add("item_right", style);

            style = wb.CreateCellStyle();
            style.Alignment = HorizontalAlignment.RIGHT;
            style.SetFont(itemFont);
            style.BorderRight = BorderStyle.DOTTED;
            style.RightBorderColor = IndexedColors.GREY_40_PERCENT.Index;
            style.BorderBottom = BorderStyle.DOTTED;
            style.BottomBorderColor = IndexedColors.GREY_40_PERCENT.Index;
            style.BorderLeft = BorderStyle.DOTTED;
            style.LeftBorderColor = IndexedColors.GREY_40_PERCENT.Index;
            style.BorderTop = BorderStyle.DOTTED;
            style.TopBorderColor = IndexedColors.GREY_40_PERCENT.Index;
            style.DataFormat = (wb.CreateDataFormat().GetFormat("_($* #,##0.00_);_($* (#,##0.00);_($* \"-\"??_);_(@_)"));
            styles.Add("input_$", style);

            style = wb.CreateCellStyle();
            style.Alignment = HorizontalAlignment.RIGHT;
            style.SetFont(itemFont);
            style.BorderRight = BorderStyle.DOTTED;
            style.RightBorderColor = IndexedColors.GREY_40_PERCENT.Index;
            style.BorderBottom = BorderStyle.DOTTED;
            style.BottomBorderColor = IndexedColors.GREY_40_PERCENT.Index;
            style.BorderLeft = BorderStyle.DOTTED;
            style.LeftBorderColor = IndexedColors.GREY_40_PERCENT.Index;
            style.BorderTop = BorderStyle.DOTTED;
            style.TopBorderColor = IndexedColors.GREY_40_PERCENT.Index;
            style.DataFormat = (wb.CreateDataFormat().GetFormat("0.000%"));
            styles.Add("input_%", style);

            style = wb.CreateCellStyle();
            style.Alignment = HorizontalAlignment.RIGHT;
            style.SetFont(itemFont);
            style.BorderRight = BorderStyle.DOTTED;
            style.RightBorderColor = IndexedColors.GREY_40_PERCENT.Index;
            style.BorderBottom = BorderStyle.DOTTED;
            style.BottomBorderColor = IndexedColors.GREY_40_PERCENT.Index;
            style.BorderLeft = BorderStyle.DOTTED;
            style.LeftBorderColor = IndexedColors.GREY_40_PERCENT.Index;
            style.BorderTop = BorderStyle.DOTTED;
            style.TopBorderColor = IndexedColors.GREY_40_PERCENT.Index;
            style.DataFormat =wb.CreateDataFormat().GetFormat("0");
            styles.Add("input_i", style);

            style = wb.CreateCellStyle();
            style.Alignment = (HorizontalAlignment.CENTER);
            style.SetFont(itemFont);
            style.DataFormat =wb.CreateDataFormat().GetFormat("m/d/yy");
            styles.Add("input_d", style);

            style = wb.CreateCellStyle();
            style.Alignment = HorizontalAlignment.RIGHT;
            style.SetFont(itemFont);
            style.BorderRight = BorderStyle.DOTTED;
            style.RightBorderColor = IndexedColors.GREY_40_PERCENT.Index;
            style.BorderBottom = BorderStyle.DOTTED;
            style.BottomBorderColor = IndexedColors.GREY_40_PERCENT.Index;
            style.BorderLeft = BorderStyle.DOTTED;
            style.LeftBorderColor = IndexedColors.GREY_40_PERCENT.Index;
            style.BorderTop = BorderStyle.DOTTED;
            style.TopBorderColor = IndexedColors.GREY_40_PERCENT.Index;
            style.DataFormat =wb.CreateDataFormat().GetFormat("$##,##0.00");
            style.BorderBottom = BorderStyle.DOTTED;
            style.BottomBorderColor = IndexedColors.GREY_40_PERCENT.Index;
            style.FillForegroundColor = IndexedColors.GREY_25_PERCENT.Index;
            style.FillPattern = FillPatternType.SOLID_FOREGROUND;
            styles.Add("formula_$", style);

            style = wb.CreateCellStyle();
            style.Alignment = HorizontalAlignment.RIGHT;
            style.SetFont(itemFont);
            style.BorderRight = BorderStyle.DOTTED;
//.........这里部分代码省略.........
开发者ID:xoposhiy,项目名称:npoi,代码行数:101,代码来源:Program.cs

示例12: CreateHeaderStyle

            private static ICellStyle CreateHeaderStyle(IWorkbook wb)
            {
                IFont font = wb.CreateFont();
                font.Color = (/*setter*/ IndexedColors.WHITE.Index);
                font.Boldweight = (short)(/*setter*/FontBoldWeight.BOLD);

                ICellStyle cellStyle = wb.CreateCellStyle();
                cellStyle.FillForegroundColor = (/*setter*/IndexedColors.BLUE_GREY.Index);
                cellStyle.FillPattern = (/*setter*/FillPatternType.SOLID_FOREGROUND);
                cellStyle.Alignment = (/*setter*/HorizontalAlignment.CENTER);
                cellStyle.VerticalAlignment = (/*setter*/VerticalAlignment.CENTER);
                cellStyle.BorderLeft = (/*setter*/BorderStyle.THIN);
                cellStyle.LeftBorderColor = (/*setter*/IndexedColors.WHITE.Index);
                cellStyle.BorderTop = (/*setter*/BorderStyle.THIN);
                cellStyle.TopBorderColor = (/*setter*/IndexedColors.WHITE.Index);
                cellStyle.BorderRight = (/*setter*/BorderStyle.THIN);
                cellStyle.RightBorderColor = (/*setter*/IndexedColors.WHITE.Index);
                cellStyle.BorderBottom = (/*setter*/BorderStyle.THIN);
                cellStyle.BottomBorderColor = (/*setter*/IndexedColors.WHITE.Index);
                cellStyle.SetFont(font);
                return cellStyle;
            }
开发者ID:xoposhiy,项目名称:npoi,代码行数:22,代码来源:BaseTestDataValidation.cs

示例13: CreateStyle

            private static ICellStyle CreateStyle(IWorkbook wb, HorizontalAlignment h_align, short color,
                    bool bold)
            {
                IFont font = wb.CreateFont();
                if (bold)
                {
                    font.Boldweight = (short)(/*setter*/FontBoldWeight.BOLD);
                }

                ICellStyle cellStyle = wb.CreateCellStyle();
                cellStyle.SetFont(font);
                cellStyle.FillForegroundColor = (/*setter*/color);
                cellStyle.FillPattern = (/*setter*/FillPatternType.SOLID_FOREGROUND);
                cellStyle.VerticalAlignment = (/*setter*/VerticalAlignment.CENTER);
                cellStyle.Alignment = (/*setter*/h_align);
                cellStyle.BorderLeft = (/*setter*/BorderStyle.THIN);
                cellStyle.LeftBorderColor = (/*setter*/IndexedColors.BLACK.Index);
                cellStyle.BorderTop = (/*setter*/BorderStyle.THIN);
                cellStyle.TopBorderColor = (/*setter*/IndexedColors.BLACK.Index);
                cellStyle.BorderRight = (/*setter*/BorderStyle.THIN);
                cellStyle.RightBorderColor = (/*setter*/IndexedColors.BLACK.Index);
                cellStyle.BorderBottom = (/*setter*/BorderStyle.THIN);
                cellStyle.BottomBorderColor = (/*setter*/IndexedColors.BLACK.Index);

                return cellStyle;
            }
开发者ID:xoposhiy,项目名称:npoi,代码行数:26,代码来源:BaseTestDataValidation.cs

示例14: GetCellStyle

        /// <summary>
        /// 获取单元格样式
        /// </summary>
        /// <param name="hssfworkbook"></param>
        /// <param name="type">1表示有边框,0表示没有边框</param>
        /// <returns></returns>
        protected ICellStyle GetCellStyle(IWorkbook hssfworkbook, int type)
        {
            ICellStyle cellstyle = hssfworkbook.CreateCellStyle();

            cellstyle.Alignment = HorizontalAlignment.Center;
            cellstyle.VerticalAlignment = VerticalAlignment.Center;
            IFont fontLeft = hssfworkbook.CreateFont();
            //字号
            fontLeft.FontHeightInPoints = 16;
            //字体
            fontLeft.FontName = "宋体";
            cellstyle.SetFont(fontLeft);
            if (type == 1)
            {
                //有边框
                cellstyle.BorderBottom = BorderStyle.Thin;
                cellstyle.BorderLeft = BorderStyle.Thin;
                cellstyle.BorderRight = BorderStyle.Thin;
                cellstyle.BorderTop = BorderStyle.Thin;
            }
            else if (type == 0)
            {
                cellstyle.BorderBottom = BorderStyle.None;
                cellstyle.BorderLeft = BorderStyle.None;
                cellstyle.BorderRight = BorderStyle.None;
                cellstyle.BorderTop = BorderStyle.None;
            }
            return cellstyle;
        }
开发者ID:ibcLee,项目名称:Wttech.DataSubmitted,代码行数:35,代码来源:ReportRelated.cs

示例15: GetHeaderCellStyle

 static ICellStyle GetHeaderCellStyle(IWorkbook book)
 {
     ICellStyle style = book.CreateCellStyle();
     style.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin;
     style.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;
     style.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
     style.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
     style.FillForegroundColor = HSSFColor.LightTurquoise.Index;
     style.FillPattern = FillPattern.SolidForeground;
     IFont font = book.CreateFont();
     font.FontHeightInPoints = 10;
     font.Boldweight = (short)FontBoldWeight.Bold;
     style.SetFont(font);
     return style;
 }
开发者ID:eolandezhang,项目名称:Diagram,代码行数:15,代码来源:ExportHelper.cs


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