Index Workbook Worksheet Error

Class Format


Class for generating Excel formats. It represents view of cells (alignment, font, color, border). Do not try create object of this class directly. Instead use factory method Workbook::addFormat().

enum Format::Underline
This enum describes the underline font styles. It is used by setUnderline() function.
ConstantView
UNDERLINE_NONE
UNDERLINE_UNDERLINE
UNDERLINE_DOUBLE

enum Format::Border
This enum describes the border styles of cell. It is used by setBorder(), setLeft(), setTop(), setRight(), setBottom() functions.
ConstantView
BORDER_NONE
BORDER_THIN
BORDER_THICK
BORDER_DASH
BORDER_DOT
BORDER_SUPERTHICK
BORDER_DOUBLE

enum Format::Bold
This enum describes the weight font styles. It is used by setBold() function.
ConstantView
BOLD_LIGHTexample
BOLD_NORMALexample
BOLD_BOLDexample
BOLD_STRONGexample

enum Format::AlignH
This enum describes the horizontal alignments. It is used by setAlign(), setAlignH() functions.
ConstantView
ALIGN_NONE
ALIGN_LEFT
ALIGN_CENTER
ALIGN_RIGHT
ALIGN_FILL
ALIGN_JUSTIFY
ALIGN_MERGE
ALIGN_EQUAL_SPACE

enum Format::AlignV
This enum describes the vertical alignments. It is used by setAlign(), setAlignV() functions.
ConstantView
ALIGN_TOP
ALIGN_VCENTER
ALIGN_BOTTOM
ALIGN_VJUSTIFY
ALIGN_VEQUAL_SPACE

enum Format::Color
This enum describes the colors. It is used by setTextColor(), setBgColor(), setBorderColor(), setLeftColor(), setTopColor(), setRightColor(), setBottomColor() functions.
ConstantBackground colorForeground color
COLOR_BLACKCOLOR_BLACK
COLOR_WHITECOLOR_WHITE
COLOR_REDCOLOR_RED
COLOR_BRIGHTGREENCOLOR_BRIGHTGREEN
COLOR_BLUECOLOR_BLUE
COLOR_YELLOWCOLOR_YELLOW
COLOR_PINKCOLOR_PINK
COLOR_TURQUOISECOLOR_TURQUOISE
COLOR_DARKREDCOLOR_DARKRED
COLOR_GREENCOLOR_GREEN
COLOR_DARKBLUECOLOR_DARKBLUE
COLOR_DARKYELLOWCOLOR_DARKYELLOW
COLOR_VIOLETCOLOR_VIOLET
COLOR_TEALCOLOR_TEAL
COLOR_GRAY25COLOR_GRAY25
COLOR_GRAY50COLOR_GRAY50
COLOR_PERIWINKLE_CFCOLOR_PERIWINKLE_CF
COLOR_PLUM_CFCOLOR_PLUM_CF
COLOR_IVORY_CFCOLOR_IVORY_CF
COLOR_LIGHTTURQUOISE_CFCOLOR_LIGHTTURQUOISE_CF
COLOR_DARKPURPLE_CFCOLOR_DARKPURPLE_CF
COLOR_CORAL_CFCOLOR_CORAL_CF
COLOR_OCEANBLUE_CFCOLOR_OCEANBLUE_CF
COLOR_ICEBLUE_CFCOLOR_ICEBLUE_CF
COLOR_DARKBLUE_CLCOLOR_DARKBLUE_CL
COLOR_PINK_CLCOLOR_PINK_CL
COLOR_YELLOW_CLCOLOR_YELLOW_CL
COLOR_TURQUOISE_CLCOLOR_TURQUOISE_CL
COLOR_VIOLET_CLCOLOR_VIOLET_CL
COLOR_DARKRED_CLCOLOR_DARKRED_CL
COLOR_TEAL_CLCOLOR_TEAL_CL
COLOR_BLUE_CLCOLOR_BLUE_CL
COLOR_SKYBLUECOLOR_SKYBLUE
COLOR_LIGHTTURQUOISECOLOR_LIGHTTURQUOISE
COLOR_LIGHTGREENCOLOR_LIGHTGREEN
COLOR_LIGHTYELLOWCOLOR_LIGHTYELLOW
COLOR_PALEBLUECOLOR_PALEBLUE
COLOR_ROSECOLOR_ROSE
COLOR_LAVENDERCOLOR_LAVENDER
COLOR_TANCOLOR_TAN
COLOR_LIGHTBLUECOLOR_LIGHTBLUE
COLOR_AQUACOLOR_AQUA
COLOR_LIMECOLOR_LIME
COLOR_GOLDCOLOR_GOLD
COLOR_LIGHTORANGECOLOR_LIGHTORANGE
COLOR_ORANGECOLOR_ORANGE
COLOR_BLUEGRAYCOLOR_BLUEGRAY
COLOR_GRAY40COLOR_GRAY40
COLOR_DARKTEALCOLOR_DARKTEAL
COLOR_SEAGREENCOLOR_SEAGREEN
COLOR_DARKGREENCOLOR_DARKGREEN
COLOR_OLIVEGREENCOLOR_OLIVEGREEN
COLOR_BROWNCOLOR_BROWN
COLOR_PLUMCOLOR_PLUM
COLOR_INDIGOCOLOR_INDIGO
COLOR_GRAY80COLOR_GRAY80

