com.ihr.xbrl.tools.excel
Class SheetPoint

java.lang.Object
  extended by com.ihr.xbrl.tools.excel.SheetPoint

public class SheetPoint
extends java.lang.Object

This class represents a cell in an HSSFSheet. It is easier operating with SheetPoints than operating with cells using the raw POI api.

Author:
Ignacio

Constructor Summary
SheetPoint(java.lang.String sheetPointer)
          Creates a sheetPoint object from the format sheetName!
SheetPoint(java.lang.String name, org.apache.poi.ss.usermodel.Sheet sh, int row, short col)
          Creates a sheetPoint object providing all parameters
SheetPoint(java.lang.String name, org.apache.poi.ss.usermodel.Sheet sh, java.lang.String rowCol)
          Creates a sheetPoint object providing all parameters
SheetPoint(java.lang.String sheetPointer, org.apache.poi.ss.usermodel.Workbook wb)
           Creates a sheetPoint object from a sheetPointer string of the following form: sheetName!
 
Method Summary
 SheetPoint clone()
           
 SheetPoint down()
          Moves this SheetPoint to point to the cell that is below this cell
 SheetPoint down(int n)
          Moves this SheetPoint down n cells
 boolean equals(java.lang.Object obj)
           
 org.apache.poi.ss.usermodel.Cell getCell()
          Obtains the HSSFCell object corresponding to the cell name
 java.lang.String getCellName()
           
 short getCol()
          Access to the column
 org.apache.poi.ss.usermodel.RichTextString getContent()
          Access to the value of the cell and returns an HSSFRichTextString
 boolean getContentAsBoolean()
          Access to the value in the cell pointed to by this object the value is converted to a boolean depending on the content type of the cell.
 boolean getContentAsBoolean(boolean exceptionsIfBlank, boolean exceptionsIfError)
          Access to the value in the cell pointed to by this object the value is converted to a boolean depending on the content type of the cell.
 boolean getContentAsBoolean(boolean exceptionsIfBlank, boolean valueIfBlankAndException, boolean exceptionsIfError, boolean valueIfErrorAndException)
          Access to the value in the cell pointed to by this object the value is converted to a boolean depending on the content type of the cell.
 java.util.Date getContentAsDate()
          Access to the value in the cell pointed to by this object the value is converted to a Date depending on the content type of the cell.
 java.lang.Double getContentAsDouble()
          Access to the value in the cell as a Double
 java.lang.String getContentAsString()
          Access to the value in the cell pointed to by this object the value is converted to a string depending on the content type of the cell.
 java.lang.String getName()
          Access to the sheet name
 org.apache.poi.ss.usermodel.Cell getOrCreateCell()
          Obtains the HSSFCell object or creates a new cell if it is not found in the HSSFSheet
 int getRow()
          Access to the row
 org.apache.poi.ss.usermodel.Sheet getSheet()
          Access to the sheet for this SheetPoint
 org.apache.poi.ss.usermodel.CellStyle getStyle()
          Access to the style defined in the cell
 int hashCode()
           
 SheetPoint left()
          Moves this SheetPoint to point to the cell that is on the left of this cell
 SheetPoint left(int n)
          Moves this SheetPoint to the left n cells
 SheetPoint right()
          Moves this SheetPoint to point to the cell that is on the right of this cell
 SheetPoint right(int n)
          Moves this SheetPoint to the right n cells
 void setCol(short col)
          Sets the column
 void setRow(int row)
          Sets the row
 java.lang.String toString()
           
 SheetPoint up()
          Moves this SheetPoint to point to the cell that is above this cell
 SheetPoint up(int n)
          Moves this SheetPoint up n cells
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SheetPoint

public SheetPoint(java.lang.String sheetPointer,
                  org.apache.poi.ss.usermodel.Workbook wb)
           throws InvalidSheetPointException

Creates a sheetPoint object from a sheetPointer string of the following form: sheetName!Xn or sheetName!name

sheetName is the name of the sheet. It MUST exist
X is the row name in letters. First row is A...
n is the column number. First column is 1

$ characters are ignored. Sheet1!$A$3 will be considered equivalent to Sheet1!A3

The alternative format is based on a cell name (Range name). Cell names must exist at the time this object is created.

