Spreadsheet Toolkit

corpus.excel
Class WorkSheet

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

public class WorkSheet
extends Component

Used to store the internal representation of an excel file. This will be the data that is used to display the worksheet.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class corpus.excel.Component
haltOnErrors
 
Constructor Summary
WorkSheet(java.lang.String name, int depth, java.util.Vector values, java.util.Vector formulas, int startCol, int startRow, WorkBook parent)
          This constructor is mainly for IBM Excelaccessor.
WorkSheet(java.lang.String name, int depth, WorkBook parent)
          Constructor used by JExcelRead
 
Method Summary
 java.util.Vector averageFormaula()
          Returns a Vector with the average formula (represented by a MathVector) for each cell.
 Grid cellGrid()
          A grid version of the cells in this worksheet.
 void createCellGrid()
          Create Cell Grid, turns the values and formula grids into a cell grid.
 int emptyCells()
          Finds the number of empty cells
 double[] findCenter()
          Finds the numerical center for this WorkSheet based on the Row and Column positions for all occupied cells.
 int formulaCells()
          Finds the number of cells that contain a formula.
 Grid formulaGrid()
          A Grid of Strings for the formula in each cell.
 java.lang.String functionCatagory(boolean header)
          Breaks down the functions used into catagories.
 int[] getAngles(int size)
          Counts outgoing vector angles for all the cells in this WorkSheet into buckets.
 Cell getCell(int col, int row)
          Returns the cell from this WorkSheet at position col, row.
 Cell[] getCycleCells()
          Searches the worksheet for circular references.
 int getDepth()
          Returns the Depth in the WorkBook that this WorkSheet is at.
 Function[] getFunctions()
          Find all the Functions used in the WorkSheet.
 Cell[] getLeafCells()
          Looks for cells that reference other cells but are not referenced by any cells themselves.
 int getMaxHeight()
          Returns the max column that contains a cell.
 int getMaxWidth()
          Returns the max column that contains a cell.
 java.lang.String getName()
          Returns the sheetname for this WorkBook.
 WorkBook getParent()
          Returns the WorkBook that contains this WorkSheet.
 Cell[] getRootCells()
          Looks for cells that are referenced by other cells but do not reference any cells.
 java.util.HashMap inDegree()
          Referencing in degree for each cell.
 int[][] inOutDegree()
          Degree of in and out bound refereces for each cell.
 java.util.HashMap inOutDegreeHashMap()
          Referencing in and out degree for each cell.
 boolean isEmpty()
          Is this WorkSheet Empty?
 Cell[] localFormulas()
          Finds cells that contain formulas but do not reference other cells.
 int maxTreeBreadth()
          Find the maximum breadth of dependency tree from the root cells.
 int maxTreeBreadth(Cell[] cells)
          Find the maximum breadth of dependency tree from the given cells.
 int maxTreeDepth()
          Find the maximum depth of dependency tree from all root cells.
 int maxTreeDepth(Cell[] cells)
          Find the maximum depth of dependency tree from the given cells.
 java.lang.String metricsAngles(boolean header)
          Breaks down the outgoing angles for all the cells in the worksheet.
 java.lang.String metricsFunctionCatagory(boolean header)
          Breaks down the functions used into catagories at a sheet level.
 java.util.Map metricsFunctionCatagory(java.util.Map map, boolean header)
          Returns a Map with a count to the number of times each Function occurs.
 int occupiedCells()
          Finds the number of occupied cells.
 int orphanCells()
          Returns the number of cells in the worksheet with no incoming or outgoing references
 java.util.HashMap outDegree()
          Referencing out degree for each cell.
 void print()
          Like toString except dumps to console.
 void process()
          Process the worksheet This method is called after reading has been completed.
 void setCell(Cell c)
          Adds/changes a cell in the worksheet.
 void setDetails(int depth, java.lang.String name)
          Assign the depth and name of the worksheet in the workbook.
 void setFormula(int col, int row, java.lang.String formula)
          Adds/changes a Formula in the worksheet.
 void setParent(WorkBook parent)
          Sets the WorkBook that contains this WorkSheet.
 void setSheetNames(java.lang.String[] sheetnames)
          Set sheetnames
 void setValue(int col, int row, java.lang.String value)
          Adds/changes a value in the worksheet.
 Grid toFormulaGrid()
          A grid containing all the formula.
 java.lang.String toHTMLString()
          Converts information about this component into an HTML formatted String.
 java.lang.String toString()
          Print String version.
 int[] totalInOutDegree()
          Find a count for all in[0] and out[1] bound references in this WorkSheet.
 int[] totalInOutDegree(int[][] inOut)
          Sums up all in and out bound references for inOut.
 java.lang.String treeToString()
          Convert the dependency tree into a file, used for fisheye views.
 Grid valueGrid()
          A grid of Strings for the value in each cell.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WorkSheet

