Home  Products  Purchase  Downloads  Demos  Forums  Blogs  Ticket  Wiki  API  Corporate


com.aspose.cells
Class Cell

java.lang.Object
  extended by com.aspose.cells.Cell

public class Cell
extends java.lang.Object

Encapsulates the object that represents a single Workbook cell.


Method Summary
 void applyStyle(Style style, StyleFlag flag)
          Applies formattings for a cell.
 void clearContent()
          Clear the content of the cell.
 int compareTo(Cell cellTo)
          Compares this Cell with another one for order.
 int compareTo(int columnIndexTo)
          Compares this Cell with another one that has given column index for order.
 NamedRange[] getAssociatedRanges()
          Gets all the named ranges which contain this cell.
 Cells getCells()
          Gets the parent cells of the cell.
 Characters[] getCharacters()
          Gets the rich text settings of a cell.
 short getColumnIndex()
          Gets the column index of the cell.
 java.util.Calendar getDateTimeValue()
          Gets the cell's date time value.
 Cell[] getDependents(boolean isAll)
          Get all cells which formula depends on this cell.
 java.lang.Double getDoubleValue()
          Gets the cell's double value.
 java.lang.String getFormula()
          Gets the formula of the cell.
 CellArea getFormulaRange()
          Gets the range of array formula or shared formula.
 byte getFormulaType()
          Gets the formula's type of this cell.
 java.lang.Integer getIntValue()
          Gets the cell's int value.
 int getKey()
          Gets the comparable key of this Cell.
 CellArea getMergedArea()
          Gets the area that this Cell be merged in.
 java.lang.String getName()
          Gets the name of the cell.
 java.lang.Object[] getPrecedents()
          Gets all cells or ranges which this cell's formula depends on.
 java.lang.String getR1C1Formula()
          Gets a R1C1 formula of the Cell.
 int getRowIndex()
          Gets the row index of the cell.
 java.lang.String getStringValue()
          Gets the string value contained in the cell.
 Style getStyle()
          Gets the style of the cell.
 java.lang.Object getValue()
          Gets the cell's value.
 int getValueType()
          Gets the cell's value type.
 boolean isDateStyle()
          Indicates whether this is a date time style.
 boolean isFormula()
          Gets if the specified cell contains formula.
 boolean isMerged()
          Checks if a cell is part of a merged range or not.
 boolean isPercentStyle()
          Indicates whether the number format is percent format.
 void removeArrayFormula()
          Remove an array formula in a range of cells.
 void setAddInFormula(java.lang.String addInFileName, java.lang.String addInFunction)
           
 void setArrayFormula(java.lang.String arrayFormula, int rowNumber, int columnNumber)
          Sets an array formula to a range of cells.
 void setCharacters(int startIndex, int length, Font font)
          Performs rich text formatting.
 void setFormula(java.lang.String formula)
          Sets the formula of the cell at runtime.
 void setKey(int key)
          Sets the comparable key of this Cell.
 void setR1C1ArrayFormula(java.lang.String arrayFormula, int rowNumber, int columnNumber)
          Sets a R1C1 array formula to a range of cells.
 void setR1C1Formula(java.lang.String r1c1Formula)
          Sets a R1C1 formula of the Cell.
 void setR1C1SharedFormula(java.lang.String sharedFormula, int rowNumber, int columnNumber)
          Sets a R1C1 shared formula to a range of cells.
 void setSharedFormula(java.lang.String sharedFormula, int rowNumber, int columnNumber)
          Sets a shared formula to a range of cells.
 void setStyle(Style style)
          Sets the cell a style.
 void setValue(boolean boolValue)
          Sets the cell a boolean value.
 void setValue(java.util.Calendar dateTimeValue)
          Sets the cell a datetime value.
 void setValue(double doubleValue)
          Sets the cell a double value.
 void setValue(int intValue)
          Sets the cell an int value.
 void setValue(java.lang.Object objectValue)
          Sets the cell an object value.
 void setValue(java.lang.String stringValue)
          Sets the cell a string value.
 void setValue(java.lang.String stringValue, boolean isConverted)
          Sets a string value into the cell and converts the value to other data type if appropriate.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getName

public java.lang.String getName()
Gets the name of the cell.

Returns:
the name of the cell.

getColumnIndex

public short getColumnIndex()
Gets the column index of the cell.

Returns:
column index of the cell.

getRowIndex

public int getRowIndex()
Gets the row index of the cell.

Returns:
row index of the cell.

getCells

public Cells getCells()
Gets the parent cells of the cell.

Returns:
the parent cells of the cell.

clearContent

