文字格式屬性

有許多屬性可以應用於 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;