Cell

Inheritance: java.lang.Object

public class Cell

Encapsulates the object that represents a single Workbook cell.

Example

         Workbook excel = new Workbook();
         Cells cells = excel.getWorksheets().get(0).getCells();
 
         //Put a string into a cell
         Cell cell = cells.get(0, 0);
         cell.putValue("Hello");
 
         String first = cell.getStringValue();
 
         //Put an integer into a cell
         cell = cells.get("B1");
         cell.putValue(12);
 
         int second = cell.getIntValue();
 
         //Put a double into a cell
         cell = cells.get(0, 2);
         cell.putValue(-1.234);
 
         double third = cell.getDoubleValue();
 
         //Put a formula into a cell
         cell = cells.get("D1");
         cell.setFormula("=B1 + C1");
 
         //Put a combined formula: "sum(average(b1,c1), b1)" to cell at b2
         cell = cells.get("b2");
         cell.setFormula("=sum(average(b1,c1), b1)");
 
         //Set style of a cell
         Style style = cell.getStyle();
         //Set background color
         style.setBackgroundColor(Color.getYellow());
         //Set format of a cell
         style.getFont().setName("Courier New");
         style.setVerticalAlignment(TextAlignmentType.TOP);
          cell.setStyle(style);

Methods

MethodDescription
calculate(CalculationOptions options)Calculates the formula of the cell.
characters(int startIndex, int length)Returns a Characters object that represents a range of characters within the cell text.
containsExternalLink()Indicates whether this cell contains an external link.
copy(Cell cell)Copies data from a source cell.
equals(Cell cell)Checks whether this object refers to the same cell with another cell object.
equals(Object obj)Checks whether this object refers to the same cell with another.
getArrayRange()Gets the array range if the cell’s formula is an array formula.
getBoolValue()Gets the boolean value contained in the cell.
getCharacters()Returns all Characters objects that represents a range of characters within the cell text.
getCharacters(boolean flag)Returns all Characters objects that represents a range of characters within the cell text.
getClass()
getColumn()Gets column number (zero based) of the cell.
getComment()Gets the comment of this cell.
getConditionalFormattingResult()Get the result of the conditional formatting.
getDateTimeValue()Gets the DateTime value contained in the cell.
getDependents(boolean isAll)Get all cells whose formula references to this cell directly.
getDependentsInCalculation(boolean recursive)Gets all cells whose calculated result depends on this cell.
getDisplayStringValue()Gets the formatted string value of this cell by cell’s display style.
getDisplayStyle()Gets the display style of the cell.
getDisplayStyle(boolean includeMergedBorders)Gets the display style of the cell.
getDoubleValue()Gets the double value contained in the cell.
getEmbeddedImage()Gets the embeddedn image in the cell.
getFloatValue()Gets the float value contained in the cell.
getFormatConditions()Gets format conditions which applies to this cell.
getFormula()Gets a formula of the Cell.
getFormula(boolean isR1C1, boolean isLocal)Get the formula of this cell.
getFormulaLocal()Get the locale formatted formula of the cell.
getHeightOfValue()Gets the height of the value in unit of pixels.
getHtmlString()Gets the html string which contains data and some formats in this cell.
getHtmlString(boolean html5)Gets the html string which contains data and some formats in this cell.
getIntValue()Gets the integer value contained in the cell.
getLeafs()Get all cells which reference to this cell directly and need to be updated when this cell is modified.
getLeafs(boolean recursive)Get all cells which will be updated when this cell is modified.
getMergedRange()Returns a Range object which represents a merged range.
getName()Gets the name of the cell.
getNumberCategoryType()Represents the category type of this cell’s number formatting.
getPrecedents()Gets all references appearing in this cell’s formula.
getPrecedentsInCalculation()Gets all precedents(reference to cells in current workbook) used by this cell’s formula while calculating it.
getR1C1Formula()Gets a R1C1 formula of the Cell.
getRichValue()Gets rich value of the cell.
getRow()Gets row number (zero based) of the cell.
getSharedStyleIndex()Gets cell’s shared style index in the style pool.
getStringValue()Gets the string value contained in the cell.
getStringValue(int formatStrategy)Gets the string value by specific formatted strategy.
getStringValueWithoutFormat()Gets cell’s value as string without any format.
getStyle()Gets the cell style.
getStyle(boolean checkBorders)If checkBorders is true, check whether other cells’ borders will effect the style of this cell.
getTable()Gets the table which contains this cell.
getType()Represents cell value type.
getValidation()Gets the validation applied to this cell.
getValidationValue()Gets the value of validation which applied to this cell.
getValue()Gets the value contained in this cell.
getWidthOfValue()Gets the width of the value in unit of pixels.
getWorksheet()Gets the parent worksheet.
hasCustomStyle()Indicates whether this cell has custom style settings(different from the default one inherited from corresponding row, column, or workbook).
hashCode()Serves as a hash function for a particular type.
insertText(int index, String text)Insert some characters to the cell.
isArrayFormula()Indicates whether the cell formula is an array formula.
isArrayHeader()Indicates the cell’s formula is an array formula and it is the first cell of the array.
isCheckBoxStyle()Indicates whether setting this cell as a check box.
isDynamicArrayFormula()Indicates whether the cell’s formula is dynamic array formula(true) or legacy array formula(false).
isErrorValue()Checks if the value of this cell is an error.
isFormula()Represents if the specified cell contains formula.
isInArray()Indicates whether the cell formula is an array formula.
isInTable()Indicates whether this cell is part of table formula.
isMerged()Checks if a cell is part of a merged range or not.
isNumericValue()Indicates whether the value of this cell is numeric(int, double and datetime)
isRichText()Indicates whether the string value of this cell is a rich formatted text.
isSharedFormula()Indicates whether the cell formula is part of shared formula.
isStyleSet()Indicates if the cell’s style is set.
isTableFormula()Indicates whether this cell is part of table formula.
notify()
notifyAll()
putValue(boolean boolValue)Puts a boolean value into the cell.
putValue(DateTime dateTime)Puts a DateTime value into the cell.
putValue(double doubleValue)Puts a double value into the cell.
putValue(int intValue)Puts an integer value into the cell.
putValue(Object objectValue)Puts an object value into the cell.
putValue(String stringValue)Puts a string value into the cell.
putValue(String stringValue, boolean isConverted)Puts a string value into the cell and converts the value to other data type if appropriate.
putValue(String stringValue, boolean isConverted, boolean setStyle)Puts a value into the cell, if appropriate the value will be converted to other data type and cell’s number format will be reset.
removeArrayFormula(boolean leaveNormalFormula)Remove array formula.
replace(String placeHolder, String newValue, ReplaceOptions options)Replace text of the cell with options.
setArrayFormula(String arrayFormula, int rowNumber, int columnNumber)Sets an array formula(legacy array formula entered via CTRL+SHIFT+ENTER in ms excel) to a range of cells.
setArrayFormula(String arrayFormula, int rowNumber, int columnNumber, boolean isR1C1, boolean isLocal)Sets an array formula to a range of cells.
setArrayFormula(String arrayFormula, int rowNumber, int columnNumber, FormulaParseOptions options)Sets an array formula to a range of cells.
setArrayFormula(String arrayFormula, int rowNumber, int columnNumber, FormulaParseOptions options, Object[][] values)Sets an array formula to a range of cells.
setCharacters(FontSetting[] characters)Sets rich text format of the cell.
setCheckBoxStyle(boolean value)Indicates whether setting this cell as a check box.
setDynamicArrayFormula(String arrayFormula, FormulaParseOptions options, boolean calculateValue)Sets dynamic array formula and make the formula spill into neighboring cells if possible.
setDynamicArrayFormula(String arrayFormula, FormulaParseOptions options, Object[][] values, boolean calculateRange, boolean calculateValue)Sets dynamic array formula and make the formula spill into neighboring cells if possible.
setDynamicArrayFormula(String arrayFormula, FormulaParseOptions options, Object[][] values, boolean calculateRange, boolean calculateValue, CalculationOptions copts)Sets dynamic array formula and make the formula spill into neighboring cells if possible.
setEmbeddedImage(byte[] value)Sets the embeddedn image in the cell.
setFormula(String value)Sets a formula of the Cell.
setFormula(String formula, boolean isR1C1, boolean isLocal, Object value)Set the formula and the value of the formula.
setFormula(String formula, FormulaParseOptions options)Set the formula and the value(calculated result) of the formula.
setFormula(String formula, FormulaParseOptions options, Object value)Set the formula and the value(calculated result) of the formula.
setFormula(String formula, Object value)Set the formula and the value(calculated result) of the formula.
setFormulaLocal(String value)Get the locale formatted formula of the cell.
setHtmlString(String value)Sets the html string which contains data and some formats in this cell.
setR1C1Formula(String value)Sets a R1C1 formula of the Cell.
setSharedFormula(String sharedFormula, int rowNumber, int columnNumber)Sets shared formulas to a range of cells.
setSharedFormula(String sharedFormula, int rowNumber, int columnNumber, boolean isR1C1, boolean isLocal)Sets a formula to a range of cells.
setSharedFormula(String sharedFormula, int rowNumber, int columnNumber, FormulaParseOptions options)Sets shared formulas to a range of cells.
setSharedFormula(String sharedFormula, int rowNumber, int columnNumber, FormulaParseOptions options, Object[][] values)Sets shared formulas to a range of cells.
setStyle(Style style)Sets the cell style.
setStyle(Style style, boolean explicitFlag)Apply the changed property of style to the cell.
setStyle(Style style, StyleFlag flag)Apply the cell style based on flags.
setTableFormula(int rowNumber, int columnNumber, int rowIndexOfInputCell, int columnIndexOfInputCell, boolean isRowInput, Object[][] values)Create one-variable data table for given range starting from this cell.
setTableFormula(int rowNumber, int columnNumber, int rowIndexOfRowInputCell, int columnIndexOfRowInputCell, int rowIndexOfColumnInputCell, int columnIndexOfColumnInputCell, Object[][] values)Create two-variable data table for given range starting from this cell.
setTableFormula(int rowNumber, int columnNumber, String inputCell, boolean isRowInput, Object[][] values)Create one-variable data table for given range starting from this cell.
setTableFormula(int rowNumber, int columnNumber, String rowInputCell, String columnInputCell, Object[][] values)Create two-variable data table for given range starting from this cell.
setValue(Object value)Sets the value contained in this cell.
toJson()Convert Cell to JSON struct data.
toString()Returns a string represents the current Cell object.
wait()
wait(long arg0)
wait(long arg0, int arg1)

