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 Excel cell.


Method Summary
 void clearContent()
          Clear the content of the cell.
 Characters[] getCharacters()
          Gets the rich text settings of a cell.
 short getColumnIndex()
          Gets the column index of the cell.
 java.lang.String getFormula()
          Gets the 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.
 void removeArrayFormula()
          Remove an array formula in a range of cells.
 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 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

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.

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:
ExcelException - 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:
ExcelException - 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:
ExcelException - 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:
ExcelException - if the cell has been removed from the worksheet.

setValue

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

Parameters:
boolValue - value to set to the cell.
Throws:
ExcelException - 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:
ExcelException - if the cell has been removed from the worksheet.

setValue

public void setValue(java.lang.Object objectValue)
Sets the cell an object value.

Parameters:
objectValue - value to set to the cell.
Throws:
ExcelException - 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:
ExcelException - 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.FORMULA undefined. currently returns null.

Returns:
cell's 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

getStyle

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

Returns:
style of the cell.
Throws:
ExcelException - 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.

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:
ExcelException - if the cell has been removed from the worksheet.

setFormula

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

Parameters:
formula - formula of the cell. Currently supported Excel built-in functions are listed below:
[A]
ABS, AND,AVERAGE
[C]
CHAR, COLUMN, CONCATENATE, COUNT, COUNTA, COUNTBLANK, COUNTIF
[D]
DATE, DAVERAGE, DAY, DCOUNT, DCOUNTA, DGET, DMAX, DMIN, DSTDEV, DSTDEVP, DSUM, DVAR, DVARP
[F]
FALSE, FIND, FLOOR
[H]
HLOOKUP, HOUR
[I]
IF, INT, ISBLANK, ISNA, ISERROR, ISNUMBER, ISTEXT
[L]
LEFT, LEN, LOOKUP, LOWER
[M]
MAX, MEDIAN, MID, MIN, MINUTE, MOD, MONTH
[N]
NOT, NOW
[O]
OFFSET,OR
[P]
POWER, PRODUCT
[R]
RAND, RANK, REPLACE, RIGHT, ROUND, ROUNDDOWN, ROUNDUP, ROW, ROWS
[S]
SEARCH, SECOND, STDEV, STDEVP, SUBTOTAL, SUM, SUMIF, SUMPRODUCT
[T]
TIME, TODAY, TRIM, TRUE, TRUNC
[U]
UPPER
[W]
WEEKDAY
[Y]
YEAR
Throws:
ExcelException - if the cell has been removed from the worksheet.

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.

removeArrayFormula

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