本文整理汇总了C#中Workbook.CreateNewWorkbookFont方法的典型用法代码示例。如果您正苦于以下问题:C# Workbook.CreateNewWorkbookFont方法的具体用法?C# Workbook.CreateNewWorkbookFont怎么用?C# Workbook.CreateNewWorkbookFont使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Workbook
的用法示例。
在下文中一共展示了Workbook.CreateNewWorkbookFont方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplyCellFormatFromStyle
private IWorksheetCellFormat ApplyCellFormatFromStyle(Workbook workbook, IWorksheetCellFormat cellFormat, CssStyle cssStyle, WebDataGrid grid)
{
if (Color.Empty != cssStyle.Background.Color && cssStyle.Background.Color.ToArgb() != Color.White.ToArgb())
{
cellFormat.FillPatternForegroundColor = cssStyle.Background.Color;
cellFormat.FillPattern = FillPatternStyle.Solid;
}
IWorkbookFont newWorkbookFont = workbook.CreateNewWorkbookFont();
newWorkbookFont.Color = grid.ForeColor.IsEmpty ? cssStyle.Color : grid.ForeColor;
newWorkbookFont.Name = string.IsNullOrEmpty(grid.Font.Name) ? cssStyle.Font.FamilyName : grid.Font.Name;
switch (cssStyle.Font.SizeEnum)
{
case Infragistics.Documents.Reports.FontSize.NotSet:
newWorkbookFont.Height = cssStyle.Font.SizeUnit.Type != UnitType.Point || cssStyle.Font.SizeUnit.Value < 1.0 ? (cssStyle.Font.SizeUnit.Type != UnitType.Pixel || cssStyle.Font.SizeUnit.Value < 1.0 ? 240 : (int)(cssStyle.Font.SizeUnit.Value * 20.0)) : (int)(cssStyle.Font.SizeUnit.Value * 20.0);
break;
case Infragistics.Documents.Reports.FontSize.Large:
case Infragistics.Documents.Reports.FontSize.Larger:
newWorkbookFont.Height = 280;
break;
case Infragistics.Documents.Reports.FontSize.Small:
case Infragistics.Documents.Reports.FontSize.Smaller:
newWorkbookFont.Height = 200;
break;
case Infragistics.Documents.Reports.FontSize.X_Large:
newWorkbookFont.Height = 360;
break;
case Infragistics.Documents.Reports.FontSize.X_Small:
newWorkbookFont.Height = 180;
break;
case Infragistics.Documents.Reports.FontSize.XX_Large:
newWorkbookFont.Height = 480;
break;
case Infragistics.Documents.Reports.FontSize.XX_Small:
newWorkbookFont.Height = 160;
break;
default:
newWorkbookFont.Height = 240;
break;
}
if (cssStyle.Font.IsBold || cssStyle.Font.Style == Infragistics.Documents.Reports.FontStyle.Oblique || grid.Font.Bold)
newWorkbookFont.Bold = ExcelDefaultableBoolean.True;
if (cssStyle.Font.IsItalic || cssStyle.Font.Style == Infragistics.Documents.Reports.FontStyle.Italic || grid.Font.Italic)
newWorkbookFont.Italic = ExcelDefaultableBoolean.True;
if (cssStyle.TextDecoration == TextDecoration.Line_Through || grid.Font.Strikeout)
newWorkbookFont.Strikeout = ExcelDefaultableBoolean.True;
if (cssStyle.TextDecoration == TextDecoration.Underline || grid.Font.Underline)
newWorkbookFont.UnderlineStyle = FontUnderlineStyle.Single;
cellFormat.Font.SetFontFormatting(newWorkbookFont);
switch (cssStyle.TextAlign)
{
case Infragistics.Documents.Reports.TextAlign.Center:
cellFormat.Alignment = HorizontalCellAlignment.Center;
break;
case Infragistics.Documents.Reports.TextAlign.Justify:
cellFormat.Alignment = HorizontalCellAlignment.Justify;
break;
case Infragistics.Documents.Reports.TextAlign.Left:
cellFormat.Alignment = HorizontalCellAlignment.Left;
break;
case Infragistics.Documents.Reports.TextAlign.Right:
cellFormat.Alignment = HorizontalCellAlignment.Right;
break;
default:
cellFormat.Alignment = HorizontalCellAlignment.General;
break;
}
switch (cssStyle.VerticalAlign)
{
case Infragistics.Documents.Reports.VerticalAlign.Bottom:
cellFormat.VerticalAlignment = VerticalCellAlignment.Bottom;
break;
case Infragistics.Documents.Reports.VerticalAlign.Middle:
cellFormat.VerticalAlignment = VerticalCellAlignment.Center;
break;
case Infragistics.Documents.Reports.VerticalAlign.Top:
cellFormat.VerticalAlignment = VerticalCellAlignment.Top;
break;
default:
cellFormat.VerticalAlignment = VerticalCellAlignment.Default;
break;
}
return cellFormat;
}