Search in sources :

Example 21 with FormulaRecord

use of org.apache.poi.hssf.record.FormulaRecord in project poi by apache.

the class ValueRecordsAggregate method construct.

/**
	 * Processes a single cell value record
	 * @param sfh used to resolve any shared-formulas/arrays/tables for the current sheet
	 */
public void construct(CellValueRecordInterface rec, RecordStream rs, SharedValueManager sfh) {
    if (rec instanceof FormulaRecord) {
        FormulaRecord formulaRec = (FormulaRecord) rec;
        // read optional cached text value
        StringRecord cachedText;
        Class<? extends Record> nextClass = rs.peekNextClass();
        if (nextClass == StringRecord.class) {
            cachedText = (StringRecord) rs.getNext();
        } else {
            cachedText = null;
        }
        insertCell(new FormulaRecordAggregate(formulaRec, cachedText, sfh));
    } else {
        insertCell(rec);
    }
}
Also used : FormulaRecord(org.apache.poi.hssf.record.FormulaRecord) StringRecord(org.apache.poi.hssf.record.StringRecord)

Example 22 with FormulaRecord

use of org.apache.poi.hssf.record.FormulaRecord in project poi by apache.

the class TestSheet method testRowAggregation.

/**
	 * Makes sure all rows registered for this sheet are aggregated, they were being skipped
	 *
	 */
@Test
public void testRowAggregation() {
    List<Record> records = new ArrayList<Record>();
    records.add(InternalSheet.createBOF());
    records.add(new DimensionsRecord());
    records.add(new RowRecord(0));
    records.add(new RowRecord(1));
    FormulaRecord formulaRecord = new FormulaRecord();
    formulaRecord.setCachedResultTypeString();
    records.add(formulaRecord);
    records.add(new StringRecord());
    records.add(new RowRecord(2));
    records.add(createWindow2Record());
    records.add(EOFRecord.instance);
    InternalSheet sheet = createSheet(records);
    assertNotNull("Row [2] was skipped", sheet.getRow(2));
}
Also used : FormulaRecord(org.apache.poi.hssf.record.FormulaRecord) RowRecord(org.apache.poi.hssf.record.RowRecord) ArrayList(java.util.ArrayList) StringRecord(org.apache.poi.hssf.record.StringRecord) GutsRecord(org.apache.poi.hssf.record.GutsRecord) MergeCellsRecord(org.apache.poi.hssf.record.MergeCellsRecord) DrawingRecord(org.apache.poi.hssf.record.DrawingRecord) NoteRecord(org.apache.poi.hssf.record.NoteRecord) Record(org.apache.poi.hssf.record.Record) ObjRecord(org.apache.poi.hssf.record.ObjRecord) EOFRecord(org.apache.poi.hssf.record.EOFRecord) RowRecord(org.apache.poi.hssf.record.RowRecord) ColumnInfoRecord(org.apache.poi.hssf.record.ColumnInfoRecord) WindowTwoRecord(org.apache.poi.hssf.record.WindowTwoRecord) EscherDggRecord(org.apache.poi.ddf.EscherDggRecord) TextObjectRecord(org.apache.poi.hssf.record.TextObjectRecord) IndexRecord(org.apache.poi.hssf.record.IndexRecord) BOFRecord(org.apache.poi.hssf.record.BOFRecord) NumberRecord(org.apache.poi.hssf.record.NumberRecord) MulBlankRecord(org.apache.poi.hssf.record.MulBlankRecord) UncalcedRecord(org.apache.poi.hssf.record.UncalcedRecord) DimensionsRecord(org.apache.poi.hssf.record.DimensionsRecord) BlankRecord(org.apache.poi.hssf.record.BlankRecord) FormulaRecord(org.apache.poi.hssf.record.FormulaRecord) DimensionsRecord(org.apache.poi.hssf.record.DimensionsRecord) StringRecord(org.apache.poi.hssf.record.StringRecord) Test(org.junit.Test)

Aggregations

FormulaRecord (org.apache.poi.hssf.record.FormulaRecord)22 Record (org.apache.poi.hssf.record.Record)8 FormulaRecordAggregate (org.apache.poi.hssf.record.aggregates.FormulaRecordAggregate)8 NumberRecord (org.apache.poi.hssf.record.NumberRecord)7 StringRecord (org.apache.poi.hssf.record.StringRecord)6 BoolErrRecord (org.apache.poi.hssf.record.BoolErrRecord)5 Test (org.junit.Test)5 BlankRecord (org.apache.poi.hssf.record.BlankRecord)4 SharedFormulaRecord (org.apache.poi.hssf.record.SharedFormulaRecord)4 ArrayList (java.util.ArrayList)3 LabelSSTRecord (org.apache.poi.hssf.record.LabelSSTRecord)3 MulBlankRecord (org.apache.poi.hssf.record.MulBlankRecord)3 RowRecord (org.apache.poi.hssf.record.RowRecord)3 WindowTwoRecord (org.apache.poi.hssf.record.WindowTwoRecord)3 Ptg (org.apache.poi.ss.formula.ptg.Ptg)3 AssertionFailedError (junit.framework.AssertionFailedError)2 ArrayRecord (org.apache.poi.hssf.record.ArrayRecord)2 BOFRecord (org.apache.poi.hssf.record.BOFRecord)2 CellValueRecordInterface (org.apache.poi.hssf.record.CellValueRecordInterface)2 ContinueRecord (org.apache.poi.hssf.record.ContinueRecord)2