Package org.apache.poi.hssf.record

Examples of org.apache.poi.hssf.record.CFHeaderRecord


      rules.add(pRules[i]);
    }
  }

  public CFRecordsAggregate(Region[] regions, CFRuleRecord[] rules) {
    this(new CFHeaderRecord(regions), rules);
  }
View Full Code Here


    if (rec.getSid() != CFHeaderRecord.sid) {
      throw new IllegalStateException("next record sid was " + rec.getSid()
          + " instead of " + CFHeaderRecord.sid + " as expected");
    }

    CFHeaderRecord header = (CFHeaderRecord)rec;
    int nRules = header.getNumberOfConditionalFormats();

    CFRuleRecord[] rules = new CFRuleRecord[nRules];
    int offset = pOffset;
    int countFound = 0;
    while (countFound < rules.length) {
      offset++;
      if(offset>=recs.size()) {
        break;
      }
      rec = (Record)recs.get(offset);
      if(rec instanceof CFRuleRecord) {
        rules[countFound] = (CFRuleRecord) rec;
        countFound++;
      } else {
        break;
      }
    }

    if (countFound < nRules)
    { // TODO -(MAR-2008) can this ever happen? write junit
     
      if (log.check(POILogger.DEBUG))
      {
        log.log(POILogger.DEBUG, "Expected  " + nRules + " Conditional Formats, "
            + "but found " + countFound + " rules");
      }
      header.setNumberOfConditionalFormats(nRules);
      CFRuleRecord[] lessRules = new CFRuleRecord[countFound];
      System.arraycopy(rules, 0, lessRules, 0, countFound);
      rules = lessRules;
    }
    return new CFRecordsAggregate(header, rules);
View Full Code Here

  /**
   * @return array of <tt>Region</tt>s. never <code>null</code>
   */
  public Region[] getFormattingRegions()
  {
    CFHeaderRecord cfh = cfAggregate.getHeader();
    CellRange[] cellRanges = cfh.getCellRanges();
    return CellRange.convertCellRangesToRegions(cellRanges);
  }
View Full Code Here

  public void testCFRecordsAggregate()
  {
    HSSFWorkbook workbook = new HSSFWorkbook();
    List recs = new ArrayList();
    CFHeaderRecord header = new CFHeaderRecord();
    CFRuleRecord rule1 = CFRuleRecord.create(workbook, "7");
    CFRuleRecord rule2 = CFRuleRecord.create(workbook, ComparisonOperator.BETWEEN, "2", "5");
    CFRuleRecord rule3 = CFRuleRecord.create(workbook, ComparisonOperator.GE, "100", null);
    header.setNumberOfConditionalFormats(3);
    CellRange[] cellRanges = {
        new CellRange(0,1,0,0),
        new CellRange(0,1,2,2),
    };
    header.setCellRanges(cellRanges);
    recs.add(header);
    recs.add(rule1);
    recs.add(rule2);
    recs.add(rule3);
    CFRecordsAggregate record;
    record = CFRecordsAggregate.createCFAggregate(recs, 0);

    // Serialize
    byte [] serializedRecord = record.serialize();
    InputStream in = new ByteArrayInputStream(serializedRecord);

    //Parse
    recs = RecordFactory.createRecords(in);

    // Verify
    assertNotNull(recs);
    assertEquals(4, recs.size());

    header = (CFHeaderRecord)recs.get(0);
    rule1 = (CFRuleRecord)recs.get(1);
    rule2 = (CFRuleRecord)recs.get(2);
    rule3 = (CFRuleRecord)recs.get(3);
    cellRanges = header.getCellRanges();

    assertEquals(2, cellRanges.length);
    assertEquals(3, header.getNumberOfConditionalFormats());

    record = CFRecordsAggregate.createCFAggregate(recs, 0);

    record = record.cloneCFAggregate();

    assertNotNull(record.getHeader());
    assertEquals(3,record.getNumberOfRules());

    header = record.getHeader();
    rule1 = record.getRule(0);
    rule2 = record.getRule(1);
    rule3 = record.getRule(2);
    cellRanges = header.getCellRanges();

    assertEquals(2, cellRanges.length);
    assertEquals(3, header.getNumberOfConditionalFormats());
  }
View Full Code Here

      rules.add(pRules[i]);
    }
  }

  public CFRecordsAggregate(CellRangeAddress[] regions, CFRuleRecord[] rules) {
    this(new CFHeaderRecord(regions, rules.length), rules);
  }
View Full Code Here

    if (rec.getSid() != CFHeaderRecord.sid) {
      throw new IllegalStateException("next record sid was " + rec.getSid()
          + " instead of " + CFHeaderRecord.sid + " as expected");
    }

    CFHeaderRecord header = (CFHeaderRecord)rec;
    int nRules = header.getNumberOfConditionalFormats();

    CFRuleRecord[] rules = new CFRuleRecord[nRules];
    for (int i = 0; i < rules.length; i++) {
      rules[i] = (CFRuleRecord) rs.getNext();
    }
View Full Code Here

      rules.add(pRules[i]);
    }
  }

  public CFRecordsAggregate(CellRangeAddress[] regions, CFRuleRecord[] rules) {
    this(new CFHeaderRecord(regions, rules.length), rules);
  }
View Full Code Here

    if (rec.getSid() != CFHeaderRecord.sid) {
      throw new IllegalStateException("next record sid was " + rec.getSid()
          + " instead of " + CFHeaderRecord.sid + " as expected");
    }

    CFHeaderRecord header = (CFHeaderRecord)rec;
    int nRules = header.getNumberOfConditionalFormats();

    CFRuleRecord[] rules = new CFRuleRecord[nRules];
    for (int i = 0; i < rules.length; i++) {
      rules[i] = (CFRuleRecord) rs.getNext();
    }
View Full Code Here

  /**
   * @return array of <tt>Region</tt>s. never <code>null</code>
   */
  public Region[] getFormattingRegions()
  {
    CFHeaderRecord cfh = cfAggregate.getHeader();
    CellRange[] cellRanges = cfh.getCellRanges();
    return CellRange.convertCellRangesToRegions(cellRanges);
  }
View Full Code Here

      rules.add(pRules[i]);
    }
  }

  public CFRecordsAggregate(Region[] regions, CFRuleRecord[] rules) {
    this(new CFHeaderRecord(regions), rules);
  }
View Full Code Here

TOP

Related Classes of org.apache.poi.hssf.record.CFHeaderRecord

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.