9using System.Collections.Generic;
10using NanoXLSX.Exceptions;
23 private List<CellXf> cellXfs =
new List<CellXf>();
24 private List<NumberFormat> numberFormats =
new List<NumberFormat>();
25 private List<Style> styles =
new List<Style>();
26 private List<Border> borders =
new List<Border>();
27 private List<Fill> fills =
new List<Fill>();
28 private List<Font> fonts =
new List<Font>();
29 private List<string> mruColors =
new List<string>();
40 get {
return styles.Count; }
54 Type t = component.GetType();
55 if (t == typeof(CellXf))
57 cellXfs.Add(component as CellXf);
59 else if (t == typeof(NumberFormat))
61 numberFormats.Add(component as NumberFormat);
63 else if (t == typeof(Style))
65 styles.Add(component as Style);
67 else if (t == typeof(Border))
69 borders.Add(component as Border);
71 else if (t == typeof(Fill))
73 fills.Add(component as Fill);
75 else if (t == typeof(Font))
77 fonts.Add(component as Font);
88 return GetComponent(typeof(Style), index) as Style;
98 public Style
GetStyle(
int index, out
bool isDateStyle, out
bool isTimeStyle)
100 Style style = GetComponent(typeof(Style), index) as Style;
105 isDateStyle = NumberFormat.IsDateFormat(style.CurrentNumberFormat.Number);
106 isTimeStyle = NumberFormat.IsTimeFormat(style.CurrentNumberFormat.Number);
118 return GetComponent(typeof(NumberFormat), index) as NumberFormat;
128 return GetComponent(typeof(Border), index) as Border;
138 return GetComponent(typeof(Fill), index) as Fill;
148 return GetComponent(typeof(Font), index) as Font;
166 return cellXfs.Count;
175 return borders.Count;
203 private AbstractStyle GetComponent(Type type,
int index)
207 if (type == typeof(NumberFormat))
210 NumberFormat numberFormat = numberFormats.Find(x => x.InternalID == index);
211 if (numberFormat ==
null)
213 throw new StyleException(
"The number format with the numFmtId: " + index +
" was not found");
217 else if (type == typeof(Style))
219 return styles[index];
221 else if (type == typeof(Border))
223 return borders[index];
225 else if (type == typeof(Fill))
245 internal void AddMruColor(
string value)
247 this.mruColors.Add(value);
254 internal List<string> GetMruColors()
256 return this.mruColors;
Class representing a collection of pre-processed styles and their components. This class is internall...
Fill GetFill(int index)
Returns a fill component by its index.
Style GetStyle(int index)
Returns a whole style by its index.
int GetNextCellXFId()
Gets the next internal id of a cell XF component.
int GetNextBorderId()
Gets the next internal id of a border component.
int StyleCount
Gets the number of resolved styles.
Style GetStyle(int index, out bool isDateStyle, out bool isTimeStyle)
Returns a whole style by its index. It also returns information about the type of the style.
Border GetBorder(int index)
Returns a border component by its index.
int GetNextFillId()
Gets the next internal id of a fill component.
Font GetFont(int index)
Returns a font component by its index.
void AddStyleComponent(AbstractStyle component)
Adds a style component and determines the appropriate type of it automatically.
int GetNextStyleId()
Gets the next internal id of a style.
NumberFormat GetNumberFormat(int index)
Returns a number format component by its index.
int GetNextFontId()
Gets the next internal id of a font component.