示例#1
0
        public void TestCantMixTypes()
        {
            HSSFWorkbook workbook = new HSSFWorkbook();
            HSSFSheet    sheet    = workbook.CreateSheet() as HSSFSheet;

            CellRangeAddress[] cellRanges =
            {
                new CellRangeAddress(0, 1, 0, 0),
                new CellRangeAddress(0, 1, 2, 2),
            };
            CFRuleBase[] rules =
            {
                CFRuleRecord.Create(sheet,   "7"),
                CFRule12Record.Create(sheet, (byte)ComparisonOperator.Between,"2",  "5"),
            };
            try
            {
                new CFRecordsAggregate(cellRanges, rules);
                Assert.Fail("Shouldn't be able to mix between types");
            }
            catch (ArgumentException) { }

            rules = new CFRuleBase[] { CFRuleRecord.Create(sheet, "7") };
            CFRecordsAggregate agg = new CFRecordsAggregate(cellRanges, rules);

            Assert.IsTrue(agg.Header.NeedRecalculation);

            try
            {
                agg.AddRule(CFRule12Record.Create(sheet, "7"));
                Assert.Fail("Shouldn't be able to mix between types");
            }
            catch (ArgumentException) { }
        }
 /// <summary>
 /// Add a Conditional Formatting rule.
 /// Excel allows to Create up to 3 Conditional Formatting rules.
 /// </summary>
 /// <param name="cfRule">Conditional Formatting rule</param>
 public void AddRule(HSSFConditionalFormattingRule cfRule)
 {
     cfAggregate.AddRule(cfRule.CfRuleRecord);
 }