本文整理汇总了C#中ICellStyle.GetFont方法的典型用法代码示例。如果您正苦于以下问题:C# ICellStyle.GetFont方法的具体用法?C# ICellStyle.GetFont怎么用?C# ICellStyle.GetFont使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICellStyle
的用法示例。
在下文中一共展示了ICellStyle.GetFont方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildStyle
protected String BuildStyle(IWorkbook workbook, ICellStyle cellStyle)
{
StringBuilder style = new StringBuilder();
if (workbook is HSSFWorkbook)
{
HSSFPalette palette = ((HSSFWorkbook)workbook).GetCustomPalette();
style.Append("white-space: pre-wrap; ");
ExcelToHtmlUtils.AppendAlign(style, cellStyle.Alignment);
if (cellStyle.FillPattern == FillPattern.NoFill)
{
// no fill
}
else if (cellStyle.FillPattern == FillPattern.SolidForeground)
{
//cellStyle.
//HSSFColor.
HSSFColor foregroundColor = palette.GetColor(cellStyle.FillForegroundColor);
if (foregroundColor != null)
style.AppendFormat("background-color:{0}; ", ExcelToHtmlUtils.GetColor(foregroundColor));
}
else
{
HSSFColor backgroundColor = palette.GetColor(cellStyle.FillBackgroundColor);
if (backgroundColor != null)
style.AppendFormat("background-color:{0}; ", ExcelToHtmlUtils.GetColor(backgroundColor));
}
}
else
{
style.Append("white-space: pre-wrap; ");
ExcelToHtmlUtils.AppendAlign(style, cellStyle.Alignment);
StylesTable st = ((XSSFWorkbook)workbook).GetStylesSource();
ThemesTable tt = st.GetTheme();
if (cellStyle.FillPattern == FillPattern.NoFill)
{
// no fill
}
else if (cellStyle.FillPattern == FillPattern.SolidForeground)
{
//cellStyle
IndexedColors clr=IndexedColors.ValueOf(cellStyle.FillForegroundColor);
string hexstring=null;
if(clr!=null)
{
hexstring=clr.HexString;
}else
{
XSSFColor foregroundColor = (XSSFColor)cellStyle.FillForegroundColorColor;
if (foregroundColor != null)
hexstring = ExcelToHtmlUtils.GetColor(foregroundColor);
}
if (hexstring != null)
style.AppendFormat("background-color:{0}; ",hexstring);
}
else
{
IndexedColors clr = IndexedColors.ValueOf(cellStyle.FillBackgroundColor);
string hexstring = null;
if (clr != null)
{
hexstring = clr.HexString;
}
else
{
XSSFColor backgroundColor = (XSSFColor)cellStyle.FillBackgroundColorColor;
if(backgroundColor!=null)
hexstring = ExcelToHtmlUtils.GetColor(backgroundColor);
}
if (hexstring != null)
style.AppendFormat("background-color:{0}; ", hexstring);
}
}
BuildStyle_Border(workbook, style, "top", cellStyle.BorderTop, cellStyle.TopBorderColor);
BuildStyle_Border(workbook, style, "right", cellStyle.BorderRight, cellStyle.RightBorderColor);
BuildStyle_Border(workbook, style, "bottom", cellStyle.BorderBottom, cellStyle.BottomBorderColor);
BuildStyle_Border(workbook, style, "left", cellStyle.BorderLeft, cellStyle.LeftBorderColor);
IFont font = cellStyle.GetFont(workbook);
BuildStyle_Font(workbook, style, font);
return style.ToString();
}