1 16 17 18 package org.apache.poi.hssf.util; 19 20 public class AreaReference { 21 22 23 private CellReference [] cells; 24 private int dim; 25 26 28 public AreaReference(String reference) { 29 String [] refs = seperateAreaRefs(reference); 30 dim = refs.length; 31 cells = new CellReference[dim]; 32 for (int i=0;i<dim;i++) { 33 cells[i]=new CellReference(refs[i]); 34 } 35 } 36 39 public int getDim() { 40 return dim; 41 } 42 43 public CellReference[] getCells() { 44 return cells; 45 } 46 47 public String toString() { 48 StringBuffer retval = new StringBuffer (); 49 for (int i=0;i<dim;i++){ 50 retval.append(':'); 51 retval.append(cells[i].toString()); 52 } 53 retval.deleteCharAt(0); 54 return retval.toString(); 55 } 56 57 61 private String [] seperateAreaRefs(String reference) { 62 String [] retval = null; 63 64 int length = reference.length(); 65 66 int loc = reference.indexOf(':',0); 67 if(loc == -1){ 68 retval = new String [1]; 69 retval[0] = reference; 70 } 71 else{ 72 retval = new String [2]; 73 int sheetStart = reference.indexOf("!"); 74 75 retval[0] = reference.substring(0, sheetStart+1) + reference.substring(sheetStart + 1,loc); 76 retval[1] = reference.substring(0, sheetStart+1) + reference.substring(loc+1); 77 } 78 return retval; 79 } 80 } | Popular Tags |