Package org.apache.poi.ss.util

Examples of org.apache.poi.ss.util.AreaReference


        assertFalse(AreaReference.isContiguous(refDCSimple));
        assertFalse(AreaReference.isContiguous(refDC2D));
        assertFalse(AreaReference.isContiguous(refDC3D));

        // Check we can only create contiguous entries
        new AreaReference(refSimple);
        new AreaReference(ref2D);
        try {
            new AreaReference(refDCSimple);
            fail();
        } catch(IllegalArgumentException e) {
          // expected during successful test
        }
        try {
            new AreaReference(refDC2D);
            fail();
        } catch(IllegalArgumentException e) {
          // expected during successful test
        }
        try {
            new AreaReference(refDC3D);
            fail();
        } catch(IllegalArgumentException e) {
          // expected during successful test
        }
View Full Code Here


        assertEquals(2, arefs.length);
        assertEquals(refA, arefs[0].formatAsString());
        assertEquals(refB, arefs[1].formatAsString());

        for(int i=0; i<arefs.length; i++) {
            AreaReference ar = arefs[i];
            confirmResolveCellRef(wb, ar.getFirstCell());
            confirmResolveCellRef(wb, ar.getLastCell());
        }
    }
View Full Code Here

        HSSFCell c = r.getCell((int)cref.getCol());
        assertNotNull(c);
    }

    public void testSpecialSheetNames() {
        AreaReference ar;
        ar = new AreaReference("'Sheet A'!A1:A1");
        confirmAreaSheetName(ar, "Sheet A", "'Sheet A'!A1");

        ar = new AreaReference("'Hey! Look Here!'!A1:A1");
        confirmAreaSheetName(ar, "Hey! Look Here!", "'Hey! Look Here!'!A1");

        ar = new AreaReference("'O''Toole'!A1:B2");
        confirmAreaSheetName(ar, "O'Toole", "'O''Toole'!A1:B2");

        ar = new AreaReference("'one:many'!A1:B2");
        confirmAreaSheetName(ar, "one:many", "'one:many'!A1:B2");
    }
View Full Code Here

        confirmWholeColumnRef("$C:D", 2, 3, true, false);
        confirmWholeColumnRef("AD:$AE", 29, 30, false, true);
    }

    private static void confirmWholeColumnRef(String ref, int firstCol, int lastCol, boolean firstIsAbs, boolean lastIsAbs) {
        AreaReference ar = new AreaReference(ref);
        confirmCell(ar.getFirstCell(), 0, firstCol, true, firstIsAbs);
        confirmCell(ar.getLastCell(), 0xFFFF, lastCol, true, lastIsAbs);
    }
View Full Code Here

        ptg = new RefPtg(cr);
      } else {
        ptg = new Ref3DPtg(cr, extIx);
      }
    } else {
      AreaReference areaRef = createAreaRef(part1, part2);

      if (sheetIden == null) {
        ptg = new AreaPtg(areaRef);
      } else {
        ptg = new Area3DPtg(areaRef, extIx);
View Full Code Here

      return AreaReference.getWholeRow(part1.getRep(), part2.getRep());
    }
    if (part1.isColumn()) {
      return AreaReference.getWholeColumn(part1.getRep(), part2.getRep());
    }
    return new AreaReference(part1.getCellReference(), part2.getCellReference());
  }
View Full Code Here

*
*/
public final class TestAreaReference extends TestCase {

    public void testAreaRef1() {
        AreaReference ar = new AreaReference("$A$1:$B$2");
        assertFalse("Two cells expected", ar.isSingleCell());
        CellReference cf = ar.getFirstCell();
        assertTrue("row is 4",cf.getRow()==0);
        assertTrue("col is 1",cf.getCol()==0);
        assertTrue("row is abs",cf.isRowAbsolute());
        assertTrue("col is abs",cf.isColAbsolute());
        assertTrue("string is $A$1",cf.formatAsString().equals("$A$1"));

        cf = ar.getLastCell();
        assertTrue("row is 4",cf.getRow()==1);
        assertTrue("col is 1",cf.getCol()==1);
        assertTrue("row is abs",cf.isRowAbsolute());
        assertTrue("col is abs",cf.isColAbsolute());
        assertTrue("string is $B$2",cf.formatAsString().equals("$B$2"));

        CellReference[] refs = ar.getAllReferencedCells();
        assertEquals(4, refs.length);

        assertEquals(0, refs[0].getRow());
        assertEquals(0, refs[0].getCol());
        assertNull(refs[0].getSheetName());
View Full Code Here

    /**
     * References failed when sheet names were being used
     * Reported by Arne.Clauss@gedas.de
     */
    public void testReferenceWithSheet() {
        AreaReference ar;

        ar = new AreaReference("Tabelle1!B5:B5");
        assertTrue(ar.isSingleCell());
        TestCellReference.confirmCell(ar.getFirstCell(), "Tabelle1", 4, 1, false, false, "Tabelle1!B5");

        assertEquals(1, ar.getAllReferencedCells().length);


        ar = new AreaReference("Tabelle1!$B$5:$B$7");
        assertFalse(ar.isSingleCell());

        TestCellReference.confirmCell(ar.getFirstCell(), "Tabelle1", 4, 1, true, true, "Tabelle1!$B$5");
        TestCellReference.confirmCell(ar.getLastCell(), "Tabelle1", 6, 1, true, true, "Tabelle1!$B$7");

        // And all that make it up
        CellReference[] allCells = ar.getAllReferencedCells();
        assertEquals(3, allCells.length);
        TestCellReference.confirmCell(allCells[0], "Tabelle1", 4, 1, true, true, "Tabelle1!$B$5");
        TestCellReference.confirmCell(allCells[1], "Tabelle1", 5, 1, true, true, "Tabelle1!$B$6");
        TestCellReference.confirmCell(allCells[2], "Tabelle1", 6, 1, true, true, "Tabelle1!$B$7");
    }
View Full Code Here

        assertFalse(AreaReference.isContiguous(refDCSimple));
        assertFalse(AreaReference.isContiguous(refDC2D));
        assertFalse(AreaReference.isContiguous(refDC3D));

        // Check we can only create contiguous entries
        new AreaReference(refSimple);
        new AreaReference(ref2D);
        try {
            new AreaReference(refDCSimple);
            fail();
        } catch(IllegalArgumentException e) {
          // expected during successful test
        }
        try {
            new AreaReference(refDC2D);
            fail();
        } catch(IllegalArgumentException e) {
          // expected during successful test
        }
        try {
            new AreaReference(refDC3D);
            fail();
        } catch(IllegalArgumentException e) {
          // expected during successful test
        }
View Full Code Here

        assertEquals(2, arefs.length);
        assertEquals(refA, arefs[0].formatAsString());
        assertEquals(refB, arefs[1].formatAsString());

        for(int i=0; i<arefs.length; i++) {
            AreaReference ar = arefs[i];
            confirmResolveCellRef(wb, ar.getFirstCell());
            confirmResolveCellRef(wb, ar.getLastCell());
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.poi.ss.util.AreaReference

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.