Spreadsheet Toolkit

corpus.excel
Class CellReference

java.lang.Object
  |
  +--corpus.excel.Component
        |
        +--corpus.excel.FormulaComponent
              |
              +--corpus.excel.CellReference
All Implemented Interfaces:
java.io.Serializable

public class CellReference
extends FormulaComponent

Used to store the internal representation of a referecnce to a single Cell in a Formula. Read up on R1C1-style range references. =A1+A2 if entered in B1 becomes =RC[-1]+R[1]C[-1] and =A3+A4 if entered in B3 becomes the same R1C1-style formula. =$A$1+A2 in B1 becomes =R1C1+R[1]C[-1]. R1C1-style addressing is ideal for spotting differences between formulas in different cells.

See Also:
Cell Grammer, Serialized Form

Field Summary
protected  int[] coords
          The coordinates of this cell 0: Column 1: Row 2: Depth of the worksheet that the cell being referred to is in.
protected  boolean[] dollars
          Where the references of this cell absolute?
protected  java.lang.String excelref
          The exact reference Excel gave this Cell.
 
Fields inherited from class corpus.excel.FormulaComponent
formula
 
Fields inherited from class corpus.excel.Component
haltOnErrors
 
Constructor Summary
CellReference(int col, int row, boolean abs_col, boolean abs_row, java.lang.String excelref)
           
CellReference(int col, int row, int depth)
          Creates a new CellReference for the Cell at Col x and Row y and Sheetdepth z.
 
Method Summary
 boolean absCol()
           
 boolean absRow()
           
 int getCol()
           
 int getDepth()
           
 Formula getFormula()
           
 Cell getReferencedCell()
           
 int getRow()
           
 int length()
          The length of the excel style reference as a string.
static void main(java.lang.String[] args)
          You should know what this does.
 void setAbsRel(boolean col, boolean row)
           
 void setDepth(int depth)
           
 void setFormula(Formula newFormula)
          Sets cells formula and creates Formula object.
 void setReferencedCell(Cell c)
           
 void setSheetNames(java.lang.String[] sheetnames)
          Sheetnames are used to determine cell depth during parsing.
 java.lang.String toHTMLString()
          Converts information about this component into an HTML formatted String.
 java.lang.String toString()
          Converts information about this cell into a String.
 
Methods inherited from class corpus.excel.FormulaComponent
getReferingFormula, parseTree
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

excelref

protected java.lang.String excelref
The exact reference Excel gave this Cell.


coords

protected int[] coords
The coordinates of this cell 0: Column 1: Row 2: Depth of the worksheet that the cell being referred to is in.


dollars

protected boolean[] dollars
Where the references of this cell absolute? 0: Column 1: Row 2: Depth There is some confussion here as to an actual cell and a cell reference found in a formula.

Constructor Detail

CellReference

public CellReference(int col,
                     int row,
                     int depth)
Creates a new CellReference for the Cell at Col x and Row y and Sheetdepth z.


CellReference

public CellReference(int col,
                     int row,
                     boolean abs_col,
                     boolean abs_row,
                     java.lang.String excelref)
Method Detail

getReferencedCell

public Cell getReferencedCell()
Returns:
the cell that is referenced.

setReferencedCell

public void setReferencedCell(Cell c)

getCol

public int getCol()
Returns:
the x position of the cell as an int.

getRow

public int getRow()
Returns:
the y position of the cell as an int.

getDepth

public int getDepth()
Returns:
the z position of the cell as an int.

setDepth

public void setDepth(int depth)
Parameters:
depth - the new z position of the cell as an int.

absCol

public boolean absCol()
Returns:
if the column reference is absolute.

absRow

public boolean absRow()
Returns:
if the row reference is absolute.

setAbsRel

public void setAbsRel(boolean col,
                      boolean row)

setFormula

public void setFormula(Formula newFormula)
Sets cells formula and creates Formula object.

Parameters:
newFormula - the new formula for the cell.

getFormula

public Formula getFormula()
Returns:
the formula for the cell as parsed from the String formula.

setSheetNames

public void setSheetNames(java.lang.String[] sheetnames)
Sheetnames are used to determine cell depth during parsing.


toString

public java.lang.String toString()
Converts information about this cell into a String. A1 style

Specified by:
toString in class Component

toHTMLString

public java.lang.String toHTMLString()
Converts information about this component into an HTML formatted String.

Specified by:
toHTMLString in class Component

length

public int length()
The length of the excel style reference as a string.


main

public static void main(java.lang.String[] args)
You should know what this does. Various tests to Cell class functionallity.


Spreadsheet Toolkit

Project Home Page