calculate(CalculationOptions options)

public void calculate(CalculationOptions options)

Calculates the formula of the cell.

Parameters:

ParameterTypeDescription
optionsCalculationOptionsOptions for calculation

characters(int startIndex, int length)

public FontSetting characters(int startIndex, int length)

Returns a Characters object that represents a range of characters within the cell text.

Remarks

This method only works on cell with string value.

Example

         Workbook excel = new Workbook();
         	Cells cells = excel.getWorksheets().get(0).getCells();
         cells.get("A1").putValue("Helloworld");
         cells.get("A1").characters(5, 5).getFont().setBold(true);
         cells.get("A1").characters(5, 5).getFont().setColor(Color.getBlue());

Parameters:

ParameterTypeDescription
startIndexintThe index of the start of the character.
lengthintThe number of characters.

Returns: FontSetting - Characters object.

public boolean containsExternalLink()

Indicates whether this cell contains an external link. Only applies when the cell is a formula cell.

Returns: boolean

copy(Cell cell)

public void copy(Cell cell)

Copies data from a source cell.

Parameters:

ParameterTypeDescription
cellCellSource Cell object.

equals(Cell cell)

public boolean equals(Cell cell)

Checks whether this object refers to the same cell with another cell object.

Parameters:

ParameterTypeDescription
cellCellanother cell object

Returns: boolean - true if two cell objects refers to the same cell.

equals(Object obj)

public boolean equals(Object obj)

Checks whether this object refers to the same cell with another.

Parameters:

ParameterTypeDescription
objjava.lang.Objectanother object

