private void InitializingExcelMLStyles(object sender, ExcelMLStylesEventArgs e) { ExcelMLStyle style = new ExcelMLStyle("Header"); style.Font.Bold = true; e.Styles.Add(style); style = new ExcelMLStyle("Cell"); style.Font.Bold = false; e.Styles.Add(style); }
void InitializingExcelMLStyles(object sender, ExcelMLStylesEventArgs e) { foreach (var column in Columns) { ExcelMLStyle style = new ExcelMLStyle(column.ColumnName); if (column.Bold != null) { style.Font.Bold = column.Bold.Value; } if (column.DataFormat != null) { style.NumberFormat.Format = column.DataFormat; } if (column.Font != null) { style.Font.FontName = column.Font.Value.ToString(); } if (column.FontColor != null) { style.Font.Color = string.Format("#{0}", column.FontColor.ToString().Substring(3, 6)); } if (column.HorizontalAlignment != null) { style.Alignment.Horizontal = column.HorizontalAlignment.Value; } if (column.Indent != null) { style.Alignment.Indent = column.Indent.Value; } if (column.InteriorColor != null) { style.Interior.Color = string.Format("#{0}", column.InteriorColor.ToString().Substring(3, 6)); } if (column.InteriorPattern != null) { style.Interior.Pattern = column.InteriorPattern.Value; } if (column.Italic != null) { style.Font.Italic = column.Italic.Value; } if (column.PatternColor != null) { style.Interior.PatternColor = string.Format("#{0}", column.PatternColor.ToString().Substring(3, 6)); } if (column.Rotate != null) { style.Alignment.Rotate = column.Rotate.Value; } if (column.ShrinkToFit != null) { style.Alignment.ShrinkToFit = column.ShrinkToFit.Value; } if (column.FontSize != null) { style.Font.Size = column.FontSize.Value; } if (column.VerticalAlginment != null) { style.Alignment.Vertical = column.VerticalAlginment.Value; } e.Styles.Add(style); } }