enum Format::Script
This enum describes the script font styles. It is used by setScript() function.
ConstantView
SCRIPT_NONETEXT SCRIPT_NONE
SCRIPT_SUPERSCRIPTTEXTSCRIPT_SUPERSCRIPT
SCRIPT_SUBSCRIPTTEXTSCRIPT_SUBSCRIPT

enum Format::Pattern
This enum describes the cell patterns. It is used by setPattern() function.
ConstantView
PATTERN_NOBACKGROUND
PATTERN_SOLID
PATTERN_GRAY75
PATTERN_GRAY50
PATTERN_GRAY25
PATTERN_GRAY12P5
PATTERN_GRAY6P25
PATTERN_HORSTRIPE
PATTERN_VERSTIPE
PATTERN_REVDIAGSTRIPE
PATTERN_DIAGSTRIPE
PATTERN_DIAGCROSSHATCH
PATTERN_THICKDIAGCROSSHATCH
PATTERN_THINHORSTRIPE
PATTERN_THINVERSTRIPE
PATTERN_THINREVDIAGSTRIPE
PATTERN_THINDIAGSTRIPE
PATTERN_THINHORCROSSHATCH
PATTERN_THINDIAGCROSSHATCH

enum Format::NumFormat
This enum describes formats of numbers, dates, times. It is used by setNumFormat() function.
ConstantDescriptionExample
NUMFORMAT_GENERALno specific format50.4
NUMFORMAT_NUMBERgeneral number301
NUMFORMAT_NUMBER_D2number with decimal point900.00
NUMFORMAT_NUMBER_SEPnumber with 1000 separator9,000,000
NUMFORMAT_NUMBER_SEP_D2number with decimal point and 1000 separator1,200.85
NUMFORMAT_CURRENCY_NEGBRAmonetary value, negative in brackets(601$)
NUMFORMAT_CURRENCY_NEGBRAREDmonetary value, negative is red in brackets(601$)
NUMFORMAT_CURRENCY_D2_NEGBRAmonetary value with decimal point, negative in brackets($600.50)
NUMFORMAT_CURRENCY_D2_NEGBRAREDmonetary value with decimal point, negative is red in brackets($600.50)
NUMFORMAT_PERCENTpercent value, multiply the cell value by 10075%
NUMFORMAT_PERCENT_D2percent value with decimal point, multiply the cell value by 10075.90%
NUMFORMAT_SCIENTIFIC_D2scientific value with E character and decimal point5.04E+1
NUMFORMAT_FRACTION_ONEDIGfraction value, one digit50 2/5
NUMFORMAT_FRACTION_TWODIGfraction value, two digits50 21/25
NUMFORMAT_DATE_MDYdate value, depends on operation system settings3/14/2008
NUMFORMAT_CUSTOM_D_MON_YYcustom date value d-mmm-yy14-Mar-08
NUMFORMAT_CUSTOM_D_MONcustom date value d-mmm14-Mar
NUMFORMAT_CUSTOM_MON_YYcustom date value mmm-yyMar-08
NUMFORMAT_CUSTOM_HMM_AMcustom time value h:mm AM/PM8:30 PM
NUMFORMAT_CUSTOM_HMMSS_AMcustom time value h:mm:ss AM/PM8:30:55 PM
NUMFORMAT_CUSTOM_HMMcustom time value h:mm20:30
NUMFORMAT_CUSTOM_HMMSScustom time value h:mm:ss20:30:55
NUMFORMAT_CUSTOM_MDYYYY_HMMcustom datetime value m/d/yyyy h:mm3/14/2008 20:30
NUMFORMAT_NUMBER_SEP_NEGBRAnumber with 1000 separator, negative in brackets(4,001)
NUMFORMAT_NUMBER_SEP_NEGBRAREDnumber with 1000 separator, negative is red in brackets(4,001)
NUMFORMAT_NUMBER_D2_SEP_NEGBRAnumber with 1000 separator and decimal point, negative in brackets(6,000.45)
NUMFORMAT_NUMBER_D2_SEP_NEGBRAREDnumber with 1000 separator and decimal point, negative is red in brackets(6,000.45)
NUMFORMAT_ACCOUNTaccount value (line up the currency symbols and decimal points in a column)5,000
NUMFORMAT_ACCOUNT_CURaccount value with currency symbol
$5,000
NUMFORMAT_ACCOUNT_D2account value with decimal point5,000.40
NUMFORMAT_ACCOUNT_D2_CURaccount value with currency symbol and decimal point
$5,000.40
NUMFORMAT_CUSTOM_MMSScustom time value mm:ss30:55
NUMFORMAT_CUSTOM_H0MMSScustom time value [h]:mm:ss20:30:55
NUMFORMAT_CUSTOM_MMSS0custom time value mm:ss.030:55.0
NUMFORMAT_CUSTOM_000P0E_PLUS0custom value ##0.0E+015.2E+3
NUMFORMAT_TEXTtext value5000.4