Returns: boolean - true if two objects refers to the same cell.

getArrayRange()

public CellArea getArrayRange()

Gets the array range if the cell’s formula is an array formula.

Remarks

Only applies when the cell’s formula is an array formula

Returns: CellArea - The array range.

getBoolValue()

public boolean getBoolValue()

Gets the boolean value contained in the cell.

Returns: boolean

getCharacters()

public FontSetting[] getCharacters()

Returns all Characters objects that represents a range of characters within the cell text.

Returns: com.aspose.cells.FontSetting[] - All Characters objects

getCharacters(boolean flag)

public FontSetting[] getCharacters(boolean flag)

Returns all Characters objects that represents a range of characters within the cell text.

Parameters:

ParameterTypeDescription
flagbooleanIndicates whether applying table style to the cell if the cell is in the table.

Returns: com.aspose.cells.FontSetting[] - All Characters objects

getClass()

public final native Class<?> getClass()

Returns: java.lang.Class

getColumn()

public int getColumn()

Gets column number (zero based) of the cell.

Returns: int

getComment()

public Comment getComment()

Gets the comment of this cell.

Remarks

If there is no comment applies to the cell, returns null.

Returns: Comment

getConditionalFormattingResult()

public ConditionalFormattingResult getConditionalFormattingResult()

Get the result of the conditional formatting.

Remarks

Returns null if no conditional formatting is applied to this cell,

Returns: ConditionalFormattingResult

getDateTimeValue()

public DateTime getDateTimeValue()

Gets the DateTime value contained in the cell.

Returns: DateTime

getDependents(boolean isAll)

public Cell[] getDependents(boolean isAll)

Get all cells whose formula references to this cell directly.

Remarks

  • If one reference containing this cell appears in one cell’s formula, that cell will be taken as the dependent of this cell, no matter the reference or this cell is used or not while calculating. For example, although cell A2 in formula “=IF(TRUE,A1,A2)” is not used while calculating, this formula is still be taken as A2’s dependent.
  • To get those formulas whose calculated results depend on this cell, please use .
  • When tracing dependents for one cell, all formulas in the workbook or worksheet will be analized and checked. So it is a time consumed process. If user need to trace dependents for lots of cells, using this method will cause poor performance. For performance consideration, user should use instead. Or, user may gather precedents map of all cells by firstly, and then build the dependents map according to the precedents map.

Example

         Workbook workbook = new Workbook();
         Cells cells = workbook.getWorksheets().get(0).getCells();
         cells.get("A1").setFormula("=B1+SUM(B1:B10)+[Book1.xls]Sheet1!B2");
         cells.get("A2").setFormula("=IF(TRUE,B2,B1)");
         Cell[] dependents = cells.get("B1").getDependents(true);
         for (int i = 0; i <dependents.length; i++)
         {
              System.out.println(dependents[i].getName());
         }

Parameters:

ParameterTypeDescription
isAllbooleanIndicates whether check formulas in other worksheets

Returns: com.aspose.cells.Cell[]

getDependentsInCalculation(boolean recursive)

public Iterator getDependentsInCalculation(boolean recursive)

Gets all cells whose calculated result depends on this cell.

Remarks

To use this method, please make sure the workbook has been set with true value for FormulaSettings.getEnableCalculationChain() and has been fully calculated with this setting. If there is no formula reference to this cell, null will be returned.

Example

         Workbook workbook = new Workbook();
         Cells cells = workbook.getWorksheets().get(0).getCells();
         cells.get("A1").setFormula("=B1+SUM(B1:B10)+[Book1.xls]Sheet1!B2");
         cells.get("A2").setFormula("=IF(TRUE,B2,B1)");
         workbook.getSettings().getFormulaSettings().setEnableCalculationChain(true);
         workbook.calculateFormula();
         Iterator en = cells.get("B1").getDependentsInCalculation(false);
         System.out.println("B1's calculation dependents:");
         while(en.hasNext())
         {
             Cell c = (Cell)en.next();
             System.out.println(c.getName());
         }
         en = cells.get("B2").getDependentsInCalculation(false);
         System.out.println("B2's calculation dependents:");
         while(en.hasNext())
         {
             Cell c = (Cell)en.next();
             System.out.println(c.getName());
         }

Parameters:

ParameterTypeDescription
recursivebooleanWhether returns those dependents which do not reference to this cell directly but reference to other leafs of this cell

Returns: java.util.Iterator - Enumerator to enumerate all dependents(Cell objects)

getDisplayStringValue()

public String getDisplayStringValue()

Gets the formatted string value of this cell by cell’s display style.

Returns: java.lang.String

getDisplayStyle()

public Style getDisplayStyle()

Gets the display style of the cell. If this cell is also affected by other settings such as conditional formatting, list objects, etc., then the display style may be different from cell.GetStyle().

Returns: Style

getDisplayStyle(boolean includeMergedBorders)

public Style getDisplayStyle(boolean includeMergedBorders)

Gets the display style of the cell. If the cell is conditional formatted, the display style is not same as the cell.GetStyle().

Parameters:

ParameterTypeDescription
includeMergedBordersbooleanIndicates whether checking borders of the merged cells.

Returns: Style

getDoubleValue()

public double getDoubleValue()

Gets the double value contained in the cell.

Returns: double

getEmbeddedImage()

public byte[] getEmbeddedImage()

Gets the embeddedn image in the cell.

Returns: byte[]

getFloatValue()

public float getFloatValue()

Gets the float value contained in the cell.

Returns: float

getFormatConditions()

public FormatConditionCollection[] getFormatConditions()

Gets format conditions which applies to this cell.

Returns: com.aspose.cells.FormatConditionCollection[] - Returns FormatConditionCollection object

getFormula()

public String getFormula()

Gets a formula of the Cell.

Remarks

A formula string always begins with an equal sign (=). And please always use comma(,) as parameters delimiter, such as “=SUM(A1, E1, H2)”.

Example

         Workbook excel = new Workbook();
         Cells cells = excel.getWorksheets().get(0).getCells();
         cells.get("B6").setFormula("=SUM(B2:B5, E1) + sheet1!A1");

Returns: java.lang.String

