/** * @return index of the newly added CF header aggregate */ public int Add(CFRecordsAggregate cfAggregate) { _cfHeaders.Add(cfAggregate); return _cfHeaders.Count - 1; }
/// <summary> /// Allows to Add a new Conditional Formatting Set to the sheet. /// </summary> /// <param name="regions">list of rectangular regions to apply conditional formatting rules</param> /// <param name="cfRules">Set of up to three conditional formatting rules</param> /// <returns>index of the newly Created Conditional Formatting object</returns> public int AddConditionalFormatting(CellRangeAddress[] regions, IConditionalFormattingRule[] cfRules) { if (regions == null) { throw new ArgumentException("regions must not be null"); } if (cfRules == null) { throw new ArgumentException("cfRules must not be null"); } if (cfRules.Length == 0) { throw new ArgumentException("cfRules must not be empty"); } if (cfRules.Length > 3) { throw new ArgumentException("Number of rules must not exceed 3"); } CFRuleRecord[] rules = new CFRuleRecord[cfRules.Length]; for (int i = 0; i != cfRules.Length; i++) { rules[i] = ((HSSFConditionalFormattingRule)cfRules[i]).CfRuleRecord; } CFRecordsAggregate cfra = new CFRecordsAggregate(regions, rules); return _conditionalFormattingTable.Add(cfra); }