void Format::setAlign(AlignH hor, AlignV ver)
Sets cell horizontal and vertical alignments.

void Format::setAlignH(AlignH hor)
Sets cell horizontal alignment.

void Format::setAlignV(AlignV ver)
Sets cell vertical alignment.

void Format::setTextWrap(bool textwrap = true)
Turn on/off text wrapping in cells.

void Format::setNumFormat(NumFormat num_format)
Sets the numeric format (date, time, currency...) for cells.

void Format::setSize(int size)
Sets font size.

void Format::setFont(const std::string& font)
Sets font name.

void Format::setBold(Bold weight = BOLD_BOLD)
Sets font bold weight.

void Format::setItalic(bool italic = true)
Turn on/off italic font style.

void Format::setUnderline(Underline underline = UNDERLINE_UNDERLINE)
Sets underline font style.

void Format::setStrikeOut(bool strikeout = true)
Turn on/off strikeout font style.

void Format::setScript(Script script)
Sets the script type of the text.

void Format::setTextRotation(int angle)
Sets the orientation of the text (from -90 to 90, 0 for stacking top-to-bottom).

void Format::setTextColor(int color)
Sets the cell's text color. See default predefined colors.

void Format::setBgColor(int color)
Sets the cell's background color.

void Format::setPattern(Pattern pattern = PATTERN_SOLID)
Sets the cell's fill pattern.

void Format::setBorder(Border style)
Sets the cell's border style.

void Format::setLeft(Border style)
Sets the cell's left border style.

void Format::setTop(Border style)
Sets the cell's top border style.

void Format::setRight(Border style)
Sets the cell's right border style.

void Format::setBottom(Border style)
Sets the cell's bottom border style.

void Format::setBorderColor(int color)
Sets the cell's border color.

void Format::setLeftColor(int color)
Sets the cell's left border color.

void Format::setTopColor(int color)
Sets the cell's top border color.

void Format::setRightColor(int color)
Sets the cell's right border color.

void Format::setBottomColor(int color)
Sets the cell's bottom border color.

void Format::setLocked(bool locked = true)
Locks/unlocks a cell.

See also:
Class Workbook
Class Worksheet
Class Error