getFormula(boolean isR1C1, boolean isLocal)

public String getFormula(boolean isR1C1, boolean isLocal)

Get the formula of this cell.

Parameters:

ParameterTypeDescription
isR1C1booleanWhether the formula needs to be formatted as R1C1.
isLocalbooleanWhether the formula needs to be formatted by locale.

Returns: java.lang.String - the formula of this cell.

getFormulaLocal()

public String getFormulaLocal()

Get the locale formatted formula of the cell.

Returns: java.lang.String

getHeightOfValue()

public int getHeightOfValue()

Gets the height of the value in unit of pixels.

Returns: int -

getHtmlString()

public String getHtmlString()

Gets the html string which contains data and some formats in this cell.

Returns: java.lang.String

getHtmlString(boolean html5)

public String getHtmlString(boolean html5)

Gets the html string which contains data and some formats in this cell.

Parameters:

ParameterTypeDescription
html5booleanIndicates whether the value is compatible for html5

Returns: java.lang.String -

getIntValue()

public int getIntValue()

Gets the integer value contained in the cell.

Returns: int

getLeafs()

public Iterator getLeafs()

Get all cells which reference to this cell directly and need to be updated when this cell is modified.

Remarks

NOTE: This class is now obsolete. Instead, please use Cell.GetDependentsInCalculation(bool) to get all dependents in calculation chain. This property will be removed 12 months later since May 2022. Aspose apologizes for any inconvenience you may have experienced.

Returns: java.util.Iterator - Enumerator to enumerate all dependents(Cell)

getLeafs(boolean recursive)

public Iterator getLeafs(boolean recursive)

Get all cells which will be updated when this cell is modified.

Remarks

NOTE: This class is now obsolete. Instead, please use Cell.GetDependentsInCalculation(bool) to get all dependents in calculation chain. This property will be removed 12 months later since May 2022. Aspose apologizes for any inconvenience you may have experienced.

Parameters:

ParameterTypeDescription
recursivebooleanWhether returns those leafs that do not reference to this cell directly but reference to other leafs of this cell

Returns: java.util.Iterator - Enumerator to enumerate all dependents(Cell)

getMergedRange()

public Range getMergedRange()

Returns a Range object which represents a merged range.

Returns: Range - Range object. Null if this cell is not merged.

getName()

public String getName()

Gets the name of the cell.

Remarks

A cell name includes its column letter and row number. For example, the name of a cell in row 0 and column 0 is A1.

Returns: java.lang.String

getNumberCategoryType()

public int getNumberCategoryType()

Represents the category type of this cell’s number formatting.

See NumberCategoryType.

Remarks

When cell’s formatting pattern is combined with conditional formatting patterns, then the returned type is corresponding to the part which is used for current value of this cell. For example, if the formatting pattern for this cell is “#,##0;(#,##0);”-";@", then when cell’s value is numeric and not 0, the returned type is NumberCategoryType.NUMBER; When cell’s value is 0 or not numeric value, the returned type is NumberCategoryType.TEXT.

Returns: int

getPrecedents()

public ReferredAreaCollection getPrecedents()

Gets all references appearing in this cell’s formula.

Remarks

  • Returns null if this is not a formula cell.
  • All references appearing in this cell’s formula will be returned no matter they are referenced or not while calculating. For example, although cell A2 in formula “=IF(TRUE,A1,A2)” is not used while calculating, it is still taken as the formula’s precedents.
  • To get those references which influence the calculation only, please use .

Example

         Workbook workbook = new Workbook();
         Cells cells = workbook.getWorksheets().get(0).getCells();
         cells.get("A1").setFormula("=B1+SUM(B1:B10)+[Book1.xls]Sheet1!A1");
         ReferredAreaCollection areas = cells.get("A1").getPrecedents();
         for (int i = 0; i <areas.getCount(); i++)
         {
              ReferredArea area = areas.get(i);
              StringBuilder stringBuilder = new StringBuilder();
              if (area.isExternalLink())
              {
                  stringBuilder.append("[");
                  stringBuilder.append(area.getExternalFileName());
                  stringBuilder.append("]");
              }
              stringBuilder.append(area.getSheetName());
              stringBuilder.append("!");
              stringBuilder.append(CellsHelper.cellIndexToName(area.getStartRow(), area.getStartColumn()));
              if (area.isArea())
              {
                  stringBuilder.append(":");
                  stringBuilder.append(CellsHelper.cellIndexToName(area.getEndRow(), area.getEndColumn()));
              }
              System.out.println(stringBuilder.toString());
         }

Returns: ReferredAreaCollection - Collection of all references appearing in this cell’s formula.

getPrecedentsInCalculation()

public Iterator getPrecedentsInCalculation()

Gets all precedents(reference to cells in current workbook) used by this cell’s formula while calculating it.

Remarks

This method can only work with the situation that FormulaSettings.getEnableCalculationChain() is true for the workbook and the workbook has been fully calculated. If this cell is not a formula or it does not reference to any other cells, null will be returned.

Example

         Workbook workbook = new Workbook();
         Cells cells = workbook.getWorksheets().get(0).getCells();
         cells.get("A2").setFormula("=IF(TRUE,B2,B1)");
         workbook.getSettings().getFormulaSettings().setEnableCalculationChain(true);
         workbook.calculateFormula();
         Iterator en = cells.get("A2").getPrecedentsInCalculation();
         System.out.println("A2's calculation precedents:");
         while(en.hasNext())
         {
             ReferredArea r = (ReferredArea)en.next();
             System.out.println(r);
         }

Returns: java.util.Iterator - Enumerator to enumerate all references(ReferredArea)

getR1C1Formula()

public String getR1C1Formula()

Gets a R1C1 formula of the Cell.

Returns: java.lang.String

getRichValue()

public CellRichValue getRichValue()

Gets rich value of the cell.

Returns: CellRichValue

getRow()

public int getRow()

Gets row number (zero based) of the cell.

Returns: int

getSharedStyleIndex()

public int getSharedStyleIndex()

Gets cell’s shared style index in the style pool.

Returns: int

getStringValue()

public String getStringValue()

