[]
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.
IStyle Add(string name, IRange baseOn = null)
Function Add(name As String, Optional baseOn As IRange = Nothing) As IStyle
| 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 |
| Type | Description |
|---|---|
| IStyle | The new IStyle. |
IRange cell = worksheet.Range["A1"];
cell.Font.Bold = true;
IStyle style = workbook.Styles.Add("HeaderStyle", cell);
worksheet.Range["B1"].Style = style;
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.
IStyle Add(string name, IStyle baseOn)
Function Add(name As String, baseOn As IStyle) As IStyle
| Type | Name | Description |
|---|---|---|
| string | name | The new IStyle name. |
| IStyle | baseOn | The IStyle to use as the basis for the new style. |
| Type | Description |
|---|---|
| IStyle | The new IStyle. |
IStyle baseStyle = workbook.Styles["Good"];
IStyle style = workbook.Styles.Add("MyGood", baseStyle);
style.Font.Italic = true;
worksheet.Range["A1"].Style = style;