/// <summary> Defines a configuration for a range of cells /// </summary> /// <param name="range"></param> /// <param name="config"></param> public void ConfigureRange(string range, XLRangeConfig config) { if (string.IsNullOrWhiteSpace(range)) { throw new ArgumentNullException(nameof(range)); } if (config == null) { throw new ArgumentNullException(nameof(config)); } int styleId = GetOrAddRangeStyle(config); _rangeConfigs[new XLRange(range, styleId)] = config; }
private int GetOrAddRangeStyle(XLRangeConfig config) { for (int i = 0; i < _styles.Count; i++) { var style = _styles[i]; if (style.BorderId == config.Border.ToInt() && style.FontId == (int)config.Font && style.NumFormatId == (int)config.Format) { return(i); } } _styles.Add(new XLStyle() { BorderId = config.Border.ToInt(), FontId = (int)config.Font, NumFormatId = (int)config.Format }); return(_styles.Count - 1); }