Gets the string value contained in the cell. If the type of this cell is string, then return the string value itself. For other cell types, the formatted string value (formatted with the specified style of this cell) will be returned. The formatted cell value is same with what you can get from excel when copying a cell as text(such as copying cell to text editor or exporting to csv).

Returns: java.lang.String

getStringValue(int formatStrategy)

public String getStringValue(int formatStrategy)

Gets the string value by specific formatted strategy.

Parameters:

ParameterTypeDescription
formatStrategyintCellValueFormatStrategy. The formatted strategy.

Returns: java.lang.String -

getStringValueWithoutFormat()

public String getStringValueWithoutFormat()

Gets cell’s value as string without any format.

Remarks

NOTE: This method is now obsolete. Instead, User should get the value object and format it according to the value type and the specific requirement. This property will be removed 12 months later since December 2020. Aspose apologizes for any inconvenience you may have experienced.

Returns: java.lang.String

getStyle()

public Style getStyle()

Gets the cell style.

Remarks

To change the style of the cell, please call Cell.SetStyle() method after modifying the returned style object. This method is same with getStyle(boolean) with true value for the parameter.

Returns: Style - Style object.

getStyle(boolean checkBorders)

public Style getStyle(boolean checkBorders)

If checkBorders is true, check whether other cells’ borders will effect the style of this cell.

Remarks

Parameters:

ParameterTypeDescription
checkBordersbooleanCheck other cells’ borders

Returns: Style - Style object.

getTable()

public ListObject getTable()

Gets the table which contains this cell.

Returns: ListObject -

getType()

public int getType()

Represents cell value type.

See CellValueType.

Returns: int

getValidation()

public Validation getValidation()

Gets the validation applied to this cell.

Returns: Validation -

getValidationValue()

public boolean getValidationValue()

Gets the value of validation which applied to this cell.

Returns: boolean -

getValue()

public Object getValue()

Gets the value contained in this cell.

Remarks

Possible type:

null,

Boolean,

DateTime,

Double,

Integer

String.

For int value, it may be returned as an Integer object or a Double object. And there is no guarantee that the returned value will be kept as the same type of object always.

Returns: java.lang.Object

getWidthOfValue()

public int getWidthOfValue()

Gets the width of the value in unit of pixels.

Returns: int -

getWorksheet()

public Worksheet getWorksheet()

Gets the parent worksheet.

Returns: Worksheet

hasCustomStyle()

public boolean hasCustomStyle()

Indicates whether this cell has custom style settings(different from the default one inherited from corresponding row, column, or workbook).

Returns: boolean

hashCode()

public int hashCode()

Serves as a hash function for a particular type.

Returns: int - A hash code for current Cell object.

insertText(int index, String text)

public void insertText(int index, String text)

Insert some characters to the cell. If the cell is rich formatted, this method could keep the original formatting.

Parameters:

ParameterTypeDescription
indexintThe index.
textjava.lang.StringInserted text.

isArrayFormula()

public boolean isArrayFormula()

Indicates whether the cell formula is an array formula.

Returns: boolean

isArrayHeader()

public boolean isArrayHeader()

Indicates the cell’s formula is an array formula and it is the first cell of the array.

Returns: boolean

isCheckBoxStyle()

public boolean isCheckBoxStyle()

Indicates whether setting this cell as a check box.

Returns: boolean

isDynamicArrayFormula()

public boolean isDynamicArrayFormula()

Indicates whether the cell’s formula is dynamic array formula(true) or legacy array formula(false).

Returns: boolean

isErrorValue()

public boolean isErrorValue()

Checks if the value of this cell is an error.

Remarks

Also applies to formula cell to check whether the calculated result is an error.

Returns: boolean

isFormula()

public boolean isFormula()

Represents if the specified cell contains formula.

Returns: boolean

isInArray()

public boolean isInArray()

Indicates whether the cell formula is an array formula.

Remarks

NOTE: This class is now obsolete. Instead, please use Cell.IsArrayFormula to check whether the cell formula is an array formula. This property will be removed 12 months later since May 2018. Aspose apologizes for any inconvenience you may have experienced.

Returns: boolean

isInTable()

public boolean isInTable()

Indicates whether this cell is part of table formula.

Remarks

NOTE: This class is now obsolete. Instead, please use Cell.IsTableFormula to check whether the cell formula is part of table formula. This property will be removed 12 months later since May 2018. Aspose apologizes for any inconvenience you may have experienced.

Returns: boolean

isMerged()

public boolean isMerged()

Checks if a cell is part of a merged range or not.

Returns: boolean

isNumericValue()

public boolean isNumericValue()

Indicates whether the value of this cell is numeric(int, double and datetime)

Remarks

Also applies to formula cell to check the calculated result

Returns: boolean

isRichText()

public boolean isRichText()

Indicates whether the string value of this cell is a rich formatted text.

Returns: boolean

isSharedFormula()

public boolean isSharedFormula()

Indicates whether the cell formula is part of shared formula.

Returns: boolean

isStyleSet()

public boolean isStyleSet()

Indicates if the cell’s style is set. If return false, it means this cell has a default cell format.

Returns: boolean

isTableFormula()

public boolean isTableFormula()

Indicates whether this cell is part of table formula.

Returns: boolean

notify()

public final native void notify()

notifyAll()

public final native void notifyAll()

putValue(boolean boolValue)

public void putValue(boolean boolValue)

Puts a boolean value into the cell.

Parameters:

ParameterTypeDescription
boolValueboolean

putValue(DateTime dateTime)

public void putValue(DateTime dateTime)

Puts a DateTime value into the cell.

Remarks

Setting a DateTime value for a cell dose not means the cell will be formatted as date time automatically. DateTime value was maintained as numeric value in the data model of both ms excel and Aspose.Cells. Whether the numeric value will be taken as the numeric value itself or date time depends on the number format applied on this cell. If this cell has not been formatted as date time, it will be displayed as a numeric value even though what you input is DateTime.

Example

This example shows how to set DateTime value to a cell and make it be displayed as date time.

         Workbook excel = new Workbook();
         Cells cells = excel.getWorksheets().get(0).getCells();
 
         //Put date time into a cell
         Cell cell = cells.get(0, 0);
         cell.putValue(new DateTime(2023, 5, 15));
         Style style = cell.getStyle(false);
         style.setNumber(14);
         cell.setStyle(style);