public void clearContent()
Clear the content of the cell. Style is reserved. To clear the style, pass null to the setStyle() method. To clear both style and content, just remove the cell.

Throws:
CellsException - if the cell has been removed from the worksheet.

setValue

public void setValue(int intValue)
Sets the cell an int value.

Parameters:
intValue - value to set to the cell.
Throws:
CellsException - if the cell has been removed from the worksheet.

setValue

public void setValue(double doubleValue)
Sets the cell a double value.

Parameters:
doubleValue - value to set to the cell.
Throws:
CellsException - if the cell has been removed from the worksheet.

setValue

public void setValue(java.lang.String stringValue)
Sets the cell a string value.

Parameters:
stringValue - value to set to the cell.
Throws:
CellsException - if the cell has been removed from the worksheet, or if the length of string value > 32k.

setValue

public void setValue(java.lang.String stringValue,
                     boolean isConverted)
Sets a string value into the cell and converts the value to other data type if appropriate.

Parameters:
stringValue - value to set to the cell.
isConverted - True: converted to other data type if appropriate.

setValue

public void setValue(boolean boolValue)
Sets the cell a boolean value.

Parameters:
boolValue - value to set to the cell.
Throws:
CellsException - if the cell has been removed from the worksheet.

setValue

public void setValue(java.util.Calendar dateTimeValue)
Sets the cell a datetime value.

Parameters:
dateTimeValue - value to set to the cell.
Throws:
CellsException - if the cell has been removed from the worksheet.

setValue

public void setValue(java.lang.Object objectValue)
Sets the cell an object value. Acceptable Object and corresponding value type:
value object cell value type
null CellValueType.NULL
java.util.Boolean CellValueType.BOOLEAN
java.util.Calendar CellValueType.DATETIME
java.util.Date CellValueType.DATETIME
java.lang.String CellValueType.STRING
java.lang.Integer CellValueType.INT
java.lang.Short CellValueType.INT
java.lang.Long CellValueType.INT or CellValueType.DOUBLE
java.lang.Double CellValueType.DOUBLE
java.math.BigDecimal CellValueType.DOUBLE

Parameters:
objectValue - value to set to the cell.
Throws:
CellsException - if the cell has bean removed from the worksheet.
java.lang.IllegalArgumentException - if the cell value type is unkown.

setCharacters

public void setCharacters(int startIndex,
                          int length,
                          Font font)
Performs rich text formatting.

Parameters:
startIndex - start index.
length - character counts. If length is negative, all characters after the start index are formatted. If length is 0, no characters is formatted.
font - font for the specified range. It can be null which means cell's font is used.
Throws:
CellsException - if the cell has been removed from the worksheet, or the cell does not have a string value.

getCharacters

public Characters[] getCharacters()
Gets the rich text settings of a cell.

Returns:
array of Characters objects. Returns null if there is no rich text settings.

getValue

public java.lang.Object getValue()
Gets the cell's value. The specific type of the returned value depends on the cell's value type.
cell value type returned value type
CellValueType.NULL null
CellValueType.BOOLEAN Boolean
CellValueType.DATETIME Calendar
CellValueType.STRING String
CellValueType.INT Integer
CellValueType.DOUBLE Double
CellValueType.RICH_TEXT_STRING String
CellValueType.ERROR Error String.

Returns:
cell's value.

getDoubleValue

public java.lang.Double getDoubleValue()
Gets the cell's double value. If the value is not numberic, return null;

Returns:
the cell's double value

getIntValue

public java.lang.Integer getIntValue()
Gets the cell's int value. If the value is not numberic, return null;

Returns:
the cell's int value

getDateTimeValue

public java.util.Calendar getDateTimeValue()
Gets the cell's date time value. If the value is not numberic or date time, return null;

Returns:
the cell's date time value

getStringValue

public java.lang.String getStringValue()
Gets the string value contained in the cell.

Returns:
the string value contained in the cell.

getValueType

public int getValueType()
Gets the cell's value type.

Returns:
cell value type.
See Also:
CellValueType

isPercentStyle

public boolean isPercentStyle()
Indicates whether the number format is percent format.

Returns:
whether the number format is percent format.

isDateStyle

public boolean isDateStyle()
Indicates whether this is a date time style.

Returns:
whether this is a date time style.

getStyle

public Style getStyle()
Gets the style of the cell.

Returns:
style of the cell.
Throws:
CellsException - if the cell has been removed from the worksheet.

setStyle

public void setStyle(Style style)
Sets the cell a style.

Parameters:
style - the style. Use null to clear the cell's style setting.

applyStyle

