public static FontUnderline ValueOf(FontUnderlineType value) { FontUnderline val; switch (value) { case FontUnderlineType.DOUBLE: val = FontUnderline.DOUBLE; break; case FontUnderlineType.DOUBLE_ACCOUNTING: val = FontUnderline.DOUBLE_ACCOUNTING; break; case FontUnderlineType.SINGLE_ACCOUNTING: val = FontUnderline.SINGLE_ACCOUNTING; break; case FontUnderlineType.SINGLE: val = FontUnderline.SINGLE; break; default: val = FontUnderline.NONE; break; } return(val); }
public static Cell SetFontUnderline(this Cell cell, FontUnderlineType value) { var style = cell.GetStyle(); style.Font.Underline = value; cell.SetStyle(style); return(cell); }
public static IList <Column> SetFontUnderline(this IList <Column> columns, FontUnderlineType value, params int[] columnIndexes) { foreach (var i in columnIndexes) { columns[i].SetFontUnderline(value); } return(columns); }
public static Range SetFontUnderline(this Range range, FontUnderlineType value) { var style = new Style(); style.Font.Underline = value; range.ApplyStyle(style, new StyleFlag { FontUnderline = true }); return(range); }
public static Row SetFontUnderline(this Row row, FontUnderlineType value) { var style = row.Style; style.Font.Underline = value; row.ApplyStyle(style, new StyleFlag { FontUnderline = true }); return(row); }
public static Column SetFontUnderline(this Column column, FontUnderlineType value) { var style = column.Style; style.Font.Underline = value; column.ApplyStyle(style, new StyleFlag { FontUnderline = true }); return(column); }
public static Cells SetFontUnderline(this Cells cells, FontUnderlineType value) { var style = new Style(); style.Font.Underline = value; cells.ApplyStyle(style, new StyleFlag { FontUnderline = true }); return(cells); }
/// <summary> /// 设置下划线 /// </summary> /// <param name="cell"></param> /// <param name="dbLine"></param> /// <param name="lineType"></param> public static void SetUnderline(this ICell cell, bool dbLine = false, FontUnderlineType lineType = FontUnderlineType.Single) { if (cell == null) { return; } cell.DealParam(); IFont font = cellStyle.GetFont(workBook); font.Underline = lineType; cellStyle.SetFont(font); cell.CellStyle = cellStyle; }
/** * set an enumeration representing the style of underlining that is used. * The none style is equivalent to not using underlining at all. * The possible values for this attribute are defined by the FontUnderline * * @param underline - FontUnderline enum value */ internal void SetUnderline(FontUnderlineType underline) { if (underline == FontUnderlineType.None) { _ctFont.SetUArray(null); } else { CT_UnderlineProperty ctUnderline = _ctFont.sizeOfUArray() == 0 ? _ctFont.AddNewU() : _ctFont.GetUArray(0); ST_UnderlineValues val = (ST_UnderlineValues)FontUnderline.ValueOf(underline).Value; ctUnderline.val = val; } }
/// <summary> /// Tao font /// </summary> /// <param name="wk">WorkBook</param> /// <param name="Boldweight">Độ đậm - FontBoldWeight</param> /// <param name="color">Màu chữ - FontColor</param> /// <param name="fontsize">cỡ chữ</param> /// <param name="FontName">kiểu chữ</param> /// <param name="IsItalic">in nghiêng</param> /// <param name="Underline">ngạch chân - FontUnderlineType</param> /// <param name="TypeOffset">Vi tri - FontSuperScript</param> /// <returns></returns> /// <modified> /// Author Date comment /// anhhn 15/07/2012 Tạo mới /// </modified> public static IFont CreateFont(this IWorkbook wk, short Boldweight, short color, short fontsize, string FontName, bool IsItalic, FontUnderlineType Underline, FontSuperScript TypeOffset) { IFont result = wk.CreateFont(); result.Boldweight = Boldweight; result.Color = color; result.FontHeightInPoints = fontsize; result.FontName = FontName; result.IsItalic = IsItalic; result.Underline = Underline; result.TypeOffset = TypeOffset; return(result); }
/// <summary> /// 创建一个新的单元格样式对象 /// </summary> public ExcelCellStyle() { // ICellStyle e; _dataFormart = string.Empty; _fontSize = 9; _fontBold = FontBoldWeight.None; _fontName = "Arial"; _alignment = HorizontalAlignment.Left; _verticalAlignment = VerticalAlignment.Center; _borderBottom = BorderStyle.None; _borderLeft = BorderStyle.None; _borderRight = BorderStyle.None; _borderTop = BorderStyle.None; _styleValueIsChange = true; _cellStyle = null; _warpText = false; _underline = FontUnderlineType.None; _fontColor = NPOI.HSSF.Util.HSSFColor.Black.Index; _isItalic = false; _isStrikeout = false; _fontTypeOffset = 0; }
private string GetUnderline(FontUnderlineType fontunderlinetype) { switch (fontunderlinetype) { case FontUnderlineType.Single: return("font-underline:SINGLE;"); case FontUnderlineType.Double: return("font-underline:DOUBLE;"); case FontUnderlineType.SingleAccounting: return("font-underline:SINGLEACCOUNTING;"); case FontUnderlineType.DoubleAccounting: return("font-underline:DOUBLEACCOUNTING;"); case FontUnderlineType.None: return(""); default: return(""); } }
/** * Finds a font that matches the one with the supplied attributes */ public XSSFFont FindFont(short boldWeight, short color, short fontHeight, String name, bool italic, bool strikeout, FontSuperScript typeOffset,FontUnderlineType underline) { foreach (XSSFFont font in fonts) { if ((font.Boldweight == boldWeight) && font.Color == color && font.FontHeight == fontHeight && font.FontName.Equals(name) && font.IsItalic == italic && font.IsStrikeout == strikeout && font.TypeOffset == typeOffset && font.Underline == underline) { return font; } } return null; }
public static FontUnderline ValueOf(FontUnderlineType value) { FontUnderline val; switch (value) { case FontUnderlineType.Double: val = FontUnderline.DOUBLE; break; case FontUnderlineType.DoubleAccounting: val = FontUnderline.DOUBLE_ACCOUNTING; break; case FontUnderlineType.SingleAccounting: val = FontUnderline.SINGLE_ACCOUNTING; break; case FontUnderlineType.Single: val = FontUnderline.SINGLE; break; default: val = FontUnderline.NONE; break; } return val; }
public void AddCellStyle(String StyleName, String FontName = "Arial", Int16 FontSize = 8, Boolean IsItalic = false, FontUnderlineType UnderlineType = FontUnderlineType.None, FontBoldWeight BoldWeight = FontBoldWeight.None, HorizontalAlignment HorizontalAlign = HorizontalAlignment.Left, VerticalAlignment VerticalAlign = VerticalAlignment.Top, BorderStyle TopBorder = BorderStyle.None, BorderStyle BottomBorder = BorderStyle.None, BorderStyle RightBorder = BorderStyle.None, BorderStyle LeftBorder = BorderStyle.None, IndexedColors FontColor = null, IndexedColors BackgroundColor = null, short HSSFBackgroundColorIndex = 64, byte[] XSSFColorByte = null) { IFont font = this.hssworkbook.CreateFont(); font.Color = ((FontColor == null) ? IndexedColors.Black.Index : FontColor.Index); font.FontName = FontName; font.FontHeightInPoints = FontSize; font.IsItalic = IsItalic; if (font.Underline != FontUnderlineType.None) { font.Underline = UnderlineType; } font.Boldweight = (short)BoldWeight; if (this.IsNewFormat) { XSSFCellStyle style = (XSSFCellStyle)this.hssworkbook.CreateCellStyle(); style.SetFont(font); style.Alignment = HorizontalAlign; style.VerticalAlignment = VerticalAlign; style.BorderTop = TopBorder; style.BorderBottom = BottomBorder; style.BorderRight = RightBorder; style.BorderLeft = LeftBorder; if (BackgroundColor != null) { style.FillForegroundColor = BackgroundColor.Index; style.FillPattern = FillPattern.SolidForeground; } if (XSSFColorByte != null) { style.FillPattern = FillPattern.SolidForeground; style.FillForegroundXSSFColor = new XSSFColor(XSSFColorByte); } if (!this.XFontStyle.ContainsKey(StyleName)) { this.XFontStyle.Add(StyleName, style); } else { this.XFontStyle[StyleName] = style; } } else { HSSFCellStyle style2 = (HSSFCellStyle)this.hssworkbook.CreateCellStyle(); style2.SetFont(font); style2.Alignment = HorizontalAlign; style2.VerticalAlignment = VerticalAlign; style2.BorderTop = TopBorder; style2.BorderBottom = BottomBorder; style2.BorderRight = RightBorder; style2.BorderLeft = LeftBorder; if (BackgroundColor != null) { style2.FillForegroundColor = BackgroundColor.Index; style2.FillPattern = FillPattern.SolidForeground; } else if (HSSFBackgroundColorIndex != 64) { style2.FillPattern = FillPattern.SolidForeground; style2.FillForegroundColor = HSSFBackgroundColorIndex; } if (!this.HFontStyle.ContainsKey(StyleName)) { this.HFontStyle.Add(StyleName, style2); } else { this.HFontStyle[StyleName] = style2; } } }
/// <summary> /// 字体样式(下划线) /// </summary> /// <param name="startRow">起始行</param> /// <param name="startColumn">起始列</param> /// <param name="endRow">结束行</param> /// <param name="endColumn">结束列</param> /// <param name="underline">下划线类型</param> public void FontUnderline(int startRow, int startColumn, int endRow, int endColumn, FontUnderlineType underline) { ICellStyle style = _myExcel.CreateCellStyle(); //新建一个字体样式对象 IFont font = _myExcel.CreateFont(); font.Underline = underline; style.SetFont(font); for (int rowIndex = startRow; rowIndex <= endRow; rowIndex++) { IRow row = _activeSheet.GetRow(rowIndex); if (null == row) { row = _activeSheet.CreateRow(rowIndex); } for (int colIndex = startColumn; colIndex <= endColumn; colIndex++) { ICell cell = row.GetCell(colIndex); if (null == cell) { cell = row.CreateCell(colIndex); } cell.CellStyle = style; } } }
public IFont FindFont(short boldWeight, short color, short fontHeight, string name, bool italic, bool strikeout, FontSuperScript typeOffset, FontUnderlineType underline) { return(XssfWorkbook.FindFont(boldWeight, color, fontHeight, name, italic, strikeout, typeOffset, underline)); }
/** * Finds a font that matches the one with the supplied attributes */ public IFont FindFont(short boldWeight, short color, short fontHeight, String name, bool italic, bool strikeout,FontSuperScript typeOffset, FontUnderlineType underline) { return stylesSource.FindFont(boldWeight, color, fontHeight, name, italic, strikeout, typeOffset, underline); }
public static Style SetFontUnderline(this Style style, FontUnderlineType value) { style.Font.Underline = value; return(style); }
/// <summary> /// 行内单元格常用样式设置 /// </summary> /// <param name="workbook">“Excel”文件对象</param> /// <param name="hAlignment">水平布局方式</param> /// <param name="vAlignment">垂直布局方式</param> /// <param name="fontHeightInPoints">字体大小</param> /// <param name="isAddBorder">是否需要边框</param> /// <param name="boldWeight">字体加粗 (None = 0,Normal = 400,Bold = 700</param> /// <param name="fontName">字体(仿宋,楷体,宋体,微软雅黑...与Excel主题字体相对应)</param> /// <param name="isAddBorderColor">是否增加边框颜色</param> /// <param name="isItalic">是否将文字变为斜体</param> /// <param name="isLineFeed">是否自动换行</param> /// <param name="isAddCellBackground">是否增加单元格背景颜色</param> /// <param name="fillPattern">填充图案样式(FineDots 细点,SolidForeground立体前景,isAddFillPattern=true时存在)</param> /// <param name="cellBackgroundColor">单元格背景颜色(当isAddCellBackground=true时存在)</param> /// <param name="fontColor">字体颜色</param> /// <param name="underlineStyle">下划线样式(无下划线[None],单下划线[Single],双下划线[Double],会计用单下划线[SingleAccounting],会计用双下划线[DoubleAccounting])</param> /// <param name="typeOffset">字体上标下标(普通默认值[None],上标[Sub],下标[Super]),即字体在单元格内的上下偏移量</param> /// <param name="isStrikeout">是否显示删除线</param> /// <returns></returns> public static HSSFCellStyle CreateStyle(HSSFWorkbook workbook, HorizontalAlignment hAlignment, VerticalAlignment vAlignment , short fontHeightInPoints, bool isAddBorder, short boldWeight, string fontName = "宋体", bool isAddBorderColor = true , bool isItalic = false, bool isLineFeed = false, bool isAddCellBackground = false, FillPattern fillPattern = FillPattern.NoFill , short cellBackgroundColor = HSSFColor.Yellow.Index, short fontColor = HSSFColor.Black.Index , FontUnderlineType underlineStyle = FontUnderlineType.None, FontSuperScript typeOffset = FontSuperScript.None, bool isStrikeout = false) { HSSFCellStyle cellStyle = (HSSFCellStyle)workbook.CreateCellStyle(); //创建列头单元格实例样式 cellStyle.Alignment = hAlignment; //水平居中 cellStyle.VerticalAlignment = vAlignment; //垂直居中 cellStyle.WrapText = isLineFeed; //自动换行 //背景颜色,边框颜色,字体颜色都是使用 HSSFColor属性中的对应调色板索引,关于 HSSFColor 颜色索引对照表,详情参考:https://www.cnblogs.com/Brainpan/p/5804167.html //TODO:引用了NPOI后可通过ICellStyle 接口的 FillForegroundColor 属性实现 Excel 单元格的背景色设置,FillPattern 为单元格背景色的填充样式 //TODO:十分注意,要设置单元格背景色必须是FillForegroundColor和FillPattern两个属性同时设置,否则是不会显示背景颜色 if (isAddCellBackground) { cellStyle.FillForegroundColor = cellBackgroundColor; //单元格背景颜色 cellStyle.FillPattern = fillPattern; //填充图案样式(FineDots 细点,SolidForeground立体前景) } //是否增加边框 if (isAddBorder) { //常用的边框样式 None(没有),Thin(细边框,瘦的),Medium(中等),Dashed(虚线),Dotted(星罗棋布的),Thick(厚的),Double(双倍),Hair(头发)[上右下左顺序设置] cellStyle.BorderBottom = BorderStyle.Thin; cellStyle.BorderRight = BorderStyle.Thin; cellStyle.BorderTop = BorderStyle.Thin; cellStyle.BorderLeft = BorderStyle.Thin; } //是否设置边框颜色 if (isAddBorderColor) { //边框颜色[上右下左顺序设置] cellStyle.TopBorderColor = HSSFColor.DarkGreen.Index;//DarkGreen(黑绿色) cellStyle.RightBorderColor = HSSFColor.DarkGreen.Index; cellStyle.BottomBorderColor = HSSFColor.DarkGreen.Index; cellStyle.LeftBorderColor = HSSFColor.DarkGreen.Index; } /** * 设置相关字体样式 */ var cellStyleFont = (HSSFFont)workbook.CreateFont(); //创建字体 //假如字体大小只需要是粗体的话直接使用下面该属性即可 //cellStyleFont.IsBold = true; cellStyleFont.Boldweight = boldWeight; //字体加粗 cellStyleFont.FontHeightInPoints = fontHeightInPoints; //字体大小 cellStyleFont.FontName = fontName; //字体(仿宋,楷体,宋体 ) cellStyleFont.Color = fontColor; //设置字体颜色 cellStyleFont.IsItalic = isItalic; //是否将文字变为斜体 cellStyleFont.Underline = underlineStyle; //字体下划线 cellStyleFont.TypeOffset = typeOffset; //字体上标下标 cellStyleFont.IsStrikeout = isStrikeout; //是否有删除线 cellStyle.SetFont(cellStyleFont); //将字体绑定到样式 return(cellStyle); }
//public NPOI.SS.UserModel.Font FindFont(NPOI.SS.UserModel.FontBoldWeight boldWeight, short color, short fontHeight, // String name, bool italic, bool strikeout, // NPOI.SS.UserModel.FontSuperScript typeOffset, NPOI.SS.UserModel.FontUnderlineType Underline) //{ // return this.FindFont(boldWeight, color, fontHeight, name, italic, strikeout, typeOffset, Underline); //} /// <summary> /// Finds a font that matches the one with the supplied attributes /// </summary> /// <param name="boldWeight">The bold weight.</param> /// <param name="color">The color.</param> /// <param name="fontHeight">Height of the font.</param> /// <param name="name">The name.</param> /// <param name="italic">if set to <c>true</c> [italic].</param> /// <param name="strikeout">if set to <c>true</c> [strikeout].</param> /// <param name="typeOffset">The type offset.</param> /// <param name="Underline">The underline.</param> /// <returns></returns> public NPOI.SS.UserModel.IFont FindFont(short boldWeight, short color, short fontHeight, String name, bool italic, bool strikeout, FontSuperScript typeOffset, FontUnderlineType underline) { // Console.WriteLine( boldWeight + ", " + color + ", " + fontHeight + ", " + name + ", " + italic + ", " + strikeout + ", " + typeOffset + ", " + Underline ); for (short i = 0; i <= this.NumberOfFonts; i++) { // Remember - there is no 4! if (i == 4) continue; NPOI.SS.UserModel.IFont hssfFont = GetFontAt(i); // Console.WriteLine( hssfFont.GetBoldweight() + ", " + hssfFont.GetColor() + ", " + hssfFont.FontHeight + ", " + hssfFont.FontName + ", " + hssfFont.GetItalic() + ", " + hssfFont.GetStrikeout() + ", " + hssfFont.GetTypeOffset() + ", " + hssfFont.Underline ); if (hssfFont.Boldweight == boldWeight && hssfFont.Color == color && hssfFont.FontHeight == fontHeight && hssfFont.FontName.Equals(name) && hssfFont.IsItalic == italic && hssfFont.IsStrikeout == strikeout && hssfFont.TypeOffset == typeOffset && hssfFont.Underline == underline) { // Console.WriteLine( "Found font" ); return hssfFont; } } // Console.WriteLine( "No font found" ); return null; }
public CStyleApplier Underline(FontUnderlineType value = FontUnderlineType.Single) { Font.Underline = value; return(this); }
/** * set an enumeration representing the style of underlining that is used. * The none style is equivalent to not using underlining at all. * The possible values for this attribute are defined by the FontUnderline * * @param underline - FontUnderline enum value */ internal void SetUnderline(FontUnderlineType underline) { if (underline == FontUnderlineType.None && _ctFont.sizeOfUArray() > 0) { _ctFont.SetUArray(null); } else { CT_UnderlineProperty ctUnderline = _ctFont.sizeOfUArray() == 0 ? _ctFont.AddNewU() : _ctFont.GetUArray(0); ST_UnderlineValues val = (ST_UnderlineValues)FontUnderline.ValueOf(underline).Value; ctUnderline.val = val; } }
/// <summary> /// 字体样式(加粗,斜体,下划线) /// </summary> /// <param name="startRow">起始行</param> /// <param name="startColumn">起始列</param> /// <param name="endRow">结束行</param> /// <param name="endColumn">结束列</param> /// <param name="isBold">是否加粗</param> /// <param name="isItalic">是否斜体</param> /// <param name="underline">下划线类型</param> public void FontStyle(int startRow, int startColumn, int endRow, int endColumn, short boldWeight, bool isItalic, FontUnderlineType underline) { ICellStyle style = _myExcel.CreateCellStyle(); IFont font = _myExcel.CreateFont(); font.Boldweight = boldWeight; font.IsItalic = isItalic; font.Underline = underline; style.SetFont(font); for (int rowIndex = startRow; rowIndex <= endRow; rowIndex++) { IRow row = _activeSheet.GetRow(rowIndex); if (null == row) { row = _activeSheet.CreateRow(rowIndex); } for (int colIndex = startColumn; colIndex <= endColumn; colIndex++) { ICell cell = row.GetCell(colIndex); if (null == cell) { cell = row.CreateCell(colIndex); } cell.CellStyle = style; } } }
/// <summary> /// 下划线 /// </summary> /// <param name="type"></param> /// <returns></returns> public ExcelStyle Underline(FontUnderlineType type) { _font.Underline = type; return(this); }
/// <summary> /// Conver Excel Undeline to Word Underline /// </summary> /// <param name="underlineType">Excel UnderlineType</param> /// <returns>Word Underline</returns> private Underline ConvertUnderline(FontUnderlineType underlineType) { Underline wordsUnderline = Underline.None; switch (underlineType) { case FontUnderlineType.Accounting: { wordsUnderline = Underline.Wavy; break; } case FontUnderlineType.Double: { wordsUnderline = Underline.Double; break; } case FontUnderlineType.DoubleAccounting: { wordsUnderline = Underline.WavyDouble; break; } case FontUnderlineType.None: { wordsUnderline = Underline.None; break; } case FontUnderlineType.Single: { wordsUnderline = Underline.Single; break; } default: { wordsUnderline = Underline.None; break; } } return wordsUnderline; }
/// <summary> /// 设置单元格字体样式(居中、是否边框、是否加粗、是否斜体、字体大小、字体类型名称、字体颜色、下划线模式) alignmentType意义:0居左,1居中 /// </summary> /// <param name="startRow"></param> /// <param name="startColumn"></param> /// <param name="endRow"></param> /// <param name="endColumn"></param> /// <param name="alignmentType"></param> /// <param name="isFrame"></param> /// <param name="isBold"></param> /// <param name="isItalic"></param> /// <param name="fontSize"></param> /// <param name="color"></param> /// <param name="underline"></param> public void SetCellStyle(int startRow, int startColumn, int endRow, int endColumn, int alignmentType, bool isFrame, bool isBold, bool isItalic, short fontSize, string strFontName = "宋体", ColorIndex color = ColorIndex.Black, ColorIndex backColor = ColorIndex.White, FontUnderlineType underline = FontUnderlineType.None) { ICellStyle style = _myExcel.CreateCellStyle(); if (0 == alignmentType) //居左 { style.Alignment = HorizontalAlignment.Left; style.VerticalAlignment = VerticalAlignment.Center; } else if (1 == alignmentType) //居中 { style.Alignment = HorizontalAlignment.Center; style.VerticalAlignment = VerticalAlignment.Center; } //边框 if (isFrame) { style.BorderBottom = BorderStyle.Thin; style.BorderLeft = BorderStyle.Thin; style.BorderRight = BorderStyle.Thin; style.BorderTop = BorderStyle.Thin; style.BottomBorderColor = HSSFColor.Black.Index; style.LeftBorderColor = HSSFColor.Black.Index; style.RightBorderColor = HSSFColor.Black.Index; style.TopBorderColor = HSSFColor.Black.Index; } //背景色(默认白色,不起作用) if (ColorIndex.White != backColor) { style.FillForegroundColor = (short)backColor; style.FillPattern = FillPattern.SolidForeground; } //新建一个字体样式对象 IFont font = _myExcel.CreateFont(); //加粗 if (isBold) { font.Boldweight = Convert.ToInt16(NPOI.SS.UserModel.FontBoldWeight.Bold); } //是否斜体 font.IsItalic = isItalic; //字号大小 font.FontHeightInPoints = fontSize; //字体颜色 font.Color = (short)color; //下划线 font.Underline = underline; //字体类型 font.FontName = strFontName; style.SetFont(font); for (int rowIndex = startRow; rowIndex <= endRow; rowIndex++) { IRow row = _activeSheet.GetRow(rowIndex); if (null == row) { row = _activeSheet.CreateRow(rowIndex); } for (int colIndex = startColumn; colIndex <= endColumn; colIndex++) { ICell cell = row.GetCell(colIndex); if (null == cell) { cell = row.CreateCell(colIndex); } cell.CellStyle = style; } } }
/// <summary> /// Sets the underline type. /// </summary> /// <param name="cell">The cell.</param> /// <param name="underline">The underline type.</param> /// <returns>A <seealso cref="FluentCell"/>, for further styling.</returns> public static FluentCell Underline(this ICell cell, FontUnderlineType underline) { return(new FluentCell(cell).Underline(underline)); }
/** * Finds a font that matches the one with the supplied attributes */ public XSSFFont FindFont(short boldWeight, short color, short fontHeight, String name, bool italic, bool strikeout, FontSuperScript typeOffset, FontUnderlineType underline) { foreach (XSSFFont font in fonts) { if ((font.Boldweight == boldWeight) && font.Color == color && font.FontHeight == fontHeight && font.FontName.Equals(name) && font.IsItalic == italic && font.IsStrikeout == strikeout && font.TypeOffset == typeOffset && font.Underline == underline) { return(font); } } return(null); }
/// <summary> /// 创建字体 /// </summary> /// <param name="workbook">Excel对象</param> /// <param name="fontName">字体名</param> /// <param name="color">字体颜色</param> /// <param name="fontSize">字体大小</param> /// <param name="isItalic">斜体</param> /// <param name="isStrikeOut">粗体</param> /// <param name="underline">下划线</param> /// <returns></returns> public static IFont CreateFont(IWorkbook workbook, string fontName, short color = 0, short fontSize = 10, bool isItalic = false, bool isStrikeOut = false, FontUnderlineType underline = FontUnderlineType.None) { IFont font = workbook.CreateFont(); if (!string.IsNullOrEmpty(fontName)) { font.FontName = fontName; } if (color > 0) { font.Color = color; } font.IsItalic = isItalic; font.IsStrikeout = isStrikeOut; //不加此判断:XSSF会有问题 if (font.Underline != FontUnderlineType.None) { font.Underline = underline; } font.FontHeightInPoints = fontSize; //HSSF与HSSX对此属性的实现不一致 //font.FontHeight = fontSize; return(font); }
/// <summary> /// Sets the underline type. /// </summary> /// <param name="underline">The underline.</param> /// <returns>The cell.</returns> public FluentCell Underline(FontUnderlineType underline) { Style.Underline = underline; return(this); }
/// <summary> /// Sets the underline type. /// </summary> /// <param name="underline">The underline.</param> /// <returns>The cell.</returns> public FluentCell Underline(FontUnderlineType underline) { Style.Underline = underline; return this; }