Parameters:

ParameterTypeDescription
dateTimeDateTimeInput value

putValue(double doubleValue)

public void putValue(double doubleValue)

Puts a double value into the cell.

Parameters:

ParameterTypeDescription
doubleValuedoubleInput value

putValue(int intValue)

public void putValue(int intValue)

Puts an integer value into the cell.

Parameters:

ParameterTypeDescription
intValueintInput value

putValue(Object objectValue)

public void putValue(Object objectValue)

Puts an object value into the cell.

Parameters:

ParameterTypeDescription
objectValuejava.lang.Objectinput value

putValue(String stringValue)

public void putValue(String stringValue)

Puts a string value into the cell.

Parameters:

ParameterTypeDescription
stringValuejava.lang.StringInput value

putValue(String stringValue, boolean isConverted)

public void putValue(String stringValue, boolean isConverted)

Puts a string value into the cell and converts the value to other data type if appropriate.

Parameters:

ParameterTypeDescription
stringValuejava.lang.StringInput value
isConvertedbooleanTrue: converted to other data type if appropriate.

putValue(String stringValue, boolean isConverted, boolean setStyle)

public void putValue(String stringValue, boolean isConverted, boolean setStyle)

Puts a value into the cell, if appropriate the value will be converted to other data type and cell’s number format will be reset.

Parameters:

ParameterTypeDescription
stringValuejava.lang.StringInput value
isConvertedbooleanTrue: converted to other data type if appropriate.
setStylebooleanTrue: set the number format to cell’s style when converting to other data type

removeArrayFormula(boolean leaveNormalFormula)

public void removeArrayFormula(boolean leaveNormalFormula)

Remove array formula.

Parameters:

ParameterTypeDescription
leaveNormalFormulabooleanTrue represents converting the array formula to normal formula.

replace(String placeHolder, String newValue, ReplaceOptions options)

public void replace(String placeHolder, String newValue, ReplaceOptions options)

Replace text of the cell with options.

Parameters:

ParameterTypeDescription
placeHolderjava.lang.StringCell placeholder
newValuejava.lang.StringString value to replace
optionsReplaceOptionsThe replace options

setArrayFormula(String arrayFormula, int rowNumber, int columnNumber)

public void setArrayFormula(String arrayFormula, int rowNumber, int columnNumber)

Sets an array formula(legacy array formula entered via CTRL+SHIFT+ENTER in ms excel) to a range of cells.

Parameters:

ParameterTypeDescription
arrayFormulajava.lang.StringArray formula.
rowNumberintNumber of rows to populate result of the array formula.
columnNumberintNumber of columns to populate result of the array formula.

setArrayFormula(String arrayFormula, int rowNumber, int columnNumber, boolean isR1C1, boolean isLocal)

public void setArrayFormula(String arrayFormula, int rowNumber, int columnNumber, boolean isR1C1, boolean isLocal)

Sets an array formula to a range of cells.

Remarks

NOTE: This class is now obsolete. Instead, please use Cell.SetArrayFormula(string,int,int,FormulaParseOptions). This property will be removed 12 months later since December 2019. Aspose apologizes for any inconvenience you may have experienced.

Parameters:

ParameterTypeDescription
arrayFormulajava.lang.StringArray formula.
rowNumberintNumber of rows to populate result of the array formula.
columnNumberintNumber of columns to populate result of the array formula.
isR1C1booleanwhether the formula is R1C1 formula
isLocalbooleanwhether the formula is locale formatted

setArrayFormula(String arrayFormula, int rowNumber, int columnNumber, FormulaParseOptions options)

public void setArrayFormula(String arrayFormula, int rowNumber, int columnNumber, FormulaParseOptions options)

Sets an array formula to a range of cells.

Parameters:

ParameterTypeDescription
arrayFormulajava.lang.StringArray formula.
rowNumberintNumber of rows to populate result of the array formula.
columnNumberintNumber of columns to populate result of the array formula.
optionsFormulaParseOptionsOptions for parsing the formula.

setArrayFormula(String arrayFormula, int rowNumber, int columnNumber, FormulaParseOptions options, Object[][] values)

public void setArrayFormula(String arrayFormula, int rowNumber, int columnNumber, FormulaParseOptions options, Object[][] values)

Sets an array formula to a range of cells.

Parameters:

ParameterTypeDescription
arrayFormulajava.lang.StringArray formula.
rowNumberintNumber of rows to populate result of the array formula.
columnNumberintNumber of columns to populate result of the array formula.
optionsFormulaParseOptionsOptions for parsing the formula.
valuesjava.lang.Object[][]values for those cells with given array formula

setCharacters(FontSetting[] characters)

public void setCharacters(FontSetting[] characters)

Sets rich text format of the cell.

Parameters:

ParameterTypeDescription
charactersFontSetting[]All Characters objects.

setCheckBoxStyle(boolean value)

public void setCheckBoxStyle(boolean value)

Indicates whether setting this cell as a check box.

Parameters:

ParameterTypeDescription
valueboolean

setDynamicArrayFormula(String arrayFormula, FormulaParseOptions options, boolean calculateValue)

public CellArea setDynamicArrayFormula(String arrayFormula, FormulaParseOptions options, boolean calculateValue)

Sets dynamic array formula and make the formula spill into neighboring cells if possible.

Remarks

the returned range may be not same with the actual one that this dynamic array formula spills into. If there are non-empty cells in the range, the formula will be set for current cell only and marked as “#SPILL!”. But for such kind of situation we still return the whole range that this formula should spill into.

Parameters:

ParameterTypeDescription
arrayFormulajava.lang.Stringthe formula expression
optionsFormulaParseOptionsoptions to parse formula. “Parse” option will be ignored and the formula will always be parsed immediately
calculateValuebooleanwhether calculate this dynamic array formula for those cells in the spilled range.

Returns: CellArea - the range that the formula should spill into.

