Format class reference

  • Font* font() const
    Returns the pointer to the current font. Returns NULL if error occurs. Get an error info with the Book::errorMessage().
  • bool setFont(Font* font)
    Sets the font for the format. To create a new font use Book::addFont(). Returns false if error occurs. Get an error info with the Book::errorMessage().
  • int numFormat() const
    Returns the number format identifier.
  • void setNumFormat(int numFormat)
    Sets the number format identifier. The identifier must be a valid built-in number format identifier or the identifier of a custom number format. To create a custom format use Book::addCustomNumFormat(). See built-in values in the following table:
    ConstantDescriptionExample
    NUMFORMAT_GENERALgeneral format
    NUMFORMAT_NUMBERgeneral number1000
    NUMFORMAT_NUMBER_D2number with decimal point1000.00
    NUMFORMAT_NUMBER_SEPnumber with thousands separator100,000
    NUMFORMAT_NUMBER_SEP_D2number with decimal point and thousands separator100,000.00
    NUMFORMAT_CURRENCY_NEGBRAmonetary value, negative in brackets(1000$)
    NUMFORMAT_CURRENCY_NEGBRAREDmonetary value, negative is red in brackets(1000$)
    NUMFORMAT_CURRENCY_D2_NEGBRAmonetary value with decimal point, negative in brackets($1000.00)
    NUMFORMAT_CURRENCY_D2_NEGBRAREDmonetary value with decimal point, negative is red in brackets($1000.00)
    NUMFORMAT_PERCENTpercent value, multiply the cell value by 10075%
    NUMFORMAT_PERCENT_D2percent value with decimal point, multiply the cell value by 10075.00%
    NUMFORMAT_SCIENTIFIC_D2scientific value with E character and decimal point10.00E+1
    NUMFORMAT_FRACTION_ONEDIGfraction value, one digit10 1/2
    NUMFORMAT_FRACTION_TWODIGfraction value, two digits10 23/95
    NUMFORMAT_DATEdate value, depends on OS settings3/11/2009
    NUMFORMAT_CUSTOM_D_MON_YYcustom date value11-Mar-09
    NUMFORMAT_CUSTOM_D_MONcustom date value11-Mar
    NUMFORMAT_CUSTOM_MON_YYcustom date valueMar-09
    NUMFORMAT_CUSTOM_HMM_AMcustom date value8:30 AM
    NUMFORMAT_CUSTOM_HMMSS_AMcustom date value8:30:00 AM
    NUMFORMAT_CUSTOM_HMMcustom date value8:30
    NUMFORMAT_CUSTOM_HMMSScustom date value8:30:00
    NUMFORMAT_CUSTOM_MDYYYY_HMMcustom datetime value3/11/2009 8:30
    NUMFORMAT_NUMBER_SEP_NEGBRAnumber with thousands separator, negative in brackets(4,000)
    NUMFORMAT_NUMBER_SEP_NEGBRAREDnumber with thousands separator, negative is red in brackets(4,000)
    NUMFORMAT_NUMBER_D2_SEP_NEGBRAnumber with thousands separator and decimal point, negative in brackets(4,000.00)
    NUMFORMAT_NUMBER_D2_SEP_NEGBRAREDnumber with thousands separator and decimal point, negative is red in brackets(4,000.00)
    NUMFORMAT_ACCOUNTaccount value5,000
    NUMFORMAT_ACCOUNTCURaccount value with currency symbol
    $5,000
    NUMFORMAT_ACCOUNT_D2account value with decimal point5,000.00
    NUMFORMAT_ACCOUNT_D2_CURaccount value with currency symbol and decimal point
    $5,000.00
    NUMFORMAT_CUSTOM_MMSScustom time value30:55
    NUMFORMAT_CUSTOM_H0MMSScustom time value20:30:55
    NUMFORMAT_CUSTOM_MMSS0custom time value30:55.0
    NUMFORMAT_CUSTOM_000P0E_PLUS0custom value15.2E+3
    NUMFORMAT_TEXTtext valueany text
  • AlignH alignH() const
    Returns the horizontal alignment.
  • void setAlignH(AlignH align)
    Sets the horizontal alignment.
    AlignH valueView
    ALIGNH_GENERALALIGNH_GENERAL
    ALIGNH_LEFTALIGNH_LEFT
    ALIGNH_CENTERALIGNH_CENTER
    ALIGNH_RIGHTALIGNH_RIGHT
    ALIGNH_FILLALIGNH_FILL
    ALIGNH_JUSTIFYALIGNH_JUSTIFY
    ALIGNH_MERGEALIGNH_MERGE
    ALIGNH_DISTRIBUTEDALIGNH_DISTRIBUTED
  • AlignV alignV() const
    Returns the vertical alignment.
  • void setAlignV(AlignV align)
    Sets the vertical alignment.
    AlignV valueView
    ALIGNV_TOPALIGNV_TOP
    ALIGNV_CENTERALIGNV_CENTER
    ALIGNV_BOTTOMALIGNV_BOTTOM
    ALIGNV_JUSTIFYALIGNV_JUSTIFY
    ALIGNV_DISTRIBUTEDALIGNV_DISTRIBUTED
  • bool wrap() const
    Returns whether the cell text is wrapped.
  • void setWrap(bool wrap = true)
    Sets the flag whether the cell text is wrapped.
  • int rotation() const
    Returns the text rotation.
  • bool setRotation(int rotation)
    Sets the text rotation. Must be a value from the following table:
    ValueMeaning
    0 - 90Text rotated counterclockwise 0 to 90 degrees
    91 - 180Text rotated clockwise 1 to 90 degrees
    255Vertical text
  • int indent() const
    Returns the text indentation level.
  • void setIndent(int indent)
    Sets the text indentation level. Must be less than or equal to 15.
  • bool shrinkToFit() const
    Returns whether the cell is shrink-to-fit.
  • void setShrinkToFit(bool shrinkToFit = true)
    Sets the flag whether the cell is shrink-to-fit.
  • void setBorder(BorderStyle style = BORDERSTYLE_THIN)
    Sets the border style.
    BorderStyle valueView
    BORDERSTYLE_NONEBORDERSTYLE_NONE
    BORDERSTYLE_THINBORDERSTYLE_THIN
    BORDERSTYLE_MEDIUMBORDERSTYLE_MEDIUM
    BORDERSTYLE_DASHEDBORDERSTYLE_DASHED
    BORDERSTYLE_DOTTEDBORDERSTYLE_DOTTED
    BORDERSTYLE_THICKBORDERSTYLE_THICK
    BORDERSTYLE_DOUBLEBORDERSTYLE_DOUBLE
    BORDERSTYLE_HAIRBORDERSTYLE_HAIR
    BORDERSTYLE_MEDIUMDASHEDBORDERSTYLE_MEDIUMDASHED
    BORDERSTYLE_DASHDOTBORDERSTYLE_DASHDOT
    BORDERSTYLE_MEDIUMDASHDOTBORDERSTYLE_MEDIUMDASHDOT
    BORDERSTYLE_DASHDOTDOTBORDERSTYLE_DASHDOTDOT
    BORDERSTYLE_MEDIUMDASHDOTDOTBORDERSTYLE_MEDIUMDASHDOTDOT
    BORDERSTYLE_SLANTDASHDOTBORDERSTYLE_SLANTDASHDOT
  • void setBorderColor(Color color)
    Sets the border color.
  • BorderStyle borderLeft() const
    Returns the left border style.
  • void setBorderLeft(BorderStyle style = BORDERSTYLE_THIN)
    Sets the left border style.
  • BorderStyle borderRight() const
    Returns the right border style.
  • void setBorderRight(BorderStyle style = BORDERSTYLE_THIN)
    Sets the right border style.
  • BorderStyle borderTop() const
    Returns the top border style.
  • void setBorderTop(BorderStyle style = BORDERSTYLE_THIN)
    Sets the top border style.
  • BorderStyle borderBottom() const
    Returns the bottom border style.
  • void setBorderBottom(BorderStyle style = BORDERSTYLE_THIN)
    Sets the bottom border style.
  • Color borderLeftColor() const
    Returns the color of the left border.
  • void setBorderLeftColor(Color color)
    Sets the color of the left border.
  • Color borderRightColor() const
    Returns the color of the right border.
  • void setBorderRightColor(Color color)
    Sets the color of the right border.
  • Color borderTopColor() const
    Returns the color of the top border.
  • void setBorderTopColor(Color color)
    Sets the color of the top border.
  • Color borderBottomColor() const
    Returns the color of the bottom border.
  • void setBorderBottomColor(Color color)
    Sets the color of the bottom border.
  • BorderDiagonal borderDiagonal() const
    Returns the diagonal border.
  • void setBorderDiagonal(BorderDiagonal border)
    Sets the diagonal border.
    BorderDiagonal valueView
    BORDERDIAGONAL_NONEBORDERDIAGONAL_NONE
    BORDERDIAGONAL_DOWNBORDERDIAGONAL_DOWN
    BORDERDIAGONAL_UPBORDERDIAGONAL_UP
    BORDERDIAGONAL_BOTHBORDERDIAGONAL_BOTH
  • BorderStyle borderDiagonalStyle() const
    Returns the style of the diagonal border.
  • void setBorderDiagonalStyle(BorderStyle style)
    Sets the style of the diagonal border.
  • Color borderDiagonalColor() const
    Returns the color of the diagonal border.
  • void setBorderDiagonalColor(Color color)
    Sets the color of the diagonal border.
  • FillPattern fillPattern() const
    Returns the fill pattern.
  • void setFillPattern(FillPattern pattern)
    Sets the fill pattern.
    FillPattern valueView
    FILLPATTERN_NONE
    FILLPATTERN_SOLIDFILLPATTERN_SOLID
    FILLPATTERN_GRAY50FILLPATTERN_GRAY50
    FILLPATTERN_GRAY75FILLPATTERN_GRAY75
    FILLPATTERN_GRAY25FILLPATTERN_GRAY25
    FILLPATTERN_HORSTRIPEFILLPATTERN_HORSTRIPE
    FILLPATTERN_VERSTRIPEFILLPATTERN_VERSTRIPE
    FILLPATTERN_REVDIAGSTRIPEFILLPATTERN_REVDIAGSTRIPE
    FILLPATTERN_DIAGSTRIPEFILLPATTERN_DIAGSTRIPE
    FILLPATTERN_DIAGCROSSHATCHFILLPATTERN_DIAGCROSSHATCH
    FILLPATTERN_THICKDIAGCROSSHATCHFILLPATTERN_THICKDIAGCROSSHATCH
    FILLPATTERN_THINHORSTRIPEFILLPATTERN_THINHORSTRIPE
    FILLPATTERN_THINVERSTRIPEFILLPATTERN_THINVERSTRIPE
    FILLPATTERN_THINREVDIAGSTRIPEFILLPATTERN_THINREVDIAGSTRIPE
    FILLPATTERN_THINDIAGSTRIPEFILLPATTERN_THINDIAGSTRIPE
    FILLPATTERN_THINHORCROSSHATCHFILLPATTERN_THINHORCROSSHATCH
    FILLPATTERN_THINDIAGCROSSHATCHFILLPATTERN_THINDIAGCROSSHATCH
    FILLPATTERN_GRAY12P5FILLPATTERN_GRAY12P5
    FILLPATTERN_GRAY6P25FILLPATTERN_GRAY6P25
  • Color patternForegroundColor() const
    Returns the foreground color of the fill pattern.
  • void setPatternForegroundColor(Color color)
    Sets the foreground color of the fill pattern.
  • Color patternBackgroundColor() const
    Returns the background color of the fill pattern.
  • void setPatternBackgroundColor(Color color)
    Sets the background color of the fill pattern.
  • bool locked() const
    Returns whether the locked protection property is set to true.
  • void setLocked(bool locked = true)
    Sets the locked protection property. It is used when the sheet is protected with the Sheet::setProtect() method.
    If "locked" is false a user can change a cell with such format even if the sheet is protected.
  • bool hidden() const
    Returns whether the hidden protection property is set to true.
  • void setHidden(bool hidden = true)
    Sets the hidden protection property.