Class StylesCollection
A collection of all the Style objects in the specified or active workbook. Each Style object represents a style description for a range. The Style object also contains all style attributes (font, number format, alignment, and so on) as properties. There are several built-in styles � including Normal, Currency, and Percent � which are listed in the Style name box in the Style dialog box (Format menu).
Implements
Inherited Members
Namespace: Syncfusion.XlsIO.Implementation.Collections
Assembly: Syncfusion.XlsIO.Base.dll
Syntax
public class StylesCollection : CollectionBaseEx<IStyle>, IList<IStyle>, ICollection<IStyle>, IEnumerable<IStyle>, IParentApplication, ICloneParent, IStyles, IEnumerable
Constructors
StylesCollection(IApplication, Object)
Creates the collection and sets its Application and Parent properties.
Declaration
public StylesCollection(IApplication application, object parent)
Parameters
Type | Name | Description |
---|---|---|
IApplication | application | The application object for this collection. |
System.Object | parent | The parent object for this collection. |
Properties
Item[String]
Returns a single object from a collection. Read-only.
Declaration
public IStyle this[string name] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.String | name |
Property Value
Type |
---|
IStyle |
Map
Declaration
public Dictionary<StyleImpl, StyleImpl> Map { get; }
Property Value
Type |
---|
System.Collections.Generic.Dictionary<StyleImpl, StyleImpl> |
Methods
Add(IStyle)
Adds specified style into this collection.
Declaration
public void Add(IStyle style)
Parameters
Type | Name | Description |
---|---|---|
IStyle | style | Style that must be added. |
Add(IStyle, Boolean)
Adds specified style to collection.
Declaration
public void Add(IStyle style, bool bReplace)
Parameters
Type | Name | Description |
---|---|---|
IStyle | style | Style to add. |
System.Boolean | bReplace | If true and ContainName then replace old name; otherwise add. |
Add(StyleRecord)
Adds new style to the collection.
Declaration
public StyleImpl Add(StyleRecord style)
Parameters
Type | Name | Description |
---|---|---|
StyleRecord | style | Style to add. |
Returns
Type |
---|
StyleImpl |
Add(String)
Creates a new style and adds it to the list of styles that are available for the current workbook. Returns a Style object.
Declaration
public IStyle Add(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the newly created style. |
Returns
Type | Description |
---|---|
IStyle | Newly created style. |
Add(String, Object)
Creates a new style and adds it to the list of styles that are available for the current workbook. Returns a Style object.
Declaration
public IStyle Add(string name, object BasedOn)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the newly created style. |
System.Object | BasedOn | Prototype for the style. |
Returns
Type | Description |
---|---|
IStyle | Newly created style. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | If name is NULL. |
System.ArgumentException | When collection already contains style with specified name. |
Clone(Object)
Creates copy of the current instance.
Declaration
public override object Clone(object parent)
Parameters
Type | Name | Description |
---|---|---|
System.Object | parent | Parent object for the new collection. |
Returns
Type | Description |
---|---|
System.Object | Copy of the current instance. |
Overrides
CompareBorder(IBorder, IBorder)
Compare Border interfaces.
Declaration
public static bool CompareBorder(IBorder source, IBorder destination)
Parameters
Type | Name | Description |
---|---|---|
IBorder | source | First border to compare. |
IBorder | destination | Second border to compare. |
Returns
Type | Description |
---|---|
System.Boolean | True if borders are the same; otherwise False. |
CompareBorders(IBorders, IBorders)
Compare all Border Collections items.
Declaration
public static bool CompareBorders(IBorders source, IBorders destination)
Parameters
Type | Name | Description |
---|---|---|
IBorders | source | First border to compare. |
IBorders | destination | Second border to compare. |
Returns
Type | Description |
---|---|
System.Boolean | True if borders are the same; otherwise False. |
CompareStyles(IStyle, IStyle)
Compares two styles.
Declaration
public static bool CompareStyles(IStyle source, IStyle destination)
Parameters
Type | Name | Description |
---|---|---|
IStyle | source | The first style to compare. |
IStyle | destination | The second style to compare. |
Returns
Type | Description |
---|---|
System.Boolean | True if styles are the same; otherwise False. |
Contains(String)
Method returns True if collection contains style with specified by user name.
Declaration
public bool Contains(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name to check. |
Returns
Type | Description |
---|---|
System.Boolean | True if style exists; otherwise False. |
ContainsSameStyle(IStyle)
Searches in the collection for style which is same as specified.
Declaration
public IStyle ContainsSameStyle(IStyle style)
Parameters
Type | Name | Description |
---|---|---|
IStyle | style | Style to search. |
Returns
Type | Description |
---|---|
IStyle | Found style or NULL if no same style exists in list. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | If specified style is NULL. |
CreateBuiltInStyle(String)
Creates built in style.
Declaration
public StyleImpl CreateBuiltInStyle(string strName)
Parameters
Type | Name | Description |
---|---|---|
System.String | strName | Name of the style. |
Returns
Type | Description |
---|---|
StyleImpl | Created style. |
GenerateDefaultName(String)
Generates default name.
Declaration
public string GenerateDefaultName(string strStart)
Parameters
Type | Name | Description |
---|---|---|
System.String | strStart | Name prefix. |
Returns
Type | Description |
---|---|
System.String | Automatically generated unique name. |
GenerateDefaultName(String, Dictionary<String, StyleRecord>)
Generates default name.
Declaration
public string GenerateDefaultName(string strStart, Dictionary<string, StyleRecord> hashNamesInFile)
Parameters
Type | Name | Description |
---|---|---|
System.String | strStart | Name prefix. |
System.Collections.Generic.Dictionary<System.String, StyleRecord> | hashNamesInFile | Dictionary with used names. |
Returns
Type | Description |
---|---|
System.String | Automatically generated unique name. |
GetByXFIndex(Int32)
Returns style corresponding to the index of extended format.
Declaration
public StyleImpl GetByXFIndex(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | Index of the extended format to find. |
Returns
Type | Description |
---|---|
StyleImpl | Found style. |
Merge(IWorkbook, ExcelStyleMergeOptions)
Merges styles from specified workbook.
Declaration
public Dictionary<string, string> Merge(IWorkbook workbook, ExcelStyleMergeOptions option)
Parameters
Type | Name | Description |
---|---|---|
IWorkbook | workbook | Source workbook. |
ExcelStyleMergeOptions | option | Merge options. |
Returns
Type | Description |
---|---|
System.Collections.Generic.Dictionary<System.String, System.String> | Dictionary with changed style names, key - old name, value - new name. |
Merge(IWorkbook, ExcelStyleMergeOptions, out Dictionary<Int32, Int32>, out Dictionary<Int32, Int32>)
Merges styles from specified workbook.
Declaration
public Dictionary<string, string> Merge(IWorkbook workbook, ExcelStyleMergeOptions option, out Dictionary<int, int> dicFontIndexes, out Dictionary<int, int> hashExtFormatIndexes)
Parameters
Type | Name | Description |
---|---|---|
IWorkbook | workbook | Source workbook. |
ExcelStyleMergeOptions | option | Merge options. |
System.Collections.Generic.Dictionary<System.Int32, System.Int32> | dicFontIndexes | Returns dictionary with new font indexes. |
System.Collections.Generic.Dictionary<System.Int32, System.Int32> | hashExtFormatIndexes | Dictionary with new indexes of extended formats. |
Returns
Type | Description |
---|---|
System.Collections.Generic.Dictionary<System.String, System.String> | Dictionary with changed style names, key - old name, value - new name. |
Merge(Object)
Merges the styles from another workbook into the Styles collection. Keep only unique style in collection.
Declaration
public IStyles Merge(object Workbook)
Parameters
Type | Name | Description |
---|---|---|
System.Object | Workbook | Workbook from which all styles will be added. |
Returns
Type | Description |
---|---|
IStyles | Merged collection. |
Merge(Object, Boolean)
Merges the styles from another workbook into the Styles collection.
Declaration
public IStyles Merge(object Workbook, bool overwrite)
Parameters
Type | Name | Description |
---|---|---|
System.Object | Workbook | Workbook from which all styles will be added. |
System.Boolean | overwrite | True to overwrite styles with the same names. |
Returns
Type | Description |
---|---|
IStyles | Merged collection. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | If specified Workbook is not WorkbookImpl. |
OnClearComplete()
Performs additional processes after clearing the collection.
Declaration
protected override void OnClearComplete()
Overrides
OnInsertComplete(Int32, IStyle)
Performs additional processes after inserting a new element into the collection.
Declaration
protected override void OnInsertComplete(int index, IStyle value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The zero-based index at which to insert value. |
IStyle | value | The new value of the element at the index. |
Overrides
OnRemoveComplete(Int32, IStyle)
Performs additional processes after removing an element from the collection.
Declaration
protected override void OnRemoveComplete(int index, IStyle value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The zero-based index at which value can be found. |
IStyle | value | The value of the element to remove from the index. |
Overrides
OnSetComplete(Int32, IStyle, IStyle)
Performs additional processes after setting a value in the collection.
Declaration
protected override void OnSetComplete(int index, IStyle oldValue, IStyle newValue)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The zero-based index at which oldValue can be found. |
IStyle | oldValue | The value to replace with newValue. |
IStyle | newValue | The new value of the element at the index. |
Overrides
Remove(String)
Removes style from the collection.
Declaration
public void Remove(string styleName)
Parameters
Type | Name | Description |
---|---|---|
System.String | styleName | Style to remove. |
UpdateStyleRecords()
Updates style record of each style in the collection according to the xf indexes.
Declaration
public void UpdateStyleRecords()