public WorkSheet(java.lang.String name,
                 int depth,
                 WorkBook parent)
Constructor used by JExcelRead


WorkSheet

public WorkSheet(java.lang.String name,
                 int depth,
                 java.util.Vector values,
                 java.util.Vector formulas,
                 int startCol,
                 int startRow,
                 WorkBook parent)
This constructor is mainly for IBM Excelaccessor.

Method Detail

setValue

public void setValue(int col,
                     int row,
                     java.lang.String value)
Adds/changes a value in the worksheet. The change in made to both the value and cell grids


setFormula

public void setFormula(int col,
                       int row,
                       java.lang.String formula)
Adds/changes a Formula in the worksheet.


setCell

public void setCell(Cell c)
Adds/changes a cell in the worksheet. Called during extraction using JExcelRead


getName

public java.lang.String getName()
Returns the sheetname for this WorkBook.

Returns:
The name of the worksheet

getDepth

public int getDepth()
Returns the Depth in the WorkBook that this WorkSheet is at.

Returns:
The depth of the worksheet

setParent

public void setParent(WorkBook parent)
Sets the WorkBook that contains this WorkSheet.

Parameters:
parent - The workbook that contains this worksheet.

getParent

public WorkBook getParent()
Returns the WorkBook that contains this WorkSheet.

Returns:
The workbook that contains this worksheet.

getMaxWidth

public int getMaxWidth()
Returns the max column that contains a cell.


getMaxHeight

public int getMaxHeight()
Returns the max column that contains a cell.


getCell

public Cell getCell(int col,
                    int row)
Returns the cell from this WorkSheet at position col, row.

Returns:
the cell in a specific (col,row) pair.

valueGrid

public Grid valueGrid()
A grid of Strings for the value in each cell.

Returns:
a Grid where each entry is the String value of a Cell.

formulaGrid

public Grid formulaGrid()
A Grid of Strings for the formula in each cell.

Returns:
a Grid where each entry is the String formula of a Cell.

cellGrid

public Grid cellGrid()
A grid version of the cells in this worksheet.

Returns:
a Grid where each entry is a Cell.

toFormulaGrid

public Grid toFormulaGrid()
A grid containing all the formula.

Returns:
a Grid where each entry is a Formula of a Cell

setDetails

public void setDetails(int depth,
                       java.lang.String name)
Assign the depth and name of the worksheet in the workbook.

Parameters:
depth - The depth
name - The name

setSheetNames

public void setSheetNames(java.lang.String[] sheetnames)
Set sheetnames

Parameters:
sheetnames - The names of the worksheets.

createCellGrid

public void createCellGrid()
Create Cell Grid, turns the values and formula grids into a cell grid. Called by Workbook process before the worksheets are processed.


process

public void process()
Process the worksheet This method is called after reading has been completed. It causes the cells to parse the formula they contain, after which the intercell references are used to to the referral links.


getRootCells

public Cell[] getRootCells()
Looks for cells that are referenced by other cells but do not reference any cells. These cells will often contain constants.

Returns:
An array of root cells.

maxTreeDepth

public int maxTreeDepth()
Find the maximum depth of dependency tree from all root cells.


maxTreeDepth

public int maxTreeDepth(Cell[] cells)
Find the maximum depth of dependency tree from the given cells.


maxTreeBreadth

public int maxTreeBreadth()
Find the maximum breadth of dependency tree from the root cells.


maxTreeBreadth

public int maxTreeBreadth(Cell[] cells)
Find the maximum breadth of dependency tree from the given cells.


getLeafCells

public Cell[] getLeafCells()
Looks for cells that reference other cells but are not referenced by any cells themselves. These cells will often contain calculated values.


