/// <summary>
/// 应用样式
/// </summary>
public void ApplyStyle()
{
object missingValue = Type.Missing;
Excel.Range rng = workSheet.get_Range("B3","L23");
Excel.Style style;
try
{
style = workBook.Styles["NewStyle"];
}
// Style doesn't exist yet.
catch
{
style = workBook.Styles.Add("NewStyle", missingValue);
style.Font.Name = "Verdana";
style.Font.Size = 12;
style.Font.Color = 255;
style.Interior.Color = (200 << 16) | (200 << 8) | 200;
style.Interior.Pattern = Excel.XlPattern.xlPatternSolid;
}
rng.Value2 = "'Style Test";
rng.Style = "NewStyle";
rng.Columns.AutoFit();
}