Dealing with Font Settings

Configuring Font Settings

Aspose.Cells provides a class, Workbook that represents a Microsoft Excel file. The Workbook class contains a WorksheetCollection 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' setStyle method, used to set a cell’s formatting. Also, the object of the Style class provides properties for configuring font settings.

This article shows how to:

Setting Font Name

Apply a specific font to text in cells using the Font object’s setName property.

Setting Font Style to Bold

Set text to bold by setting the Font object’s setBold property to true.

Setting Font Size

Set the font size using the Font object’s setSize property.

Setting Font Underline Type

Underline text with the Font object’s setUnderline property. Aspose.Cells offers various pre-defined font underline types in the FontUnderlineType enumeration.

Font Underline Types Description
NONE No underline
SINGLE A single underline
DOUBLE Double underline
ACCOUNTING A single accounting underline
DOUBLE_ACCOUNTING Double accounting underline
DASH Dashed Underline
DASH_DOT_DOT_HEAVY Thick Dash-Dot-Dot Underline
DASH_DOT_HEAVY Thick Dash-Dot Underline
DASHED_HEAVY Thick Dashed Underline
DASH_LONG Long Dashed Underline
DASH_LONG_HEAVY Thick Long Dashed Underline
DOT_DASH Dash-Dot Underline
DOT_DOT_DASH Dash-Dot-Dot Underline
DOTTED Dotted Underline
DOTTED_HEAVY Thick Dotted Underline
HEAVY Thick Underline
WAVE Wave Underline
WAVY_DOUBLE Double Wave Underline
WAVY_HEAVY Heavy Wave Underline
 WORDS Underline Non-Space Characters Only

Setting Font Color

Set the font color with the Font object’s setColor property. Select any color from the Color enumeration and assign the selected color to the Font object’s setColor.

Setting Strikeout Effect on Text

Strikeout text with the Font object’s setStrikeout property.

Setting Subscript

Make text superscript by using the Font object’s setSubscript property.

Setting Superscript

Apply superscript to text with the Font object’s setSuperscript property.

Advance topics