public void applyStyle(Style style,
                       StyleFlag flag)
Applies formattings for a cell. If any other cell's style refers to the same style object of this cell, the other cell's style will be changed too.

Parameters:
style - The style object which will be applied.
flag - Flags which indicates applied formatting properties.

isFormula

public boolean isFormula()
Gets if the specified cell contains formula.

Returns:
if the specified cell contains formula.

getAssociatedRanges

public NamedRange[] getAssociatedRanges()
Gets all the named ranges which contain this cell.

Returns:
all the named ranges.

getPrecedents

public java.lang.Object[] getPrecedents()
Gets all cells or ranges which this cell's formula depends on. The return object must be Cell object or Range object. if the cell is not a formula ,it will return null. if the cell's formula does not depends on any other cell, it will return null.

Returns:
all cells or ranges which this cell's formula depends on.

getDependents

public Cell[] getDependents(boolean isAll)
Get all cells which formula depends on this cell. if no formula depends this cell ,it will return null.

Parameters:
isAll - If False,only finds all cells in this worksheet. If true ,finds all cells in the workbook.
Returns:
all cells which formulas depends on this cell.

isMerged

public boolean isMerged()
Checks if a cell is part of a merged range or not. if getMergedArea() return null, this method return false; else return true.

Returns:
if a cell is part of a merged range or not.
See Also:
getMergedArea()

getMergedArea

public CellArea getMergedArea()
Gets the area that this Cell be merged in.

Returns:
the area that this Cell be merged in. null means this Cell is not merged.

getFormula

public java.lang.String getFormula()
Gets the formula of the cell.

Returns:
formula of the cell. Null is returned if the cell has no formula or the formula is not supported yet.
Throws:
CellsException - if the cell has been removed from the worksheet.

getFormulaType

public byte getFormulaType()
Gets the formula's type of this cell.

Returns:
formula type of this cell.
See Also:
FormulaType

getFormulaRange

public CellArea getFormulaRange()
Gets the range of array formula or shared formula.

Returns:
if this cell's formula is array or shared formula, returns the range. Otherwise returns null. The returned CellArea should be read only, modification on it will effect the array or shared formula.

setFormula

public void setFormula(java.lang.String formula)
Sets the formula of the cell at runtime.

Parameters:
formula - formula of the cell. Currently supported Workbook built-in functions are listed below:
[A]
ABS, ACOS, ACOSH, ADDRESS, AND, AREAS, ASC, ASIN, ASINH
ATAN, ATAN2, ATANH, AVEDEV, AVERAGE, AVERAGEA
[B]
BETADIST, BETAINV, BINOMDIST
[C]
CEILING, CELL, CHAR, CHIDIST, CHITEST, CHOOSE, CLEAN
CODE, COLUMN, COLUMNS, COMBIN, CONCATENATE, CONFIDENCE, CORREL
COS, COSH, COUNT, COUNTA, COUNTBLANK, COUNTIF, COVAR
CRITBINOM, CUMIPMT, CUMPRINC
[D]
DATE, DATEDIF, DATESTRING, DATEVALUE, DAVERAGE, DAY, DAYS360, DB, DCOUNT, DCOUNTA, DDB
DEVSQ, DEGREES, DGET, DMAX, DMIN, DOLLAR, DPRODUCT, DSTDEV, DSTDEVP, DSUM, DVAR, DVARP
[E]
ERROR.TYPE, EVEN, EXACT, EXP, EXPONDIST
[F]
FACT, FALSE, FDIST, FIND, FISHER, FISHERINV, FIXED, FLOOR, FORECAST, FREQUENCY, FTEST, FV
[G]
GAMMADIST, GAMMAINV, GAMMALN, GEOMEAN, GETPIVOTDATA, GROWTH
[H]
HARMEAN, HLOOKUP, HOUR, HYPERLINK, HYPGEOMDIST
[I]
IF,INDIRECT, INFO, INT, INTERCEPT, INDEX, IPMT, IRR
ISBLANK, ISERR, ISERROR, ISEVEN, ISLOGICAL, ISNA, ISNONTEXT, ISNUMBER, ISODD, ISPMT, ISREF, ISTEXT
[K]
KURT
[L]
LARGE, LEFT, LEN, LINEST, LN, LOOKUP, LOG, LOG10, LOGEST, LOWER
[M]
MATCH, MAX, MAXA, MDETERM, MEDIAN, MID, MIN, MINA, MINUTE, MINVERSE, MIRR, MMULT, MOD, MONTH, MROUND
[N]
N, NA, NEGBINOMDIST, NORMDIST, NORMINV, NORMSDIST, NORMSINV, NOT, NOW, NPER, NPV, NUMBERSTRING
[O]
ODD, OFFSET, OR
[P]
PEARSON, PERCENTILE, PERCENTRANK, PERMUT, PHONETIC, PI, PMT, POISSON, POWER, PPMT, PROB, PRODUCT, PROPER, PV
[Q]
QUARTILE
[R]
RADIANS, RAND, RANK, RATE, REPLACE, REPT, RIGHT, ROMAN, ROUND, ROUNDDOWN, ROUNDUP, ROW, ROWS, RSQ
[S]
SEARCH, SECOND, SIGN, SIN, SINH, SKEW, SLN, SLOPE, SMALL, SQRT
STANDARDIZE, STDEV, STDEVA, STDEVP, STDEVPA, STEYX
SUBSTITUTE, SUBTOTAL, SUM, SUMIF, SUMPRODUCT, SUMSQ, SUMX2MY2, SUMX2PY2, SUMXMY2, SYD
[T]
T, TAN, TANH, TDIST, TEXT, TIME, TIMEVALUE, TINV, TODAY
TRANSPOSE, TREND, TRIM, TRIMMEAN, TRUE, TRUNC, TTEST, TYPE
[U]
UPPER, USDOLLAR
[V]
VALUE, VAR, VARA, VARP, VARPA, VDB, VLOOKUP
[W]
WEEKDAY, WEEKNUM, WEIBULL, WIDECHAR
[Y]
YEAR
[Z]
ZTEST
Throws:
CellsException - if the cell has been removed from the worksheet.
java.lang.IllegalArgumentException - if the formula is not supported or invalid.