setDynamicArrayFormula(String arrayFormula, FormulaParseOptions options, Object[][] values, boolean calculateRange, boolean calculateValue)

public CellArea setDynamicArrayFormula(String arrayFormula, FormulaParseOptions options, Object[][] values, boolean calculateRange, boolean calculateValue)

Sets dynamic array formula and make the formula spill into neighboring cells if possible.

Remarks

the returned range may be not same with the actual one that this dynamic array formula spills into. If there are non-empty cells in the range, the formula will be set for current cell only and marked as “#SPILL!”. But for such kind of situation we still return the whole range that this formula should spill into.

Parameters:

ParameterTypeDescription
arrayFormulajava.lang.Stringthe formula expression
optionsFormulaParseOptionsoptions to parse formula. “Parse” option will be ignored and the formula will always be parsed immediately
valuesjava.lang.Object[][]values(calculated results) for those cells with given dynamic array formula
calculateRangebooleanWhether calculate the spilled range for this dynamic array formula. If the “values” parameter is not null and this flag is false, then the spilled range’s height will be values.Length and width will be values[0].Length.
calculateValuebooleanwhether calculate this dynamic array formula for those cells in the spilled range when “values” is null or corresponding item in “values” for one cell is null.

Returns: CellArea - the range that the formula should spill into.

setDynamicArrayFormula(String arrayFormula, FormulaParseOptions options, Object[][] values, boolean calculateRange, boolean calculateValue, CalculationOptions copts)

public CellArea setDynamicArrayFormula(String arrayFormula, FormulaParseOptions options, Object[][] values, boolean calculateRange, boolean calculateValue, CalculationOptions copts)

Sets dynamic array formula and make the formula spill into neighboring cells if possible.

Remarks

the returned range may be not same with the actual one that this dynamic array formula spills into. If there are non-empty cells in the range, the formula will be set for current cell only and marked as “#SPILL!”. But for such kind of situation we still return the whole range that this formula should spill into.

Parameters:

ParameterTypeDescription
arrayFormulajava.lang.Stringthe formula expression
optionsFormulaParseOptionsoptions to parse formula. “Parse” option will be ignored and the formula will always be parsed immediately
valuesjava.lang.Object[][]values(calculated results) for those cells with given dynamic array formula
calculateRangebooleanWhether calculate the spilled range for this dynamic array formula. If the “values” parameter is not null and this flag is false, then the spilled range’s height will be values.Length and width will be values[0].Length.
calculateValuebooleanwhether calculate this dynamic array formula for those cells in the spilled range when “values” is null or corresponding item in “values” for one cell is null.
coptsCalculationOptionsThe options for calculating formula. Commonly, for performance consideration, the CalculationOptions.getRecursive() property should be false.

Returns: CellArea - the range that the formula should spill into.

setEmbeddedImage(byte[] value)

public void setEmbeddedImage(byte[] value)

Sets the embeddedn image in the cell.

Parameters:

ParameterTypeDescription
valuebyte[]

setFormula(String value)

public void setFormula(String value)

Sets a formula of the Cell.

Remarks

A formula string always begins with an equal sign (=). And please always use comma(,) as parameters delimiter, such as “=SUM(A1, E1, H2)”.

Parameters:

ParameterTypeDescription
valuejava.lang.String

setFormula(String formula, boolean isR1C1, boolean isLocal, Object value)

public void setFormula(String formula, boolean isR1C1, boolean isLocal, Object value)

Set the formula and the value of the formula.

Remarks

NOTE: This class is now obsolete. Instead, please use Cell.SetFormula(string,FormulaParseOptions,object). This property will be removed 12 months later since December 2019. Aspose apologizes for any inconvenience you may have experienced.

Parameters:

ParameterTypeDescription
formulajava.lang.StringThe formula.
isR1C1booleanWhether the formula is R1C1 formula.
isLocalbooleanWhether the formula is locale formatted.
valuejava.lang.ObjectThe value of the formula.

setFormula(String formula, FormulaParseOptions options)

public void setFormula(String formula, FormulaParseOptions options)

Set the formula and the value(calculated result) of the formula.

Parameters:

ParameterTypeDescription
formulajava.lang.StringThe formula.
optionsFormulaParseOptionsOptions for parsing the formula.

setFormula(String formula, FormulaParseOptions options, Object value)

public void setFormula(String formula, FormulaParseOptions options, Object value)

Set the formula and the value(calculated result) of the formula.

Parameters:

ParameterTypeDescription
formulajava.lang.StringThe formula.
optionsFormulaParseOptionsOptions for parsing the formula.
valuejava.lang.ObjectThe value(calculated result) of the formula.

setFormula(String formula, Object value)

public void setFormula(String formula, Object value)

Set the formula and the value(calculated result) of the formula.

Parameters:

ParameterTypeDescription
formulajava.lang.StringThe formula.
valuejava.lang.ObjectThe value(calculated result) of the formula.

setFormulaLocal(String value)

public void setFormulaLocal(String value)

Get the locale formatted formula of the cell.

Parameters:

ParameterTypeDescription
valuejava.lang.String

setHtmlString(String value)

public void setHtmlString(String value)

Sets the html string which contains data and some formats in this cell.

Parameters:

ParameterTypeDescription
valuejava.lang.String

setR1C1Formula(String value)

public void setR1C1Formula(String value)

Sets a R1C1 formula of the Cell.

Parameters:

ParameterTypeDescription
valuejava.lang.String

setSharedFormula(String sharedFormula, int rowNumber, int columnNumber)

public void setSharedFormula(String sharedFormula, int rowNumber, int columnNumber)

Sets shared formulas to a range of cells.

Remarks

Parameters:

ParameterTypeDescription
sharedFormulajava.lang.StringShared formula.
rowNumberintNumber of rows to populate the formula.
columnNumberintNumber of columns to populate the formula.

setSharedFormula(String sharedFormula, int rowNumber, int columnNumber, boolean isR1C1, boolean isLocal)

public void setSharedFormula(String sharedFormula, int rowNumber, int columnNumber, boolean isR1C1, boolean isLocal)

Sets a formula to a range of cells.

Remarks

