[]
        
(Showing Draft Content)

GrapeCity.Documents.Excel.IStyleCollection.Add

Add Method

Add(string, IRange)

Creates a new IStyle and adds it to the list of styles that are available for the current Workbook.

The new style is based on the style of the specified range. Specify null to base the new style on the Normal style.

Declaration
IStyle Add(string name, IRange baseOn = null)
Function Add(name As String, Optional baseOn As IRange = Nothing) As IStyle
Parameters
Type Name Description
string name

The new IStyle name.

IRange baseOn

The IRange whose cell style is used as the basis for the new style. Specify null to base the new style on the Normal style.

Returns
Type Description
IStyle

The new IStyle.

Examples
IRange cell = worksheet.Range["A1"];
cell.Font.Bold = true;
IStyle style = workbook.Styles.Add("HeaderStyle", cell);
worksheet.Range["B1"].Style = style;

Add(string, IStyle)

Creates a new IStyle and adds it to the list of styles that are available for the current Workbook.

The new style is created by using an existing IStyle as its basis.

Declaration
IStyle Add(string name, IStyle baseOn)
Function Add(name As String, baseOn As IStyle) As IStyle
Parameters
Type Name Description
string name

The new IStyle name.

IStyle baseOn

The IStyle to use as the basis for the new style.

Returns
Type Description
IStyle

The new IStyle.

Examples
IStyle baseStyle = workbook.Styles["Good"];
IStyle style = workbook.Styles.Add("MyGood", baseStyle);
style.Font.Italic = true;
worksheet.Range["A1"].Style = style;