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.
Constant | View |
---|---|
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.
Constant | View |
---|---|
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.
Constant | View |
---|---|
BOLD_LIGHT | example |
BOLD_NORMAL | example |
BOLD_BOLD | example |
BOLD_STRONG | example |
enum Format::AlignH
This enum describes the horizontal alignments. It is used by setAlign(), setAlignH() functions.
Constant | View |
---|---|
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.
Constant | View |
---|---|
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.
Constant | Background color | Foreground color |
---|---|---|
COLOR_BLACK | COLOR_BLACK | |
COLOR_WHITE | COLOR_WHITE | |
COLOR_RED | COLOR_RED | |
COLOR_BRIGHTGREEN | COLOR_BRIGHTGREEN | |
COLOR_BLUE | COLOR_BLUE | |
COLOR_YELLOW | COLOR_YELLOW | |
COLOR_PINK | COLOR_PINK | |
COLOR_TURQUOISE | COLOR_TURQUOISE | |
COLOR_DARKRED | COLOR_DARKRED | |
COLOR_GREEN | COLOR_GREEN | |
COLOR_DARKBLUE | COLOR_DARKBLUE | |
COLOR_DARKYELLOW | COLOR_DARKYELLOW | |
COLOR_VIOLET | COLOR_VIOLET | |
COLOR_TEAL | COLOR_TEAL | |
COLOR_GRAY25 | COLOR_GRAY25 | |
COLOR_GRAY50 | COLOR_GRAY50 | |
COLOR_PERIWINKLE_CF | COLOR_PERIWINKLE_CF | |
COLOR_PLUM_CF | COLOR_PLUM_CF | |
COLOR_IVORY_CF | COLOR_IVORY_CF | |
COLOR_LIGHTTURQUOISE_CF | COLOR_LIGHTTURQUOISE_CF | |
COLOR_DARKPURPLE_CF | COLOR_DARKPURPLE_CF | |
COLOR_CORAL_CF | COLOR_CORAL_CF | |
COLOR_OCEANBLUE_CF | COLOR_OCEANBLUE_CF | |
COLOR_ICEBLUE_CF | COLOR_ICEBLUE_CF | |
COLOR_DARKBLUE_CL | COLOR_DARKBLUE_CL | |
COLOR_PINK_CL | COLOR_PINK_CL | |
COLOR_YELLOW_CL | COLOR_YELLOW_CL | |
COLOR_TURQUOISE_CL | COLOR_TURQUOISE_CL | |
COLOR_VIOLET_CL | COLOR_VIOLET_CL | |
COLOR_DARKRED_CL | COLOR_DARKRED_CL | |
COLOR_TEAL_CL | COLOR_TEAL_CL | |
COLOR_BLUE_CL | COLOR_BLUE_CL | |
COLOR_SKYBLUE | COLOR_SKYBLUE | |
COLOR_LIGHTTURQUOISE | COLOR_LIGHTTURQUOISE | |
COLOR_LIGHTGREEN | COLOR_LIGHTGREEN | |
COLOR_LIGHTYELLOW | COLOR_LIGHTYELLOW | |
COLOR_PALEBLUE | COLOR_PALEBLUE | |
COLOR_ROSE | COLOR_ROSE | |
COLOR_LAVENDER | COLOR_LAVENDER | |
COLOR_TAN | COLOR_TAN | |
COLOR_LIGHTBLUE | COLOR_LIGHTBLUE | |
COLOR_AQUA | COLOR_AQUA | |
COLOR_LIME | COLOR_LIME | |
COLOR_GOLD | COLOR_GOLD | |
COLOR_LIGHTORANGE | COLOR_LIGHTORANGE | |
COLOR_ORANGE | COLOR_ORANGE | |
COLOR_BLUEGRAY | COLOR_BLUEGRAY | |
COLOR_GRAY40 | COLOR_GRAY40 | |
COLOR_DARKTEAL | COLOR_DARKTEAL | |
COLOR_SEAGREEN | COLOR_SEAGREEN | |
COLOR_DARKGREEN | COLOR_DARKGREEN | |
COLOR_OLIVEGREEN | COLOR_OLIVEGREEN | |
COLOR_BROWN | COLOR_BROWN | |
COLOR_PLUM | COLOR_PLUM | |
COLOR_INDIGO | COLOR_INDIGO | |
COLOR_GRAY80 | COLOR_GRAY80 |
enum Format::Script
This enum describes the script font styles. It is used by setScript() function.
Constant | View |
---|---|
SCRIPT_NONE | TEXT SCRIPT_NONE |
SCRIPT_SUPERSCRIPT | TEXTSCRIPT_SUPERSCRIPT |
SCRIPT_SUBSCRIPT | TEXTSCRIPT_SUBSCRIPT |
enum Format::Pattern
This enum describes the cell patterns. It is used by setPattern() function.
Constant | View |
---|---|
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.
Constant | Description | Example | ||
---|---|---|---|---|
NUMFORMAT_GENERAL | no specific format | 50.4 | ||
NUMFORMAT_NUMBER | general number | 301 | ||
NUMFORMAT_NUMBER_D2 | number with decimal point | 900.00 | ||
NUMFORMAT_NUMBER_SEP | number with 1000 separator | 9,000,000 | ||
NUMFORMAT_NUMBER_SEP_D2 | number with decimal point and 1000 separator | 1,200.85 | ||
NUMFORMAT_CURRENCY_NEGBRA | monetary value, negative in brackets | (601$) | ||
NUMFORMAT_CURRENCY_NEGBRARED | monetary value, negative is red in brackets | (601$) | ||
NUMFORMAT_CURRENCY_D2_NEGBRA | monetary value with decimal point, negative in brackets | ($600.50) | ||
NUMFORMAT_CURRENCY_D2_NEGBRARED | monetary value with decimal point, negative is red in brackets | ($600.50) | ||
NUMFORMAT_PERCENT | percent value, multiply the cell value by 100 | 75% | ||
NUMFORMAT_PERCENT_D2 | percent value with decimal point, multiply the cell value by 100 | 75.90% | ||
NUMFORMAT_SCIENTIFIC_D2 | scientific value with E character and decimal point | 5.04E+1 | ||
NUMFORMAT_FRACTION_ONEDIG | fraction value, one digit | 50 2/5 | ||
NUMFORMAT_FRACTION_TWODIG | fraction value, two digits | 50 21/25 | ||
NUMFORMAT_DATE_MDY | date value, depends on operation system settings | 3/14/2008 | ||
NUMFORMAT_CUSTOM_D_MON_YY | custom date value d-mmm-yy | 14-Mar-08 | ||
NUMFORMAT_CUSTOM_D_MON | custom date value d-mmm | 14-Mar | ||
NUMFORMAT_CUSTOM_MON_YY | custom date value mmm-yy | Mar-08 | ||
NUMFORMAT_CUSTOM_HMM_AM | custom time value h:mm AM/PM | 8:30 PM | ||
NUMFORMAT_CUSTOM_HMMSS_AM | custom time value h:mm:ss AM/PM | 8:30:55 PM | ||
NUMFORMAT_CUSTOM_HMM | custom time value h:mm | 20:30 | ||
NUMFORMAT_CUSTOM_HMMSS | custom time value h:mm:ss | 20:30:55 | ||
NUMFORMAT_CUSTOM_MDYYYY_HMM | custom datetime value m/d/yyyy h:mm | 3/14/2008 20:30 | ||
NUMFORMAT_NUMBER_SEP_NEGBRA | number with 1000 separator, negative in brackets | (4,001) | ||
NUMFORMAT_NUMBER_SEP_NEGBRARED | number with 1000 separator, negative is red in brackets | (4,001) | ||
NUMFORMAT_NUMBER_D2_SEP_NEGBRA | number with 1000 separator and decimal point, negative in brackets | (6,000.45) | ||
NUMFORMAT_NUMBER_D2_SEP_NEGBRARED | number with 1000 separator and decimal point, negative is red in brackets | (6,000.45) | ||
NUMFORMAT_ACCOUNT | account value (line up the currency symbols and decimal points in a column) | 5,000 | ||
NUMFORMAT_ACCOUNT_CUR | account value with currency symbol |
| ||
NUMFORMAT_ACCOUNT_D2 | account value with decimal point | 5,000.40 | ||
NUMFORMAT_ACCOUNT_D2_CUR | account value with currency symbol and decimal point |
| ||
NUMFORMAT_CUSTOM_MMSS | custom time value mm:ss | 30:55 | ||
NUMFORMAT_CUSTOM_H0MMSS | custom time value [h]:mm:ss | 20:30:55 | ||
NUMFORMAT_CUSTOM_MMSS0 | custom time value mm:ss.0 | 30:55.0 | ||
NUMFORMAT_CUSTOM_000P0E_PLUS0 | custom value ##0.0E+0 | 15.2E+3 | ||
NUMFORMAT_TEXT | text value | 5000.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