Search in sources :

Example 6 with SharedFormulaRecord

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

the class FormulaRecordAggregate method visitContainedRecords.

public void visitContainedRecords(RecordVisitor rv) {
    rv.visitRecord(_formulaRecord);
    Record sharedFormulaRecord = _sharedValueManager.getRecordForFirstCell(this);
    if (sharedFormulaRecord != null) {
        rv.visitRecord(sharedFormulaRecord);
    }
    if (_formulaRecord.hasCachedResultString() && _stringRecord != null) {
        rv.visitRecord(_stringRecord);
    }
}
Also used : Record(org.apache.poi.hssf.record.Record) StringRecord(org.apache.poi.hssf.record.StringRecord) ArrayRecord(org.apache.poi.hssf.record.ArrayRecord) SharedFormulaRecord(org.apache.poi.hssf.record.SharedFormulaRecord) FormulaRecord(org.apache.poi.hssf.record.FormulaRecord)

Example 7 with SharedFormulaRecord

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

the class TestSharedValueManager method testCompletelyOverlappedRanges.

/**
	 * This bug occurs for similar reasons to the bug in {@link #testPartiallyOverlappingRanges()}
	 * but the symptoms are much uglier - serialization fails with {@link NullPointerException}.<br/>
	 */
public void testCompletelyOverlappedRanges() {
    Record[] records;
    int attempt = 1;
    do {
        HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook(SAMPLE_FILE_NAME);
        HSSFSheet sheet = wb.getSheetAt(1);
        try {
            records = RecordInspector.getRecords(sheet, 0);
        } catch (NullPointerException e) {
            throw new AssertionFailedError("Identified bug " + "- cannot reserialize completely overlapped shared formula" + " (attempt " + attempt + ")");
        }
    } while (attempt++ < MAX_ATTEMPTS);
    int count = 0;
    for (Record record : records) {
        if (record instanceof SharedFormulaRecord) {
            count++;
        }
    }
    assertEquals(2, count);
}
Also used : SharedFormulaRecord(org.apache.poi.hssf.record.SharedFormulaRecord) Record(org.apache.poi.hssf.record.Record) SharedFormulaRecord(org.apache.poi.hssf.record.SharedFormulaRecord) HSSFSheet(org.apache.poi.hssf.usermodel.HSSFSheet) AssertionFailedError(junit.framework.AssertionFailedError) HSSFWorkbook(org.apache.poi.hssf.usermodel.HSSFWorkbook)

Aggregations

SharedFormulaRecord (org.apache.poi.hssf.record.SharedFormulaRecord)7 Record (org.apache.poi.hssf.record.Record)6 FormulaRecord (org.apache.poi.hssf.record.FormulaRecord)4 AssertionFailedError (junit.framework.AssertionFailedError)3 HSSFWorkbook (org.apache.poi.hssf.usermodel.HSSFWorkbook)3 ArrayRecord (org.apache.poi.hssf.record.ArrayRecord)2 BlankRecord (org.apache.poi.hssf.record.BlankRecord)2 MulBlankRecord (org.apache.poi.hssf.record.MulBlankRecord)2 NumberRecord (org.apache.poi.hssf.record.NumberRecord)2 RowRecord (org.apache.poi.hssf.record.RowRecord)2 StringRecord (org.apache.poi.hssf.record.StringRecord)2 WindowTwoRecord (org.apache.poi.hssf.record.WindowTwoRecord)2 HSSFSheet (org.apache.poi.hssf.usermodel.HSSFSheet)2 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1 LastCellOfRowDummyRecord (org.apache.poi.hssf.eventusermodel.dummyrecord.LastCellOfRowDummyRecord)1 MissingCellDummyRecord (org.apache.poi.hssf.eventusermodel.dummyrecord.MissingCellDummyRecord)1 MissingRowDummyRecord (org.apache.poi.hssf.eventusermodel.dummyrecord.MissingRowDummyRecord)1 BOFRecord (org.apache.poi.hssf.record.BOFRecord)1 CellValueRecordInterface (org.apache.poi.hssf.record.CellValueRecordInterface)1