Search in sources :

Example 1 with CellRangeAddress8Bit

use of org.apache.poi.hssf.util.CellRangeAddress8Bit in project poi by apache.

the class FormulaRecordAggregate method setArrayFormula.

public void setArrayFormula(CellRangeAddress r, Ptg[] ptgs) {
    ArrayRecord arr = new ArrayRecord(Formula.create(ptgs), new CellRangeAddress8Bit(r.getFirstRow(), r.getLastRow(), r.getFirstColumn(), r.getLastColumn()));
    _sharedValueManager.addArrayRecord(arr);
}
Also used : ArrayRecord(org.apache.poi.hssf.record.ArrayRecord) CellRangeAddress8Bit(org.apache.poi.hssf.util.CellRangeAddress8Bit)

Example 2 with CellRangeAddress8Bit

use of org.apache.poi.hssf.util.CellRangeAddress8Bit in project poi by apache.

the class FormulaRecordAggregate method getArrayFormulaRange.

public CellRangeAddress getArrayFormulaRange() {
    if (_sharedFormulaRecord != null) {
        throw new IllegalStateException("not an array formula cell.");
    }
    CellReference expRef = _formulaRecord.getFormula().getExpReference();
    if (expRef == null) {
        throw new IllegalStateException("not an array formula cell.");
    }
    ArrayRecord arec = _sharedValueManager.getArrayRecord(expRef.getRow(), expRef.getCol());
    if (arec == null) {
        throw new IllegalStateException("ArrayRecord was not found for the locator " + expRef.formatAsString());
    }
    CellRangeAddress8Bit a = arec.getRange();
    return new CellRangeAddress(a.getFirstRow(), a.getLastRow(), a.getFirstColumn(), a.getLastColumn());
}
Also used : ArrayRecord(org.apache.poi.hssf.record.ArrayRecord) CellRangeAddress8Bit(org.apache.poi.hssf.util.CellRangeAddress8Bit) CellRangeAddress(org.apache.poi.ss.util.CellRangeAddress) CellReference(org.apache.poi.ss.util.CellReference)

Example 3 with CellRangeAddress8Bit

use of org.apache.poi.hssf.util.CellRangeAddress8Bit in project poi by apache.

the class SelectionRecord method serialize.

@Override
public void serialize(LittleEndianOutput out) {
    out.writeByte(getPane());
    out.writeShort(getActiveCellRow());
    out.writeShort(getActiveCellCol());
    out.writeShort(getActiveCellRef());
    int nRefs = field_6_refs.length;
    out.writeShort(nRefs);
    for (CellRangeAddress8Bit field_6_ref : field_6_refs) {
        field_6_ref.serialize(out);
    }
}
Also used : CellRangeAddress8Bit(org.apache.poi.hssf.util.CellRangeAddress8Bit)

Example 4 with CellRangeAddress8Bit

use of org.apache.poi.hssf.util.CellRangeAddress8Bit in project poi by apache.

the class TestArrayRecord method testRead.

public void testRead() {
    String hex = "21 02 25 00 01 00 01 00 01 01 00 00 00 00 00 00 " + "17 00 65 00 00 01 00 02 C0 02 C0 65 00 00 01 00 " + "03 C0 03 C0 04 62 01 07 00";
    byte[] data = HexRead.readFromString(hex);
    RecordInputStream in = TestcaseRecordInputStream.create(data);
    ArrayRecord r1 = new ArrayRecord(in);
    CellRangeAddress8Bit range = r1.getRange();
    assertEquals(1, range.getFirstColumn());
    assertEquals(1, range.getLastColumn());
    assertEquals(1, range.getFirstRow());
    assertEquals(1, range.getLastRow());
    Ptg[] ptg = r1.getFormulaTokens();
    assertEquals("MAX(C1:C2-D1:D2)", FormulaRenderer.toFormulaString(null, ptg));
    //construct a new ArrayRecord with the same contents as r1
    Ptg[] fmlaPtg = FormulaParser.parse("MAX(C1:C2-D1:D2)", null, FormulaType.ARRAY, 0);
    ArrayRecord r2 = new ArrayRecord(Formula.create(fmlaPtg), new CellRangeAddress8Bit(1, 1, 1, 1));
    byte[] ser = r2.serialize();
    //serialize and check that the data is the same as in r1
    assertEquals(HexDump.toHex(data), HexDump.toHex(ser));
}
Also used : Ptg(org.apache.poi.ss.formula.ptg.Ptg) CellRangeAddress8Bit(org.apache.poi.hssf.util.CellRangeAddress8Bit)

Example 5 with CellRangeAddress8Bit

use of org.apache.poi.hssf.util.CellRangeAddress8Bit in project poi by apache.

the class TestTableRecord method testLoad.

public void testLoad() {
    TableRecord record = new TableRecord(TestcaseRecordInputStream.create(0x236, data));
    CellRangeAddress8Bit range = record.getRange();
    assertEquals(3, range.getFirstRow());
    assertEquals(8, range.getLastRow());
    assertEquals(4, range.getFirstColumn());
    assertEquals(6, range.getLastColumn());
    assertEquals(0, record.getFlags());
    assertEquals(4, record.getRowInputRow());
    assertEquals(1, record.getColInputRow());
    assertEquals(0x4076, record.getRowInputCol());
    assertEquals(0, record.getColInputCol());
    assertEquals(16 + 4, record.getRecordSize());
}
Also used : CellRangeAddress8Bit(org.apache.poi.hssf.util.CellRangeAddress8Bit)

Aggregations

CellRangeAddress8Bit (org.apache.poi.hssf.util.CellRangeAddress8Bit)8 ArrayRecord (org.apache.poi.hssf.record.ArrayRecord)2 CellRangeAddress (org.apache.poi.ss.util.CellRangeAddress)2 SharedValueRecordBase (org.apache.poi.hssf.record.SharedValueRecordBase)1 Ptg (org.apache.poi.ss.formula.ptg.Ptg)1 CellReference (org.apache.poi.ss.util.CellReference)1