Namespace EasyXLS

Class ExcelCell


  • public class ExcelCell
    extends System.Object
    This class stores the cell information like value, format (font name, font size, font bold, font italic, word wrap, font underline style, font subscript, font superscript, font strikethrough, background color, foreground color, horizontal alignment, vertical alignment, number or date format, cell locked or hidden, shrink, border type, border color) and comment.
    • Constructor Detail

      • ExcelCell

        public ExcelCell()
        Defines an instance of the Excel cell.
    • Method Detail

      • setStyle

        public void setStyle​(ExcelStyle xlsStyle)
        Sets the style of the cell.
        Parameters:
        xlsStyle - the style of the cell
        See Also:
        getStyle()
      • getXF

        public int getXF()
        Internal use only
        Returns:
        the xf index of the style
      • setXF

        public void setXF​(int xfIndex)
        Internal use only
        Parameters:
        xfIndex - the xf index of the style
      • getFormat

        public System.String getFormat()
        Returns the number/date format of the cell. Possible values are available in Format class.
        Returns:
        the number/date format of the cell
        See Also:
        setFormat(System.String)
      • setFormat

        public void setFormat​(System.String format)
        Sets the number/date format of the cell. Possible values are available in Format class.
        Parameters:
        format - the number/date format of the cell
        See Also:
        getFormat()
      • getHorizontalAlignment

        public System.String getHorizontalAlignment()
        Returns the horizontal alignment of the cell. Possible values are available in Alignment class.
        Returns:
        the horizontal alignment of the cell
        See Also:
        setHorizontalAlignment(System.String)
      • setHorizontalAlignment

        public void setHorizontalAlignment​(System.String horizontalAlignment)
        Sets the horizontal alignment of the cell. Possible values are available in Alignment class.
        Parameters:
        horizontalAlignment - the horizontal alignment of the cell
        See Also:
        getHorizontalAlignment()
      • getVerticalAlignment

        public System.String getVerticalAlignment()
        Returns the vertical alignment of the cell. Possible values are available in Alignment class.
        Returns:
        the vertical alignment of the cell
        See Also:
        setVerticalAlignment(System.String)
      • setVerticalAlignment

        public void setVerticalAlignment​(System.String verticalAlignment)
        Sets the vertical alignment of the cell. Possible values are available in Alignment class.
        Parameters:
        verticalAlignment - the vertical alignment of the cell
        See Also:
        getVerticalAlignment()
      • IsJustifyDistributed

        public bool IsJustifyDistributed()
        Returns the justify distributed setting of the cell. It can only be used for distributed alignment.
        Returns:
        the justify distributed setting of the cell
        See Also:
        setJustifyDistributed(bool)
      • setJustifyDistributed

        public void setJustifyDistributed​(bool isJustifyDistributed)
        Sets the justify distributed option of the cell. It can only be used for distributed alignment.
        Parameters:
        isJustifyDistributed - the justify distributed option of the cell
        See Also:
        IsJustifyDistributed()
      • getIndent

        public int getIndent()
        Returns the indent of the cell.
        Returns:
        the indent of the cell.
        See Also:
        setIndent(int)
      • setIndent

        public void setIndent​(int indent)
        Sets the indent of the cell.
        Parameters:
        indent - the indent of the cell.
        See Also:
        getIndent()
      • getTextRotation

        public int getTextRotation()
        Returns the text rotation of the cell.
        Returns:
        the text rotation of the cell
        See Also:
        setTextRotation(int)
      • setTextRotation

        public void setTextRotation​(int textRotation)
        Sets the text rotation of the cell.
        Parameters:
        textRotation - the text rotation of the cell
        See Also:
        getTextRotation()
      • IsWrap

        public bool IsWrap()
        Returns the wrap setting of the cell.
        Returns:
        the wrap setting of the cell
        See Also:
        setWrap(bool)
      • setWrap

        public void setWrap​(bool isWrap)
        Sets the wrap option of the cell.
        Parameters:
        isWrap - the wrap option of the cell
        See Also:
        IsWrap()
      • IsShrink

        public bool IsShrink()
        Returns the shrink setting of the cell.
        Returns:
        the shrink setting of the cell
        See Also:
        setShrink(bool)
      • setShrink

        public void setShrink​(bool isShrink)
        Sets the shrink option of the cell.
        Parameters:
        isShrink - the shrink option of the cell
        See Also:
        IsShrink()
      • IsMergeCell

        public bool IsMergeCell()
        Returns the merge cell option of the cell
        Returns:
        the merge cell option of the cell
      • getTextDirection

        public int getTextDirection()
        Returns the text direction of the cell.
        Returns:
        the text direction of the cell
        See Also:
        setTextDirection(int)
      • setTextDirection

        public void setTextDirection​(int textDirection)
        Sets the text direction of the cell.
        Parameters:
        textDirection - the text direction of the cell
        See Also:
        getTextDirection()
      • getFont

        public System.String getFont()
        Returns the name of the cell font.
        Returns:
        the name of the cell font
        See Also:
        setFont(System.String)
      • setFont

        public void setFont​(System.String fontName)
        Sets the name of the cell font.
        Parameters:
        fontName - the name of the cell font
        See Also:
        getFont()
      • IsHeadingsFont

        public bool IsHeadingsFont()
        Returns true if the font is the headings font, false otherwise.
        Returns:
        true if the font is the headings font, false otherwise.
        See Also:
        setHeadingsFont(), setFont(System.String)
      • IsBodyFont

        public bool IsBodyFont()
        Returns true if the font is the body font, false otherwise.
        Returns:
        true if the font is the body font, false otherwise.
        See Also:
        setBodyFont(), setFont(System.String)
      • getFontSize

        public int getFontSize()
        Returns the size of the cell font.
        Returns:
        the size of the cell font
        See Also:
        setFontSize(int)
      • setFontSize

        public void setFontSize​(int fontSize)
        Sets the size of the cell font.
        Parameters:
        fontSize - the size of the cell font
        See Also:
        getFontSize()
      • IsBold

        public bool IsBold()
        Returns the bold setting of the cell font.
        Returns:
        the bold setting of the cell font
        See Also:
        setBold(bool)
      • setBold

        public void setBold​(bool isBold)
        Sets the bold option of the cell font.
        Parameters:
        isBold - the bold option of the cell font
        See Also:
        IsBold()
      • IsItalic

        public bool IsItalic()
        Returns the italic setting of the cell font.
        Returns:
        the italic setting of the cell font
        See Also:
        setItalic(bool)
      • setItalic

        public void setItalic​(bool isItalic)
        Sets the italic option of the cell font.
        Parameters:
        isItalic - the italic option of the cell font
        See Also:
        IsItalic()
      • getUnderlineStyle

        public int getUnderlineStyle()
        Returns the underline style of the cell font. Possible values are available in FontSettings class.
        Returns:
        the underline style of the cell font
        See Also:
        setUnderlineStyle(int)
      • setUnderlineStyle

        public void setUnderlineStyle​(int underlineStyle)
        Sets the underline style of the cell font. Possible values are available in FontSettings class.
        Parameters:
        underlineStyle - underline style of the cell font
        See Also:
        getUnderlineStyle()
      • getForeground

        public System.Drawing.Color getForeground()
        Returns the foreground color of the cell.
        Returns:
        the foreground color of the cell
        See Also:
        setForeground(Color)
      • getForegroundThemeColor

        public ThemeColor getForegroundThemeColor()
        Returns the foreground color of the cell.
        Returns:
        the foreground color of the cell
        See Also:
        setForeground(ThemeColor)
      • setForeground

        public void setForeground​(System.Drawing.Color color)
        Sets the foreground color of the cell.
        Parameters:
        color - the foreground color of the cell
        See Also:
        getForeground()
      • setForeground

        public void setForeground​(ThemeColor themeColor)
        Sets the foreground color of the cell.
        Parameters:
        themeColor - the foreground color of the cell
        See Also:
        getForegroundThemeColor()
      • IsStrikethrough

        public bool IsStrikethrough()
        Returns the strikethrough setting of the cell font.
        Returns:
        the strikethrough setting of the cell font
        See Also:
        setStrikethrough(bool)
      • setStrikethrough

        public void setStrikethrough​(bool isStrikethrough)
        Sets the strikethrough option of the cell font.
        Parameters:
        isStrikethrough - the strikethrough option of the cell font
        See Also:
        IsStrikethrough()
      • IsSuperscript

        public bool IsSuperscript()
        Returns the superscript setting of the cell font.
        Returns:
        the superscript setting of the cell font
        See Also:
        setSuperscript(bool)
      • setSuperscript

        public void setSuperscript​(bool isSuperscript)
        Sets the superscript option of the cell font.
        Parameters:
        isSuperscript - the superscript option of the cell font
        See Also:
        IsSuperscript()
      • IsSubscript

        public bool IsSubscript()
        Returns the subscript setting of the cell font.
        Returns:
        the subscript setting of the cell font
        See Also:
        setSubscript(bool)
      • setSubscript

        public void setSubscript​(bool isSubscript)
        Sets the subscript option of the cell font.
        Parameters:
        isSubscript - the subscript option of the cell font
        See Also:
        IsSubscript()
      • getTopStyle_Border

        public int getTopStyle_Border()
        Returns the style of the top border. Possible values are available in Border class.
        Returns:
        the style of the top border
        See Also:
        setTopStyle_Border(int)
      • setTopStyle_Border

        public void setTopStyle_Border​(int borderStyle)
        Sets the style of the top border. Possible values are available in Border class.
        Parameters:
        borderStyle - the style of the top border
        See Also:
        getTopStyle_Border()
      • getBottomStyle_Border

        public int getBottomStyle_Border()
        Returns the style of the bottom border. Possible values are available in Border class.
        Returns:
        the style of the bottom border
        See Also:
        setBottomStyle_Border(int)
      • setBottomStyle_Border

        public void setBottomStyle_Border​(int borderStyle)
        Sets the style of the bottom border. Possible values are available in Border class.
        Parameters:
        borderStyle - the style of the bottom border
        See Also:
        getBottomStyle_Border()
      • getLeftStyle_Border

        public int getLeftStyle_Border()
        Returns the style of the left border. Possible values are available in Border class.
        Returns:
        the style of the left border
        See Also:
        setLeftStyle_Border(int)
      • setLeftStyle_Border

        public void setLeftStyle_Border​(int borderStyle)
        Sets the style of the left border. Possible values are available in Border class.
        Parameters:
        borderStyle - the style of the left border
        See Also:
        getLeftStyle_Border()
      • getRightStyle_Border

        public int getRightStyle_Border()
        Returns the style of the right border. Possible values are available in Border class.
        Returns:
        the style of the right border
        See Also:
        setRightStyle_Border(int)
      • setRightStyle_Border

        public void setRightStyle_Border​(int borderStyle)
        Sets the style of the right border. Possible values are available in Border class.
        Parameters:
        borderStyle - the style of the right border
        See Also:
        getRightStyle_Border()
      • setBorderColors

        public void setBorderColors​(System.Drawing.Color borderTop,
                                    System.Drawing.Color borderBottom,
                                    System.Drawing.Color borderLeft,
                                    System.Drawing.Color borderRight)
        Sets the border colors of the cell.
        Parameters:
        borderTop - the border color for the top side of the cell
        borderBottom - the border color for the bottom side of the cell
        borderLeft - the border color for the left side of the cell
        borderRight - the border color for the right side of the cell.
        See Also:
        getTopColor_Border(), getBottomColor_Border(), getLeftColor_Border(), getRightColor_Border(), setBorderStyles(int, int, int, int)
      • setTopColor_Border

        public void setTopColor_Border​(System.Drawing.Color color)
        Sets the color of the top border.
        Parameters:
        color - the color of the top border
        See Also:
        getTopColor_Border()
      • setTopColor_Border

        public void setTopColor_Border​(ThemeColor themeColor)
        Sets the color of the top border.
        Parameters:
        themeColor - the color of the top border
        See Also:
        getTopThemeColor_Border()
      • setBottomColor_Border

        public void setBottomColor_Border​(System.Drawing.Color color)
        Sets the color of the bottom border.
        Parameters:
        color - the color of the bottom border
        See Also:
        getBottomColor_Border()
      • setBottomColor_Border

        public void setBottomColor_Border​(ThemeColor themeColor)
        Sets the color of the bottom border.
        Parameters:
        themeColor - the color of the bottom border
        See Also:
        getBottomThemeColor_Border()
      • setLeftColor_Border

        public void setLeftColor_Border​(System.Drawing.Color color)
        Sets the color of the left border.
        Parameters:
        color - the color of the left border
        See Also:
        getLeftColor_Border()
      • setLeftColor_Border

        public void setLeftColor_Border​(ThemeColor themeColor)
        Sets the color of the left border.
        Parameters:
        themeColor - the color of the left border
        See Also:
        getLeftThemeColor_Border()
      • setRightColor_Border

        public void setRightColor_Border​(System.Drawing.Color color)
        Sets the color of the right border.
        Parameters:
        color - the color of the right border
        See Also:
        getRightColor_Border()
      • setRightColor_Border

        public void setRightColor_Border​(ThemeColor themeColor)
        Sets the color of the right border.
        Parameters:
        themeColor - the color of the right border
        See Also:
        getRightThemeColor_Border()
      • getDiagonalColor_Border

        public System.Drawing.Color getDiagonalColor_Border()
        Returns the color of the diagonal border.
        Returns:
        the color of the diagonal border
        See Also:
        setDiagonalBorder(bool,bool,int,Color)
      • getBackground

        public System.Drawing.Color getBackground()
        Returns the background color of the cell.
        Returns:
        the background color of the cell
        See Also:
        setBackground(Color)
      • getBackgroundThemeColor

        public ThemeColor getBackgroundThemeColor()
        Returns the background color of the cell.
        Returns:
        the background color of the cell
        See Also:
        setBackground(ThemeColor)
      • setBackground

        public void setBackground​(System.Drawing.Color color)
        Sets the background color of the cell.
        Parameters:
        color - the background color of the cell
        See Also:
        getBackground()
      • setBackground

        public void setBackground​(ThemeColor themeColor)
        Sets the background color of the cell.
        Parameters:
        themeColor - the background color of the cell
        See Also:
        getBackgroundThemeColor()
      • getPattern

        public int getPattern()
        Returns the pattern of the cell.
        Returns:
        the pattern of the cell
        See Also:
        setPattern(int)
      • setPattern

        public void setPattern​(int pattern)
        Sets the pattern of the cell.
        Parameters:
        pattern - the pattern of the cell
        See Also:
        getPattern()
      • getPatternColor

        public System.Drawing.Color getPatternColor()
        Returns the pattern color of the cell.
        Returns:
        the pattern color of the cell
        See Also:
        setPatternColor(System.Drawing.Color)
      • setPatternColor

        public void setPatternColor​(System.Drawing.Color color)
        Sets the pattern color of the cell.
        Parameters:
        color - the pattern color of the cell
        See Also:
        getPatternColor()
      • setPatternColor

        public void setPatternColor​(ThemeColor themeColor)
        Sets the pattern color of the cell.
        Parameters:
        themeColor - the pattern color of the cell
        See Also:
        getPatternThemeColor()
      • getGradientColor1

        public System.Drawing.Color getGradientColor1()
        Returns the first color of the gradient fill.
        Returns:
        the first color of the gradient fill
        See Also:
        setGradientFill(Color,Color,int)
      • getGradientColor2

        public System.Drawing.Color getGradientColor2()
        Returns the second color of the gradient fill.
        Returns:
        the second color of the gradient fill
        See Also:
        setGradientFill(Color,Color,int)
      • IsLocked

        public bool IsLocked()
        Returns the locked setting of the cell.
        Returns:
        the locked setting of the cell
        See Also:
        setLocked(bool)
      • setLocked

        public void setLocked​(bool isLocked)
        Sets the locked option of the cell.
        Parameters:
        isLocked - the locked option of the cell
        See Also:
        IsLocked()
      • IsHiddenFormula

        public bool IsHiddenFormula()
        Returns the hidden setting of the cell.
        Returns:
        the hidden setting of the cell
        See Also:
        setHiddenFormula(bool)
      • setHiddenFormula

        public void setHiddenFormula​(bool isHidden)
        Sets the hidden option of the cell.
        Parameters:
        isHidden - the hidden option of the cell
        See Also:
        IsHiddenFormula()
      • getValue

        public System.String getValue()
        Returns the value of the cell.
        Returns:
        the value of the cell
        See Also:
        setValue(System.String)
      • setValue

        public void setValue​(System.String value)
        Sets the value of the cell.
        Parameters:
        value - the value of the cell
        See Also:
        getValue()
      • getHTMLValue

        public System.String getHTMLValue()
        Returns the value of the cell containing the tags used to set the rich text format in cells. The following tags are supported: <b>, <strong>, <i>, <u>, <underline single>, <underline double>, <underline single-accounting>, <underline double-accounting>, <s>, <strike>, <sup>, <sub>, <font color= face= size=>
        Returns:
        the value of the cell containing the tags used to set the rich text format in cells.
        See Also:
        setHTMLValue(System.String)
      • setHTMLValue

        public void setHTMLValue​(System.String value)
        Sets the value of the cell using html tags.The html tags are used to set the rich text format in cells. The following tags are supported: <b>, <strong>, <i>, <u>, <underline single>, <underline double>, <underline single-accounting>, <underline double-accounting>, <s>, <strike>, <sup>, <sub>, <font color= face= size=>
        Parameters:
        value - the value of the cell
        See Also:
        getHTMLValue()
      • IsHTMLUsed

        public bool IsHTMLUsed()
        Returns true if the cell contains rich text format.
        Returns:
        true if the cell contains rich text format.
        See Also:
        setHTMLValue(System.String)
      • IsArrayFormula

        public bool IsArrayFormula()
        Returns whether or not the cell formula has been entered as an array formula
        Returns:
        true if the cell formula is a part of an array formula
      • resetFormulaResult

        public void resetFormulaResult()
        Internal use only
      • getFormulaResult

        public EasyXLS.Formulas.Util.FunctionDataObject getFormulaResult()
        Internal use only. Returns the formula result if the cell contains a formula and the formula has been computed
        Returns:
        a FunctionDataObject instance representing the formula result;
        the result will be an instance of ErrorObject having the value of "N/A" if the cell does not contain a formula or if the formula has not been computed yet.
        See Also:
        setValue(System.String)
      • getFormulaResultValue

        public System.String getFormulaResultValue()
        Returns the formula result if the cell contains a formula and the formula has been computed
        Returns:
        a String representing the formula result;
        the result will be the "N/A" string if the cell does not contain a formula or if the formula hasn't been computed yet.
      • containsFormula

        public bool containsFormula()
        Returns whether or not the cell contains a formula as value (its value starts with "=" (equal sign))
        Returns:
        true if the cell value is starting with the equal sign ("=")
      • calculateFormula

        public EasyXLS.Formulas.Util.FunctionDataObject calculateFormula​(ExcelDocument excel,
                                                                         ExcelWorksheet cellWorksheet,
                                                                         ExcelWorksheet formulaWorksheet,
                                                                         int nCellRow,
                                                                         int nCellColumn,
                                                                         int nFormulaRow,
                                                                         int nFormulaColumn,
                                                                         bool bRecalculate)
        Calculates the cell formula if the cell value is a formula
        Parameters:
        excel - - the ExcelDocument that this ExcelCell belongs to
        cellWorksheet - - the ExcelWorksheet that this ExcelCell belongs to
        formulaWorksheet - - the ExcelWorksheet that the formula belongs to
        nCellRow - - the row number of this ExcelCell
        nCellColumn - - the column number of this ExcelCell
        nFormulaRow - - the row number of the cell that the formula belongs to
        nFormulaColumn - - the column number of the cell that the formula belongs to
        bRecalculate - - a flag indicating if the cell formula should be recalculated. If the cell formula has never been calculated before, the formula will be processed even if the flag is false.
        Returns:
        a FunctionDataObject instance representing the formula result (it can be a number, bool, string or error value) During the formula calculation the cellWorksheet and formulaWorksheet can be different if the cell formula contains table references from other worksheets
      • getFormattedValue

        public System.String getFormattedValue()
        Returns the value of the cell according to the cell format applied. The formulas must be computed in order to display the results.
        Returns:
        the formatted value of the cell;
        the result will be the "#N/A" string if the cell formula hasn't been computed yet.
      • getDataType

        public System.String getDataType()
        Returns the data type of the cell. The default value is DataType.AUTOMATIC. Automatic data type can be resource and time consuming and we recommend using a defined one. Possible values are available in DataType class.
        Returns:
        the data type of the cell
        See Also:
        setDataType(System.String)
      • setDataType

        public void setDataType​(System.String dataType)
        Sets the data type of the cell. The default value is DataType.AUTOMATIC. Automatic data type can be resource and time consuming and we recommend using a defined one. Possible values are available in DataType class.
        Parameters:
        dataType - the data type of the cell
        See Also:
        getDataType()
      • setComment

        public void setComment​(System.String text,
                               System.String fontName,
                               int fontSize,
                               bool isBold,
                               bool isItalic,
                               System.Drawing.Color foreground)
        Sets the comment of the cell having the specified text and font settings.
        Parameters:
        text - the text of the comment
        fontName - the font name of the comment text
        fontSize - the font size of the comment text
        isBold - the bold option of the comment text
        isItalic - the italic option of the comment text
        foreground - the foreground of the comment text
        See Also:
        setComment(ExcelComment), setComment(String), setComment(String,int,int), getComment()
      • Clone

        public ExcelCell Clone()
        Creates and returns a copy of this object.
        Returns:
        a clone of this instance.