com.aspose.cells

  • java.lang.Object
    • com.aspose.cells.Cell
public class Cell 
extends java.lang.Object

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);

Property Getters/Setters Summary
booleangetBoolValue()
Gets the boolean value contained in the cell.
intgetColumn()
Gets column number (zero based) of the cell.
booleancontainsExternalLink()
Indicates whether this cell contains an external link. Only applies when the cell is a formula cell.
com.aspose.cells.DateTimegetDateTimeValue()
Gets the DateTime value contained in the cell.
java.lang.StringgetDisplayStringValue()
Gets the formatted string value of this cell.
doublegetDoubleValue()
Gets the double value contained in the cell.
floatgetFloatValue()
Gets the float value contained in the cell.
java.lang.StringgetFormula()
void
setFormula(java.lang.Stringvalue)
           Gets or sets a formula of the Cell.
java.lang.StringgetFormulaLocal()
void
setFormulaLocal(java.lang.Stringvalue)
           Get the locale formatted formula of the cell.
java.lang.StringgetHtmlString()
void
setHtmlString(java.lang.Stringvalue)
           Gets and sets the html string which contains data and some formats in this cell.
intgetIntValue()
Gets the integer value contained in the cell.
booleanisArrayFormula()
Indicates whether the cell formula is an array formula.
booleanisArrayHeader()
Inidicates the cell's formula is and array formula and it is the first cell of the array.
booleanisErrorValue()
Checks if a formula can properly evaluate a result.
booleanisFormula()
Represents if the specified cell contains formula.
booleanisInArray()
Indicates whether the cell formula is an array formula.
booleanisInTable()
Indicates whether this cell is part of table formula.
booleanisMerged()
Checks if a cell is part of a merged range or not.
booleanisSharedFormula()
Indicates whether the cell formula is part of shared formula.
booleanisStyleSet()
Indicates if the cell's style is set. If return false, it means this cell has a default cell format.
booleanisTableFormula()
Indicates whether this cell is part of table formula.
java.lang.StringgetName()
Gets the name of the cell.
intgetNumberCategoryType()
Represents the category type of this cell's number formatting. The value of the property is NumberCategoryType integer constant.
java.lang.StringgetR1C1Formula()
void
setR1C1Formula(java.lang.Stringvalue)
           Gets or sets a R1C1 formula of the Cell.
intgetRow()
Gets row number (zero based) of the cell.
intgetSharedStyleIndex()
Gets cell's shared style index in the style pool.
java.lang.StringgetStringValue()
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).
java.lang.StringgetStringValueWithoutFormat()
Gets cell's value as string without any format.
intgetType()
Represents cell value type. The value of the property is CellValueType integer constant.
java.lang.ObjectgetValue()
void
setValue(java.lang.Objectvalue)
           Gets the value contained in this cell.
WorksheetgetWorksheet()
Gets the parent worksheet.
 