wb is the HSSFWorkBook. if not indicated then the HSSFSheet of this object will be null and sheet name will be the empty string

Parameters:
sheetPointer - String
wb - HSSFWorkbook where the sheetName exists.
Throws:
InvalidSheetPointException - if the sheetPointer string is not properly written

SheetPoint

public SheetPoint(java.lang.String name,
                  org.apache.poi.ss.usermodel.Sheet sh,
                  int row,
                  short col)
Creates a sheetPoint object providing all parameters

Parameters:
name - String Sheet name
sh - HSSFSheet object
row - row number, first row is 0
col - col number, first col is 0

SheetPoint

public SheetPoint(java.lang.String sheetPointer)
           throws InvalidSheetPointException
Creates a sheetPoint object from the format sheetName!A1 where A is the column letter(s) and 1 is the row number

This constructor does not resolve cell names and only works when the workbook or Sheet object is not required by the application.

Use with care

Parameters:
sheetPointer - the sheet point
Throws:
InvalidSheetPointException

SheetPoint

public SheetPoint(java.lang.String name,
                  org.apache.poi.ss.usermodel.Sheet sh,
                  java.lang.String rowCol)
           throws InvalidSheetPointException
Creates a sheetPoint object providing all parameters

Parameters:
name - String Sheet name
sh - HSSFSheet object
rowCol - row name and column name in A1 format
Throws:
InvalidSheetPointException
Method Detail

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

clone

public SheetPoint clone()
Overrides:
clone in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getName

public java.lang.String getName()
Access to the sheet name

Returns:
String sheet name

getContentAsString

public java.lang.String getContentAsString()
                                    throws SheetPointAccessException
Access to the value in the cell pointed to by this object the value is converted to a string depending on the content type of the cell. If the cell content is not known then null is returned HSSFCell.BLANK cells returns the empty string HSSFCell.ERROR cells returns "Error" as a string

Returns:
String
Throws:
SheetPointAccessException - if there is no cell in the sheet

getContentAsBoolean

public boolean getContentAsBoolean()
                            throws SheetPointAccessException
Access to the value in the cell pointed to by this object the value is converted to a boolean depending on the content type of the cell. If the cell type is unknown then an exception is raised HSSFCell.BLANK cells returns false HSSFCell.ERROR cells returns false HSSFCell.BOOLEAN cells returns the boolean value HSSFCell.NUMERIC cells returns true if the value is non zero HSSFCell.STRING cells returns the parsed string converted into a boolean value HSSFCell.FORMULA cells returns a value depending on the formula result type, in turn NUMERIC, STRING or BOOLEAN are equally handled

Returns:
boolean
Throws:
SheetPointAccessException - if there is no cell in the sheet

getContentAsDate

public java.util.Date getContentAsDate()
                                throws SheetPointAccessException
Access to the value in the cell pointed to by this object the value is converted to a Date depending on the content type of the cell. If the cell type is unknown then an exception is raised HSSFCell.BLANK cells returns new java.util.Date(0) HSSFCell.ERROR cells returns new java.util.Date(0) HSSFCell.BOOLEAN cells returns new java.util.Date(0) HSSFCell.NUMERIC cells returns a date from the Excel cell HSSFCell.STRING cells returns the parsed date of the Excel cell HSSFCell.FORMULA cells returns a value depending on the formula result type, only NUMERIC or STRING are handled

Returns:
java.util.Date
Throws:
SheetPointAccessException - if there is no cell in the sheet

getContentAsBoolean

public boolean getContentAsBoolean(boolean exceptionsIfBlank,
                                   boolean exceptionsIfError)
                            throws SheetPointAccessException
Access to the value in the cell pointed to by this object the value is converted to a boolean depending on the content type of the cell. If the cell type is unknown then an exception is raised HSSFCell.BLANK cells returns false HSSFCell.ERROR cells returns false HSSFCell.BOOLEAN cells returns the boolean value HSSFCell.NUMERIC cells returns true if the value is non zero HSSFCell.STRING cells returns the parsed string converted into a boolean value HSSFCell.FORMULA cells returns a value depending on the formula result type, in turn NUMERIC, STRING or BOOLEAN are equally handled

