文本格式属性

有许多属性可以应用于 RichText 的各个部分。

var title = cell.RichText.Add("This is my title");

// Data Type:     bool
// Default Value: false
title.Bold = true;

// Data Type:     System.Drawing.Color
// Default Value: Color.Black
title.Color = Color.Red;
title.Color = Color.FromArgb(255, 0, 0);
title.Color = ColorTranslator.FromHtml("#FF0000");

// Data Type:     string
// Default Value: "Calibri"
title.FontName = "Verdana";

// Data Type:     bool
// Default Value: false
title.Italic = true;

// Data Type:     bool
// Default Value: true
// If this property is set to false, any whitespace (including new lines) 
// is trimmed from the start and end of the Text
title.PreserveSpace = true;

// Data Type:     float
// Default Value: 11
// The font size is specified in Points
title.Size = 16;

// Data Type:     bool
// Default Value: false
// Strikethrough
title.Strike = false;

// Data Type:     string
// Default Value: Whatever was set when the text was added to the RichText collection
title.Text += " (updated)";

// Data Type:     bool
// Default Value: false
title.UnderLine = true;

// Data Type:     OfficeOpenXml.Style.ExcelVerticalAlignmentFont
// Default Value: ExcelVerticalAlignmentFont.None
title.VerticalAlign = ExcelVerticalAlignmentFont.None;