1 2 17 18 19 package org.apache.poi.hssf.util; 20 21 import junit.framework.TestCase; 22 23 import org.apache.poi.hssf.usermodel.HSSFCell; 24 import org.apache.poi.hssf.usermodel.HSSFRow; 25 import org.apache.poi.hssf.usermodel.HSSFSheet; 26 27 public class TestAreaReference extends TestCase { 28 public TestAreaReference(String s) { 29 super(s); 30 } 31 public void testAreaRef1() { 32 AreaReference ar = new AreaReference("$A$1:$B$2"); 33 assertTrue("Two cells expected",ar.getCells().length == 2); 34 CellReference cf = ar.getCells()[0]; 35 assertTrue("row is 4",cf.getRow()==0); 36 assertTrue("col is 1",cf.getCol()==0); 37 assertTrue("row is abs",cf.isRowAbsolute()); 38 assertTrue("col is abs",cf.isColAbsolute()); 39 assertTrue("string is $A$1",cf.toString().equals("$A$1")); 40 41 cf = ar.getCells()[1]; 42 assertTrue("row is 4",cf.getRow()==1); 43 assertTrue("col is 1",cf.getCol()==1); 44 assertTrue("row is abs",cf.isRowAbsolute()); 45 assertTrue("col is abs",cf.isColAbsolute()); 46 assertTrue("string is $B$2",cf.toString().equals("$B$2")); 47 } 48 49 53 public void testReferenceWithSheet() { 54 String ref = "Tabelle1!$B$5"; 55 AreaReference myAreaReference = new AreaReference(ref); 56 CellReference[] myCellReference = myAreaReference.getCells(); 57 58 assertNotNull("cell reference not null : "+myCellReference[0]); 59 assertEquals("Not Column B", (short)1,myCellReference[0].getCol()); 60 assertEquals("Not Row 5", 4,myCellReference[0].getRow()); 61 } 62 63 public static void main(java.lang.String [] args) { 64 junit.textui.TestRunner.run(TestAreaReference.class); 65 } 66 67 } 68 | Popular Tags |