NOTE: This class is now obsolete. Instead, please use Cell.SetSharedFormula(string,int,int,FormulaParseOptions). This property will be removed 12 months later since December 2019. Aspose apologizes for any inconvenience you may have experienced.

Parameters:

ParameterTypeDescription
sharedFormulajava.lang.StringShared formula.
rowNumberintNumber of rows to populate the formula.
columnNumberintNumber of columns to populate the formula.
isR1C1booleanwhether the formula is R1C1 formula
isLocalbooleanwhether the formula is locale formatted

setSharedFormula(String sharedFormula, int rowNumber, int columnNumber, FormulaParseOptions options)

public void setSharedFormula(String sharedFormula, int rowNumber, int columnNumber, FormulaParseOptions options)

Sets shared formulas to a range of cells.

Parameters:

ParameterTypeDescription
sharedFormulajava.lang.StringShared formula.
rowNumberintNumber of rows to populate the formula.
columnNumberintNumber of columns to populate the formula.
optionsFormulaParseOptionsOptions for parsing the formula.

setSharedFormula(String sharedFormula, int rowNumber, int columnNumber, FormulaParseOptions options, Object[][] values)

public void setSharedFormula(String sharedFormula, int rowNumber, int columnNumber, FormulaParseOptions options, Object[][] values)

Sets shared formulas to a range of cells.

Parameters:

ParameterTypeDescription
sharedFormulajava.lang.StringShared formula.
rowNumberintNumber of rows to populate the formula.
columnNumberintNumber of columns to populate the formula.
optionsFormulaParseOptionsOptions for parsing the formula.
valuesjava.lang.Object[][]values for those cells with given shared formula

setStyle(Style style)

public void setStyle(Style style)

Sets the cell style.

Remarks

If the border settings are changed, the border of adjust cells will be updated too.

Parameters:

ParameterTypeDescription
styleStyleThe cell style.

setStyle(Style style, boolean explicitFlag)

public void setStyle(Style style, boolean explicitFlag)

Apply the changed property of style to the cell.

Parameters:

ParameterTypeDescription
styleStyleThe cell style.
explicitFlagbooleanTrue, only overwriting formatting which is explicitly set.

setStyle(Style style, StyleFlag flag)

public void setStyle(Style style, StyleFlag flag)

Apply the cell style based on flags.

Parameters:

ParameterTypeDescription
styleStyleThe cell style.
flagStyleFlagThe style flag.

setTableFormula(int rowNumber, int columnNumber, int rowIndexOfInputCell, int columnIndexOfInputCell, boolean isRowInput, Object[][] values)

public void setTableFormula(int rowNumber, int columnNumber, int rowIndexOfInputCell, int columnIndexOfInputCell, boolean isRowInput, Object[][] values)

Create one-variable data table for given range starting from this cell.

Parameters:

ParameterTypeDescription
rowNumberintNumber of rows to populate the formula.
columnNumberintNumber of columns to populate the formula.
rowIndexOfInputCellintrow index of the input cell
columnIndexOfInputCellintcolumn index of the input cell
isRowInputbooleanIndicates whether the input cell is a row input cell(true) or a column input cell(false).
valuesjava.lang.Object[][]values for cells in table formula range

setTableFormula(int rowNumber, int columnNumber, int rowIndexOfRowInputCell, int columnIndexOfRowInputCell, int rowIndexOfColumnInputCell, int columnIndexOfColumnInputCell, Object[][] values)

public void setTableFormula(int rowNumber, int columnNumber, int rowIndexOfRowInputCell, int columnIndexOfRowInputCell, int rowIndexOfColumnInputCell, int columnIndexOfColumnInputCell, Object[][] values)

Create two-variable data table for given range starting from this cell.

Parameters:

ParameterTypeDescription
rowNumberintNumber of rows to populate the formula.
columnNumberintNumber of columns to populate the formula.
rowIndexOfRowInputCellintrow index of the row input cell
columnIndexOfRowInputCellintcolumn index of the row input cell
rowIndexOfColumnInputCellintrow index of the column input cell
columnIndexOfColumnInputCellintcolumn index of the column input cell
valuesjava.lang.Object[][]values for cells in table formula range

setTableFormula(int rowNumber, int columnNumber, String inputCell, boolean isRowInput, Object[][] values)

public void setTableFormula(int rowNumber, int columnNumber, String inputCell, boolean isRowInput, Object[][] values)

Create one-variable data table for given range starting from this cell.

Parameters:

ParameterTypeDescription
rowNumberintNumber of rows to populate the formula.
columnNumberintNumber of columns to populate the formula.
inputCelljava.lang.Stringthe input cell
isRowInputbooleanIndicates whether the input cell is a row input cell(true) or a column input cell(false).
valuesjava.lang.Object[][]values for cells in table formula range

setTableFormula(int rowNumber, int columnNumber, String rowInputCell, String columnInputCell, Object[][] values)

public void setTableFormula(int rowNumber, int columnNumber, String rowInputCell, String columnInputCell, Object[][] values)

Create two-variable data table for given range starting from this cell.

Parameters:

ParameterTypeDescription
rowNumberintNumber of rows to populate the formula.
columnNumberintNumber of columns to populate the formula.
rowInputCelljava.lang.Stringthe row input cell
columnInputCelljava.lang.Stringthe column input cell
valuesjava.lang.Object[][]values for cells in table formula range

setValue(Object value)

public void setValue(Object value)

Sets the value contained in this cell.

Remarks

Possible type:

null,

Boolean,

DateTime,

Double,

Integer

String.

For int value, it may be returned as an Integer object or a Double object. And there is no guarantee that the returned value will be kept as the same type of object always.

Parameters:

ParameterTypeDescription
valuejava.lang.Object

toJson()

public String toJson()

Convert Cell to JSON struct data.

Returns: java.lang.String -

toString()

public String toString()

Returns a string represents the current Cell object.

Returns: java.lang.String -

wait()

public final void wait()

wait(long arg0)

public final native void wait(long arg0)

Parameters:

ParameterTypeDescription
arg0long

wait(long arg0, int arg1)

public final void wait(long arg0, int arg1)

Parameters:

ParameterTypeDescription
arg0long
arg1int