getCycleCells

public Cell[] getCycleCells()
Searches the worksheet for circular references.

Returns:
An array of cells that are members of a cycle.

orphanCells

public int orphanCells()
Returns the number of cells in the worksheet with no incoming or outgoing references

Returns:
number of orphans

emptyCells

public int emptyCells()
Finds the number of empty cells

Returns:
the number of cells in the worksheet with no value

occupiedCells

public int occupiedCells()
Finds the number of occupied cells.

Returns:
the number of cells in the worksheet with a value

formulaCells

public int formulaCells()
Finds the number of cells that contain a formula.

Returns:
the number of cells in the worksheet with a formula

getFunctions

public Function[] getFunctions()
Find all the Functions used in the WorkSheet.

Returns:
an array containing all the functions used in the worksheet (with duplicates)
See Also:
Function

isEmpty

public boolean isEmpty()
Is this WorkSheet Empty?

Returns:
True if no cells in this worksheet contain any values of formulas.

localFormulas

public Cell[] localFormulas()
Finds cells that contain formulas but do not reference other cells.


totalInOutDegree

public int[] totalInOutDegree()
Find a count for all in[0] and out[1] bound references in this WorkSheet.

Returns:
an int[2] where the first int is the total in degree and the second the total out degree.
See Also:
totalInOutDegree(int[][]), inOutDegree()

totalInOutDegree

public int[] totalInOutDegree(int[][] inOut)
Sums up all in and out bound references for inOut.

Parameters:
inOut - An int[][] where the first index is a count and the second is either an in[0] or out[1] bound reference count.
Returns:
An int[] where [0] is the total in-degree count and [1] is the total outbound count.
See Also:
totalInOutDegree(), inOutDegree()

inOutDegree

public int[][] inOutDegree()
Degree of in and out bound refereces for each cell.

Returns:
an int[][] containing one entry for each cell in the worksheet. The first index is the cell number, say i. So for cell i, [i][0] is the count for the number of inbound references and [i][1] is the count for the number of outbound cell references.

inOutDegreeHashMap

public java.util.HashMap inOutDegreeHashMap()
Referencing in and out degree for each cell.

Returns:
a HashMap containing one entry for each cell in the worksheet. Each key cell will reference an Integer Array containing the count the number of inbound references[0] and the count for the number of outbound references[1].

inDegree

public java.util.HashMap inDegree()
Referencing in degree for each cell.

Returns:
a HashMap containing one entry for each cell in the worksheet. Each key cell will reference an Integer containing the count the number of inbound references.

outDegree

public java.util.HashMap outDegree()
Referencing out degree for each cell.

Returns:
an HashMap containing one entry for each cell in the worksheet. Each key cell will reference an Integer containing the count the number of inbound references.

findCenter

public double[] findCenter()
Finds the numerical center for this WorkSheet based on the Row and Column positions for all occupied cells.

Returns:
a double[2] with the first coord being the x center of all the occupiced cells and the second being the y.

getAngles

public int[] getAngles(int size)
Counts outgoing vector angles for all the cells in this WorkSheet into buckets.

Parameters:
size - The number of buckets to divide 360 Degrees into.
Returns:
An int[] containing a series of buckets with counts for how many outgoing vectors occur in the bucket angle.\
See Also:
Cell.anglesOutgoing(int)

averageFormaula

public java.util.Vector averageFormaula()
Returns a Vector with the average formula (represented by a MathVector) for each cell.


metricsFunctionCatagory

public java.util.Map metricsFunctionCatagory(java.util.Map map,
                                             boolean header)
Returns a Map with a count to the number of times each Function occurs.


metricsFunctionCatagory

public java.lang.String metricsFunctionCatagory(boolean header)
Breaks down the functions used into catagories at a sheet level.


functionCatagory

public java.lang.String functionCatagory(boolean header)
Breaks down the functions used into catagories.


metricsAngles

public java.lang.String metricsAngles(boolean header)
Breaks down the outgoing angles for all the cells in the worksheet.


treeToString

public java.lang.String treeToString()
Convert the dependency tree into a file, used for fisheye views.


toString

public java.lang.String toString()
Print String version.

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

print

public void print()
Like toString except dumps to console.


Spreadsheet Toolkit

Project Home Page