Font Settings
Configuring Font Settings
Aspose.Cells provides a class, Workbook that represents a Microsoft Excel file. The Workbook class contains a Worksheets collection that allows access to each worksheet in an Excel file. A worksheet is represented by the Worksheet class. The Worksheet class provides a Cells collection. Each item in the Cells collection represents an object of the Cell class.
Aspose.Cells provides the Cell class' GetStyle and SetStyle methods which are used to get and set a cell’s formatting style. The Style class provides properties for configuring font settings.
Setting Font Name
Developers can apply any font to text inside a cell by using the Style.Font object’s Name property.
Setting Font Style to Bold
Developers can make text bold by setting the Style.Font object’s IsBold property to true.
Setting Font Size
Set the font size with the Style.Font object’s Size property.
Setting Font Color
Use the Style.Font object’s Color property to set the font color. Select any color from the Color enumeration (part of the .NET framework) and assign it to the Color property.
Setting Font Underline Type
Use the Style.Font object’s Underline property to underline text. Aspose.Cells offers various pre-defined font underline types in the FontUnderlineType enumeration.
Font Underline Types | Description |
---|---|
Accounting | A single accounting underline |
Double | Double underline |
DoubleAccounting | Double accounting underline |
None | No underline |
Single | A single underline |
Setting Strikeout Effect
Apply strikeout by setting the Style.Font object’s IsStrikeout property to true.
Setting Subscript Effect
Apply subscript by setting the Style.Font object’s IsSubScript property to true.
Setting Superscript Effect on Font
Developers can apply the superscript effect on the font by setting the IsSuperscript property of the Style.Font object to true.
Advance topics
- Apply Superscript and Subscript Effects on Fonts
- Get a List of Fonts used in a Spreadsheet or Workbook