getR1C1Formula

public java.lang.String getR1C1Formula()
Gets a R1C1 formula of the Cell.

Returns:
a R1C1 formula.

setR1C1Formula

public void setR1C1Formula(java.lang.String r1c1Formula)
Sets a R1C1 formula of the Cell.

Parameters:
r1c1Formula - a R1C1 formula.
See Also:
setFormula(String)

setAddInFormula

public void setAddInFormula(java.lang.String addInFileName,
                            java.lang.String addInFunction)

setArrayFormula

public void setArrayFormula(java.lang.String arrayFormula,
                            int rowNumber,
                            int columnNumber)
Sets an array formula to a range of cells.

Parameters:
arrayFormula - Array formula.
rowNumber - Number of rows to populate result of the array formula.
columnNumber - Number of columns to populate result of the array formula.

setR1C1ArrayFormula

public void setR1C1ArrayFormula(java.lang.String arrayFormula,
                                int rowNumber,
                                int columnNumber)
Sets a R1C1 array formula to a range of cells.

Parameters:
arrayFormula - Array formula.
rowNumber - Number of rows to populate result of the array formula.
columnNumber - Number of columns to populate result of the array formula.

setSharedFormula

public void setSharedFormula(java.lang.String sharedFormula,
                             int rowNumber,
                             int columnNumber)
Sets a shared formula to a range of cells.

Parameters:
sharedFormula - shared formula.
rowNumber - Number of rows to populate result of the array formula.
columnNumber - Number of columns to populate result of the array formula.

setR1C1SharedFormula

public void setR1C1SharedFormula(java.lang.String sharedFormula,
                                 int rowNumber,
                                 int columnNumber)
Sets a R1C1 shared formula to a range of cells.

Parameters:
sharedFormula - shared formula.
rowNumber - Number of rows to populate result of the array formula.
columnNumber - Number of columns to populate result of the array formula.

removeArrayFormula

public void removeArrayFormula()
Remove an array formula in a range of cells.


compareTo

public int compareTo(int columnIndexTo)
Compares this Cell with another one that has given column index for order.

Parameters:
columnIndexTo - the column index to be compared with the column index of this Cell.
Returns:
a negative integer, zero, or a positive integer as the column index of this Cell is less than, equal to, or greater than the specified column index.

compareTo

public int compareTo(Cell cellTo)
Compares this Cell with another one for order. Only compares the column index, row index of the cell will be ignored.

Parameters:
cellTo - the Cell to be compared with this one.
Returns:
a negative integer, zero, or a positive integer as the column index of this Cell is less than, equal to, or greater than the column index of the specified Cell object.

getKey

public int getKey()
Gets the comparable key of this Cell. Same with getColumnIndex().

Returns:
the comparable key of this Cell, that is the column index of this cell.

setKey

public void setKey(int key)
Sets the comparable key of this Cell. Only for inner usage. Does not make any change for this Cell object.

Parameters:
key - key value.