Beispiel #1
0
 public override void VisitContainedRecords(RecordVisitor rv)
 {
     for (int i = 0; i < _cfHeaders.Count; i++)
     {
         CFRecordsAggregate subAgg = (CFRecordsAggregate)_cfHeaders[i];
         subAgg.VisitContainedRecords(rv);
     }
 }
Beispiel #2
0
        public ConditionalFormattingTable(RecordStream rs)
        {
            IList temp = new ArrayList();

            while (rs.PeekNextClass() == typeof(CFHeaderRecord))
            {
                temp.Add(CFRecordsAggregate.CreateCFAggregate(rs));
            }
            _cfHeaders = temp;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="HSSFConditionalFormatting"/> class.
 /// </summary>
 /// <param name="workbook">The workbook.</param>
 /// <param name="cfAggregate">The cf aggregate.</param>
 public HSSFConditionalFormatting(HSSFWorkbook workbook, CFRecordsAggregate cfAggregate)
 {
     if (workbook == null)
     {
         throw new ArgumentException("workbook must not be null");
     }
     if (cfAggregate == null)
     {
         throw new ArgumentException("cfAggregate must not be null");
     }
     _workbook = workbook;
     this.cfAggregate = cfAggregate;
 }
Beispiel #4
0
 public void UpdateFormulasAfterCellShift(FormulaShifter shifter, int externSheetIndex)
 {
     for (int i = 0; i < _cfHeaders.Count; i++)
     {
         CFRecordsAggregate subAgg = (CFRecordsAggregate)_cfHeaders[i];
         bool shouldKeep           = subAgg.UpdateFormulasAfterCellShift(shifter, externSheetIndex);
         if (!shouldKeep)
         {
             _cfHeaders.RemoveAt(i);
             i--;
         }
     }
 }
 /**
  * @return index of the newly added CF header aggregate
  */
 public int Add(CFRecordsAggregate cfAggregate)
 {
     _cfHeaders.Add(cfAggregate);
     return _cfHeaders.Count - 1;
 }
        public void TestNRules()
        {
            HSSFWorkbook workbook = new HSSFWorkbook();
            HSSFSheet sheet = (HSSFSheet)workbook.CreateSheet();
            CellRangeAddress[] cellRanges = {
				new CellRangeAddress(0,1,0,0),
				new CellRangeAddress(0,1,2,2),
		    };
            CFRuleRecord[] rules = {
			CFRuleRecord.Create(sheet, "7"),
			CFRuleRecord.Create(sheet, (byte)ComparisonOperator.BETWEEN, "2", "5"),
		    };
            CFRecordsAggregate agg = new CFRecordsAggregate(cellRanges, rules);
            byte[] serializedRecord = new byte[agg.RecordSize];
            agg.Serialize(0, serializedRecord);

            int nRules = NPOI.Util.LittleEndian.GetUShort(serializedRecord, 4);
            if (nRules == 0)
            {
                throw new AssertionException("Identified bug 45682 b");
            }
            Assert.AreEqual(rules.Length, nRules);
        }
        /// <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, HSSFConditionalFormattingRule[] 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] = cfRules[i].CfRuleRecord;
            }
            CFRecordsAggregate cfra = new CFRecordsAggregate(regions, rules);
            return _conditionalFormattingTable.Add(cfra);
        }
Beispiel #8
0
 /**
  * @return index of the newly added CF header aggregate
  */
 public int Add(CFRecordsAggregate cfAggregate)
 {
     _cfHeaders.Add(cfAggregate);
     return(_cfHeaders.Count - 1);
 }