Parameters:
exceptionsIfBlank - if this parameter is true, the function will raise an exception if the cell is blank rather than return false which is the default
exceptionsIfError - if this parameter is true, the function will raise an exception if the cell is an error rather than return false which is the default
Returns:
boolean
Throws:
SheetPointAccessException - if there is no cell in the sheet

getContentAsBoolean

public boolean getContentAsBoolean(boolean exceptionsIfBlank,
                                   boolean valueIfBlankAndException,
                                   boolean exceptionsIfError,
                                   boolean valueIfErrorAndException)
                            throws SheetPointAccessException
Access to the value in the cell pointed to by this object the value is converted to a boolean depending on the content type of the cell. If the cell type is unknown then an exception is raised HSSFCell.BLANK cells returns false HSSFCell.ERROR cells returns false HSSFCell.BOOLEAN cells returns the boolean value HSSFCell.NUMERIC cells returns true if the value is non zero HSSFCell.STRING cells returns the parsed string converted into a boolean value HSSFCell.FORMULA cells returns a value depending on the formula result type, in turn NUMERIC, STRING or BOOLEAN are equally handled

Parameters:
exceptionsIfBlank - if this parameter is true, the function will raise an exception if the cell is blank rather than return the value of the valueIfBlankAndException parameter
valueIfBlankAndException - this is the value returned in case the cell is blank and exceptions are not reported
exceptionsIfError - if this parameter is true, the function will raise an exception if the cell is an error rather than return the value of the valueIfErrorAndException parameter
valueIfErrorAndException - this is the value returned in case the cell contains an error and exceptions are not reported
Returns:
boolean
Throws:
SheetPointAccessException - there is a IllegalStateException or NumberFormatException

getContentAsDouble

public java.lang.Double getContentAsDouble()
                                    throws SheetPointAccessException
Access to the value in the cell as a Double

Returns:
Double
Throws:
SheetPointAccessException - if there is no cell in the sheet

getContent

public org.apache.poi.ss.usermodel.RichTextString getContent()
                                                      throws SheetPointAccessException
Access to the value of the cell and returns an HSSFRichTextString

Returns:
HSSFRichTextString
Throws:
SheetPointAccessException - if there is no cell in the sheet

getStyle

public org.apache.poi.ss.usermodel.CellStyle getStyle()
                                               throws SheetPointAccessException
Access to the style defined in the cell

Returns:
HSSFCellStyle
Throws:
SheetPointAccessException

getCell

public org.apache.poi.ss.usermodel.Cell getCell()
                                         throws SheetPointAccessException
Obtains the HSSFCell object corresponding to the cell name

Returns:
HSSFCell
Throws:
SheetPointAccessException - if the row or the column does not exists

getOrCreateCell

public org.apache.poi.ss.usermodel.Cell getOrCreateCell()
Obtains the HSSFCell object or creates a new cell if it is not found in the HSSFSheet

Returns:
HSSFCell

getSheet

public org.apache.poi.ss.usermodel.Sheet getSheet()
Access to the sheet for this SheetPoint

Returns:
HSSFSheet

getRow

public int getRow()
Access to the row

Returns:
int

getCol

public short getCol()
Access to the column

Returns:
short

getCellName

public java.lang.String getCellName()
Returns:
the cellName

setRow

public void setRow(int row)
Sets the row

Parameters:
row - int new value

setCol

public void setCol(short col)
Sets the column

Parameters:
col - short new value

up

public SheetPoint up()
Moves this SheetPoint to point to the cell that is above this cell


up

public SheetPoint up(int n)
Moves this SheetPoint up n cells

Parameters:
n -
Returns:
SheetPoint

down

public SheetPoint down()
Moves this SheetPoint to point to the cell that is below this cell


down

public SheetPoint down(int n)
Moves this SheetPoint down n cells

Parameters:
n -
Returns:
SheetPoint

left

public SheetPoint left()
Moves this SheetPoint to point to the cell that is on the left of this cell


left

public SheetPoint left(int n)
Moves this SheetPoint to the left n cells

Parameters:
n -
Returns:
SheetPoint

right

public SheetPoint right()
Moves this SheetPoint to point to the cell that is on the right of this cell


right

public SheetPoint right(int n)
Moves this SheetPoint to the right n cells

Parameters:
n -
Returns:
SheetPoint