Method Summary
voidcalculate(boolean ignoreError, ICustomFunction customFunction)
Calcaulate the formula of the cell.
voidcalculate(CalculationOptions options)
Calcaulate the formula of the cell.
FontSettingcharacters(int startIndex, int length)
Returns a Characters object that represents a range of characters within the cell text.
voidcopy(Cell cell)
Copies data from a source cell.
booleanequals(Cell cell)
Checks whether this object refers to the same cell with another cell object.
booleanequals(java.lang.Object obj)
Checks whether this object refers to the same cell with another.
CellAreagetArrayRange()
Gets the array range if the cell's formula is an array formula.
com.aspose.cells.FontSetting[]getCharacters()
Returns all Characters objects that represents a range of characters within the cell text.
com.aspose.cells.FontSetting[]getCharacters(boolean flag)
Returns all Characters objects that represents a range of characters within the cell text.
ConditionalFormattingResultgetConditionalFormattingResult()
Get the result of the conditional formatting.
com.aspose.cells.Cell[]getDependents(boolean isAll)
Get all cells which refer to the specific cell.
StylegetDisplayStyle()
Gets the display style of the cell. If the cell is conditional formatted, the display style is not same as the cell.GetStyle().
StylegetDisplayStyle(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().
com.aspose.cells.FormatConditionCollection[]getFormatConditions()
Gets format conditions which applies to this cell.
java.lang.StringgetFormula(boolean isR1C1, boolean isLocal)
Get the formula of this cell.
intgetHeightOfValue()
Gets the height of the value in unit of pixels.
java.lang.StringgetHtmlString(boolean html5)
Gets the html string which contains data and some formats in this cell.
java.util.IteratorgetLeafs()
Get all cells which will be updated when this cell is modified. This method can only work after calling Workbook.CalculateFormula.
RangegetMergedRange()
Returns a Range object which represents a merged range.
ReferredAreaCollectiongetPrecedents()
Gets all cells or ranges which this cell's formula depends on.
java.lang.StringgetStringValue(int formatStrategy)
Gets the string value by specific formatted strategy.
StylegetStyle()
Gets the cell style.
StylegetStyle(boolean checkBorders)
If checkBorders is true, check whether other cells' borders will effect the style of this cell.
ListObjectgetTable()
Gets the table which contains this cell.
ValidationgetValidation()
Gets the validation applied to this cell.
booleangetValidationValue()
Gets the value of validation which applied to this cell.
intgetWidthOfValue()
Gets the width of the value in unit of pixels.
inthashCode()
Serves as a hash function for a particular type.
booleanisRichText()
Indicates whether the cell string value is a rich text.
voidputValue(boolean boolValue)
Puts an boolean value into the cell.
voidputValue(com.aspose.cells.DateTime dateTime)
Puts a DateTime value into the cell.
voidputValue(double doubleValue)
Puts a double value into the cell.
voidputValue(int intValue)
Puts an integer value into the cell.
voidputValue(java.lang.Object objectValue)
Puts an object value into the cell.
voidputValue(java.lang.String stringValue)
Puts a string value into the cell.
voidputValue(java.lang.String stringValue, boolean isConverted)
Puts a string value into the cell and converts the value to other data type if appropriate.
voidputValue(java.lang.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.
voidremoveArrayFormula(boolean leaveNormalFormula)
Remove array formula.
voidsetAddInFormula(java.lang.String addInFileName, java.lang.String addInFunction)
Sets an Add-In formula to the cell.
voidsetArrayFormula(java.lang.String arrayFormula, int rowNumber, int columnNumber)
Sets an array formula to a range of cells.
voidsetArrayFormula(java.lang.String arrayFormula, int rowNumber, int columnNumber, boolean isR1C1, boolean isLocal)
Sets an array formula to a range of cells.
voidsetArrayFormula(java.lang.String arrayFormula, int rowNumber, int columnNumber, FormulaParseOptions options)
Sets an array formula to a range of cells.
voidsetCharacters(com.aspose.cells.FontSetting[] characters)
Sets rich text format of the cell.
voidsetFormula(java.lang.String formula, boolean isR1C1, boolean isLocal, java.lang.Object value)
Set the formula and the value of the formula.
voidsetFormula(java.lang.String formula, FormulaParseOptions options, java.lang.Object value)
Set the formula and the value of the formula.
voidsetFormula(java.lang.String formula, java.lang.Object value)
Set the formula and the value of the formula.
voidsetSharedFormula(java.lang.String sharedFormula, int rowNumber, int columnNumber)
Sets a formula to a range of cells.
voidsetSharedFormula(java.lang.String sharedFormula, int rowNumber, int columnNumber, boolean isR1C1, boolean isLocal)
Sets a formula to a range of cells.
voidsetSharedFormula(java.lang.String sharedFormula, int rowNumber, int columnNumber, FormulaParseOptions options)
Sets a formula to a range of cells.
voidsetStyle(Style style)
Sets the cell style.
voidsetStyle(Style style, boolean explicitFlag)
Apply the cell style.
voidsetStyle(Style style, StyleFlag flag)
Apply the cell style.
java.lang.StringtoString()
Returns a string represents the current Cell object.
 

    • Property Getters/Setters Detail

      • getWorksheet

        public Worksheet getWorksheet()
        
        Gets the parent worksheet.
      • getDateTimeValue

        public com.aspose.cells.DateTime getDateTimeValue()
        
        Gets the DateTime value contained in the cell.
      • getRow

        public int getRow()
        
        Gets row number (zero based) of the cell. Cell row number
      • getColumn

        public int getColumn()
        
        Gets column number (zero based) of the cell.
      • isFormula

        public boolean isFormula()
        
        Represents if the specified cell contains formula.
      • getType

        public int getType()
        
        Represents cell value type. The value of the property is CellValueType integer constant.
      • getName

        public java.lang.String getName()
        
        Gets the name of the cell. 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.
      • isErrorValue

        public boolean isErrorValue()
        
        Checks if a formula can properly evaluate a result. Only applies to formula cell.
      • getStringValue

        public java.lang.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).
      • getStringValueWithoutFormat

        public java.lang.String getStringValueWithoutFormat()
        
        Gets cell's value as string without any format.
      • getNumberCategoryType

        public int getNumberCategoryType()
        
        Represents the category type of this cell's number formatting. The value of the property is NumberCategoryType integer constant.
      • getDisplayStringValue

        public java.lang.String getDisplayStringValue()
        
        Gets the formatted string value of this cell.
      • getIntValue

        public int getIntValue()
        
        Gets the integer value contained in the cell.
      • getDoubleValue

        public double getDoubleValue()
        
        Gets the double value contained in the cell.
      • getFloatValue

        public float getFloatValue()
        
        Gets the float value contained in the cell.
      • getBoolValue

        public boolean getBoolValue()
        
        Gets the boolean value contained in the cell.
      • getSharedStyleIndex

        public int getSharedStyleIndex()
        
        Gets cell's shared style index in the style pool.
      • getFormula/setFormula

        public java.lang.String getFormula() / public void setFormula(java.lang.String value)
        
        Gets or sets a formula of the Cell. A formula string always begins with an equal sign (=). And please always use comma(,) as parameters delimeter, such as "=SUM(A1, E1, H2)".

        User can set any formula in Workbook designer file. Aspose.Cells will keep all the formulas. If user use this property to set a formula to a cell, major part of Workbook built-in functions is supported. And more is coming. If you have any special need for Workbook built-in functions, please let us know.

        Example:

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

        public java.lang.String getFormulaLocal() / public void setFormulaLocal(java.lang.String value)
        
        Get the locale formatted formula of the cell.
      • getR1C1Formula/setR1C1Formula

        public java.lang.String getR1C1Formula() / public void setR1C1Formula(java.lang.String value)
        
        Gets or sets a R1C1 formula of the Cell.
      • containsExternalLink

        public boolean containsExternalLink()
        
        Indicates whether this cell contains an external link. Only applies when the cell is a formula cell.
      • isArrayHeader

        public boolean isArrayHeader()
        
        Inidicates the cell's formula is and array formula and it is the first cell of the array.
      • isArrayFormula

        public boolean isArrayFormula()
        
        Indicates whether the cell formula is an array formula.
      • isInArray

        public boolean isInArray()
        
        Indicates whether the cell formula is an array formula. 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.
      • isSharedFormula

        public boolean isSharedFormula()
        
        Indicates whether the cell formula is part of shared formula.
      • isTableFormula

        public boolean isTableFormula()
        
        Indicates whether this cell is part of table formula.
      • isInTable

        public boolean isInTable()
        
        Indicates whether this cell is part of table formula. 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.
      • getValue/setValue

        public java.lang.Object getValue() / public void setValue(java.lang.Object value)
        
        Gets the value contained in this cell. 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 object type always.
      • isStyleSet

        public boolean isStyleSet()
        
        Indicates if the cell's style is set. If return false, it means this cell has a default cell format.
      • isMerged

        public boolean isMerged()
        
        Checks if a cell is part of a merged range or not.
      • getHtmlString/setHtmlString

        public java.lang.String getHtmlString() / public void setHtmlString(java.lang.String value)
        
        Gets and sets the html string which contains data and some formats in this cell.

    setFormula

    public voidsetFormula(java.lang.Stringvalue)
    
    Gets or sets a formula of the Cell. A formula string always begins with an equal sign (=). And please always use comma(,) as parameters delimeter, such as "=SUM(A1, E1, H2)".

    User can set any formula in Workbook designer file. Aspose.Cells will keep all the formulas. If user use this property to set a formula to a cell, major part of Workbook built-in functions is supported. And more is coming. If you have any special need for Workbook built-in functions, please let us know.

    Example:

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

    setFormulaLocal

    public voidsetFormulaLocal(java.lang.Stringvalue)
    
    Get the locale formatted formula of the cell.

    setR1C1Formula

    public voidsetR1C1Formula(java.lang.Stringvalue)
    
    Gets or sets a R1C1 formula of the Cell.

    setValue

    public voidsetValue(java.lang.Objectvalue)
    
    Gets the value contained in this cell. 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 object type always.

    setHtmlString

    public voidsetHtmlString(java.lang.Stringvalue)
    
    Gets and sets the html string which contains data and some formats in this cell.
    • Method Detail

      • 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.
      • setSharedFormula

        public void setSharedFormula(java.lang.String sharedFormula, int rowNumber, int columnNumber)
        Sets a formula to a range of cells.
        Parameters:
        sharedFormula - Shared formula.
        rowNumber - Number of rows to populate the formula.
        columnNumber - Number of columns to populate the formula.
      • removeArrayFormula

        public void removeArrayFormula(boolean leaveNormalFormula)
        Remove array formula.
        Parameters:
        leaveNormalFormula - True represents converting the array formula to normal formula.
      • setAddInFormula

        public void setAddInFormula(java.lang.String addInFileName, java.lang.String addInFunction)
        Sets an Add-In formula to the cell. Add-In file should be placed in the directory or sub-directory of Workbook Add-In library. For example, file name can be "Eurotool.xla" or "solver\solver.xla". NOTE: This class is now obsolete. Instead, please use Cell.Formula/Cell.SetFormula() to set cell formula with the Add-In functions after registering it by WorksheetCollection.RegisterAddInFunction(). This property will be removed 12 months later since January 2019. Aspose apologizes for any inconvenience you may have experienced.
        Parameters:
        addInFileName - Add-In file name.
        addInFunction - Add-In function name.

        Example:

        cells.get("h11").setAddInFormula("HRVSTTRK.xla", "=pct_overcut(F3:G3)");
        cells.get("h12").setAddInFormula("HRVSTTRK.xla", "=pct_overcut()");
      • copy

        public void copy(Cell cell)
        Copies data from a source cell.
        Parameters:
        cell - Source Cell object.
      • characters

        public FontSetting characters(int startIndex, int length)
        Returns a Characters object that represents a range of characters within the cell text. This method only works on cell with string value.
        Parameters:
        startIndex - The index of the start of the character.
        length - The number of characters.
        Returns:
        Characters object.

        Example:

        excel.getWorksheets().get(0).getCells().get("A1").putValue("Helloworld");
        excel.getWorksheets().get(0).getCells().get("A1").characters(5, 5).getFont().setBold(true);
        excel.getWorksheets().get(0).getCells().get("A1").characters(5, 5).getFont().setColor(Color.getBlue());
      • isRichText

        public boolean isRichText()
        Indicates whether the cell string value is a rich text.
      • getCharacters

        public com.aspose.cells.FontSetting[] getCharacters()
        Returns all Characters objects that represents a range of characters within the cell text.
        Returns:
        All Characters objects
      • getCharacters

        public com.aspose.cells.FontSetting[] getCharacters(boolean flag)
        Returns all Characters objects that represents a range of characters within the cell text.
        Parameters:
        flag - Indicates whether applying table style to the cell if the cell is in the table.
        Returns:
        All Characters objects
      • setCharacters

        public void setCharacters(com.aspose.cells.FontSetting[] characters)
        Sets rich text format of the cell.
        Parameters:
        characters - All Characters objects.
      • getMergedRange

        public Range getMergedRange()
        Returns a Range object which represents a merged range.
        Returns:
        Range object. Null if this cell is not merged.
      • getHtmlString

        public java.lang.String getHtmlString(boolean html5)
                            throws java.lang.Exception
        Gets the html string which contains data and some formats in this cell.
        Parameters:
        html5 - Indicates whether the value is compatible for html5
        Returns:
      • toString

        public java.lang.String toString()
        Returns a string represents the current Cell object.
        Returns:
      • equals

        public boolean equals(java.lang.Object obj)
        Checks whether this object refers to the same cell with another.
        Parameters:
        obj - another object
        Returns:
        true if two objects refers to the same cell.
      • hashCode

        public int hashCode()
        Serves as a hash function for a particular type.
        Returns:
        A hash code for current Cell object.
      • equals

        public boolean equals(Cell cell)
        Checks whether this object refers to the same cell with another cell object.
        Parameters:
        cell - another cell object
        Returns:
        true if two cell objects refers to the same cell.
      • getConditionalFormattingResult

        public ConditionalFormattingResult getConditionalFormattingResult()
        Get the result of the conditional formatting. Returns null if no conditional formatting is applied to this cell,
      • getValidation

        public Validation getValidation()
        Gets the validation applied to this cell.
        Returns:
      • getValidationValue

        public boolean getValidationValue()
        Gets the value of validation which applied to this cell.
        Returns:
      • getTable

        public ListObject getTable()
        Gets the table which contains this cell.
        Returns:
      • calculate

        public void calculate(CalculationOptions options)
        Calcaulate the formula of the cell.
        Parameters:
        options - Options for calculation
      • calculate

        public void calculate(boolean ignoreError, ICustomFunction customFunction)
        Calcaulate the formula of the cell.
        Parameters:
        ignoreError - Indicates if hide the error in calculating formulas. The error may be unsupported function, external links, etc.
        customFunction - The custom formula calculation functions to extend the calculation engine.
      • putValue

        public void putValue(boolean boolValue)
        Puts an boolean value into the cell.
        Parameters:
        boolValue -
      • putValue

        public void putValue(int intValue)
        Puts an integer value into the cell.
        Parameters:
        intValue - Input value
      • putValue

        public void putValue(double doubleValue)
        Puts a double value into the cell.
        Parameters:
        doubleValue - Input value
      • putValue

        public void putValue(java.lang.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:
        stringValue - Input value
        isConverted - True: converted to other data type if appropriate.
        setStyle - True: set the number format to cell's style when converting to other data type
      • putValue

        public void putValue(java.lang.String stringValue, boolean isConverted)
        Puts a string value into the cell and converts the value to other data type if appropriate.
        Parameters:
        stringValue - Input value
        isConverted - True: converted to other data type if appropriate.
      • putValue

        public void putValue(java.lang.String stringValue)
        Puts a string value into the cell.
        Parameters:
        stringValue - Input value
      • putValue

        public void putValue(com.aspose.cells.DateTime dateTime)
        Puts a DateTime value into the cell.
        Parameters:
        dateTime - Input value
      • putValue

        public void putValue(java.lang.Object objectValue)
        Puts an object value into the cell.
        Parameters:
        objectValue - input value
      • getStringValue

        public java.lang.String getStringValue(int formatStrategy)
        Gets the string value by specific formatted strategy.
        Parameters:
        formatStrategy - A CellValueFormatStrategy value. The formatted strategy.
        Returns:
      • getWidthOfValue

        public int getWidthOfValue()
                           throws java.lang.Exception
        Gets the width of the value in unit of pixels.
        Returns:
      • getHeightOfValue

        public int getHeightOfValue()
                            throws java.lang.Exception
        Gets the height of the value in unit of pixels.
        Returns:
      • getDisplayStyle

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

        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:
        includeMergedBorders - Indicates whether checking borders of the merged cells.
      • getFormatConditions

        public com.aspose.cells.FormatConditionCollection[] getFormatConditions()
        Gets format conditions which applies to this cell.
        Returns:
        Returns FormatConditionCollection object
      • getStyle

        public Style getStyle()
        Gets the cell style. To change the style of the cell, please call Cell.SetStyle() method after changing the style.
        Returns:
        Style object.
      • getStyle

        public Style getStyle(boolean checkBorders)
        If checkBorders is true, check whether other cells' borders will effect the style of this cell.
        Parameters:
        checkBorders - Check other cells' borders
        Returns:
        Style object.
      • setStyle

        public void setStyle(Style style)
        Sets the cell style. If the border settings are changed, the border of adjact cells will be updated too.
        Parameters:
        style - The cell style.
      • setStyle

        public void setStyle(Style style, boolean explicitFlag)
        Apply the cell style.
        Parameters:
        style - The cell style.
        explicitFlag - True, only overwriting formatting which is explicitly set.
      • setStyle

        public void setStyle(Style style, StyleFlag flag)
        Apply the cell style.
        Parameters:
        style - The cell style.
        flag - The style flag.
      • setFormula

        public void setFormula(java.lang.String formula, java.lang.Object value)
        Set the formula and the value of the formula.
        Parameters:
        formula - The formula.
        value - The value of the formula.
      • getFormula

        public java.lang.String getFormula(boolean isR1C1, boolean isLocal)
        Get the formula of this cell.
        Parameters:
        isR1C1 - Whether the formula needs to be formatted as R1C1.
        isLocal - Whether the formula needs to be formatted by locale.
        Returns:
        the formula of this cell.
      • setFormula

        public void setFormula(java.lang.String formula, boolean isR1C1, boolean isLocal, java.lang.Object value)
        Set the formula and the value of the formula. 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:
        formula - The formula.
        isR1C1 - Whether the formula is R1C1 formula.
        isLocal - Whether the formula is locale formatted.
        value - The value of the formula.
      • setFormula

        public void setFormula(java.lang.String formula, FormulaParseOptions options, java.lang.Object value)
        Set the formula and the value of the formula.
        Parameters:
        formula - The formula.
        options - Options for parsing the formula.
        value - The value of the formula.
      • setArrayFormula

        public void setArrayFormula(java.lang.String arrayFormula, int rowNumber, int columnNumber, boolean isR1C1, boolean isLocal)
        Sets an array formula to a range of cells. 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:
        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.
        isR1C1 - whether the formula is R1C1 formula
        isLocal - whether the formula is locale formatted
      • setArrayFormula

        public void setArrayFormula(java.lang.String arrayFormula, int rowNumber, int columnNumber, FormulaParseOptions options)
        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.
        options - Options for parsing the formula.
      • setSharedFormula

        public void setSharedFormula(java.lang.String sharedFormula, int rowNumber, int columnNumber, boolean isR1C1, boolean isLocal)
        Sets a formula to a range of cells. 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:
        sharedFormula - Shared formula.
        rowNumber - Number of rows to populate the formula.
        columnNumber - Number of columns to populate the formula.
        isR1C1 - whether the formula is R1C1 formula
        isLocal - whether the formula is locale formatted
      • setSharedFormula

        public void setSharedFormula(java.lang.String sharedFormula, int rowNumber, int columnNumber, FormulaParseOptions options)
        Sets a formula to a range of cells.
        Parameters:
        sharedFormula - Shared formula.
        rowNumber - Number of rows to populate the formula.
        columnNumber - Number of columns to populate the formula.
        options - Options for parsing the formula.
      • getPrecedents

        public ReferredAreaCollection getPrecedents()
        Gets all cells or ranges which this cell's formula depends on. Returns null if this is not a formula cell.
        Returns:
        Returns all cells or ranges.

        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());
            }
         workbook.save("C:\\Book2.xls");
      • getDependents

        public com.aspose.cells.Cell[] getDependents(boolean isAll)
        Get all cells which refer to the specific cell.
        Parameters:
        isAll - Indicates whether check other worksheets
      • getLeafs

        public java.util.Iterator getLeafs()
        Get all cells which will be updated when this cell is modified. This method can only work after calling Workbook.CalculateFormula.
      • getArrayRange

        public CellArea getArrayRange()
        Gets the array range if the cell's formula is an array formula. Only applies when the cell's formula is an array formula
        Returns:
        The array range.