xlsxwriter.format

@page format_page The Format object

The Format object represents an the formatting properties that can be applied to a cell including: fonts, colors, patterns, borders, alignment and number formatting.

See @ref format.h for full details of the functionality.

@file format.h

@brief Functions and properties for adding formatting to cells in Excel.

This section describes the functions and properties that are available for formatting cells in Excel.

The properties of a cell that can be formatted include: fonts, colors, patterns, borders, alignment and number formatting.

@image html formats_intro.png

Formats in libxlsxwriter are accessed via the lxw_format struct. Throughout this document these will be referred to simply as *Formats*.

Formats are created by calling the workbook_add_format() method as follows:

@code lxw_format *format = workbook_add_format(workbook); @endcode

The members of the lxw_format struct aren't modified directly. Instead the format properties are set by calling the functions shown in this section. For example:

@code // Create the Format. lxw_format *format = workbook_add_format(workbook);

// Set some of the format properties. format_set_bold(format); format_set_font_color(format, LXW_COLOR_RED);

// Use the format to change the text format in a cell. worksheet_write_string(worksheet, 0, 0, "Hello", format);

@endcode

The full range of formatting options that can be applied using libxlsxwriter are shown below.

Members

Aliases

lxw_color_t
alias lxw_color_t = int32_t

@brief The type for RGB colors in libxlsxwriter.

Enums

lxw_defined_colors
enum lxw_defined_colors

Predefined values for common colors.

lxw_format_alignments
enum lxw_format_alignments

Alignment values for format_set_align().

lxw_format_borders
enum lxw_format_borders

Cell border styles for use with format_set_border().

lxw_format_diagonal_types
enum lxw_format_diagonal_types
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
lxw_format_patterns
enum lxw_format_patterns

Pattern value for use with format_set_pattern().

lxw_format_scripts
enum lxw_format_scripts

Superscript and subscript values for format_set_font_script().

lxw_format_underlines
enum lxw_format_underlines

Format underline values for format_set_underline().

Functions

format_set_align
void format_set_align(lxw_format* format, uint8_t alignment)

@brief Set the alignment for data in the cell.

format_set_bg_color
void format_set_bg_color(lxw_format* format, lxw_color_t color)

@brief Set the pattern background color for a cell.

format_set_bold
void format_set_bold(lxw_format* format)

@brief Turn on bold for the format font.

format_set_border
void format_set_border(lxw_format* format, uint8_t style)

@brief Set the cell border style.

format_set_border_color
void format_set_border_color(lxw_format* format, lxw_color_t color)

@brief Set the color of the cell border.

format_set_bottom
void format_set_bottom(lxw_format* format, uint8_t style)

@brief Set the cell bottom border style.

format_set_bottom_color
void format_set_bottom_color(lxw_format* format, lxw_color_t color)

@brief Set the color of the bottom cell border.

format_set_diag_border
void format_set_diag_border(lxw_format* format, uint8_t value)
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
format_set_diag_color
void format_set_diag_color(lxw_format* format, lxw_color_t color)
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
format_set_diag_type
void format_set_diag_type(lxw_format* format, uint8_t value)
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
format_set_fg_color
void format_set_fg_color(lxw_format* format, lxw_color_t color)

@brief Set the pattern foreground color for a cell.

format_set_font_charset
void format_set_font_charset(lxw_format* format, uint8_t value)
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
format_set_font_color
void format_set_font_color(lxw_format* format, lxw_color_t color)

@brief Set the color of the font used in the cell.

format_set_font_condense
void format_set_font_condense(lxw_format* format)
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
format_set_font_extend
void format_set_font_extend(lxw_format* format)
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
format_set_font_family
void format_set_font_family(lxw_format* format, uint8_t value)
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
format_set_font_name
void format_set_font_name(lxw_format* format, char* font_name)

@brief Set the font used in the cell.

format_set_font_outline
void format_set_font_outline(lxw_format* format)
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
format_set_font_scheme
void format_set_font_scheme(lxw_format* format, char* font_scheme)
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
format_set_font_script
void format_set_font_script(lxw_format* format, uint8_t style)

@brief Set the superscript/subscript property of the font.

format_set_font_shadow
void format_set_font_shadow(lxw_format* format)
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
format_set_font_size
void format_set_font_size(lxw_format* format, uint16_t size)

@brief Set the size of the font used in the cell.

format_set_font_strikeout
void format_set_font_strikeout(lxw_format* format)

@brief Set the strikeout property of the font.

format_set_hidden
void format_set_hidden(lxw_format* format)

@brief Hide formulas in a cell.

format_set_indent
void format_set_indent(lxw_format* format, uint8_t level)

@brief Set the cell text indentation level.

format_set_italic
void format_set_italic(lxw_format* format)

@brief Turn on italic for the format font.

format_set_left
void format_set_left(lxw_format* format, uint8_t style)

@brief Set the cell left border style.

format_set_left_color
void format_set_left_color(lxw_format* format, lxw_color_t color)

@brief Set the color of the left cell border.

format_set_num_format
void format_set_num_format(lxw_format* format, char* num_format)

@brief Set the number format for a cell.

format_set_num_format_index
void format_set_num_format_index(lxw_format* format, uint8_t index)

@brief Set the Excel built-in number format for a cell.

format_set_pattern
void format_set_pattern(lxw_format* format, uint8_t index)

@brief Set the background fill pattern for a cell

format_set_reading_order
void format_set_reading_order(lxw_format* format, uint8_t value)
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
format_set_right
void format_set_right(lxw_format* format, uint8_t style)

@brief Set the cell right border style.

format_set_right_color
void format_set_right_color(lxw_format* format, lxw_color_t color)

@brief Set the color of the right cell border.

format_set_rotation
void format_set_rotation(lxw_format* format, int16_t angle)

@brief Set the rotation of the text in a cell.

format_set_shrink
void format_set_shrink(lxw_format* format)

@brief Turn on the text "shrink to fit" for a cell.

format_set_text_wrap
void format_set_text_wrap(lxw_format* format)

@brief Wrap text in a cell.

format_set_theme
void format_set_theme(lxw_format* format, uint8_t value)
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
format_set_top
void format_set_top(lxw_format* format, uint8_t style)

@brief Set the cell top border style.

format_set_top_color
void format_set_top_color(lxw_format* format, lxw_color_t color)

@brief Set the color of the top cell border.

format_set_underline
void format_set_underline(lxw_format* format, uint8_t style)

@brief Turn on underline for the format:

format_set_unlocked
void format_set_unlocked(lxw_format* format)

@brief Set the cell unlocked state.

lxw_format_free
void lxw_format_free(lxw_format* format)
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
lxw_format_get_border_key
lxw_border* lxw_format_get_border_key(lxw_format* format)
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
lxw_format_get_fill_key
lxw_fill* lxw_format_get_fill_key(lxw_format* format)
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
lxw_format_get_font_key
lxw_font* lxw_format_get_font_key(lxw_format* format)
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
lxw_format_get_xf_index
int32_t lxw_format_get_xf_index(lxw_format* format)
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
lxw_format_new
lxw_format* lxw_format_new()
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.

Manifest constants

LXW_COLOR_MASK
enum LXW_COLOR_MASK;
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
LXW_COLOR_PINK
enum LXW_COLOR_PINK;
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
LXW_COLOR_UNSET
enum LXW_COLOR_UNSET;
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
LXW_DEFAULT_FONT_FAMILY
enum LXW_DEFAULT_FONT_FAMILY;
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
LXW_DEFAULT_FONT_NAME
enum LXW_DEFAULT_FONT_NAME;
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
LXW_DEFAULT_FONT_THEME
enum LXW_DEFAULT_FONT_THEME;
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
LXW_FORMAT_FIELD_LEN
enum LXW_FORMAT_FIELD_LEN;
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
LXW_MAX_FONT_SIZE
enum LXW_MAX_FONT_SIZE;
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
LXW_MIN_FONT_SIZE
enum LXW_MIN_FONT_SIZE;
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
LXW_PROPERTY_UNSET
enum LXW_PROPERTY_UNSET;
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.

Structs

lxw_border
struct lxw_border
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
lxw_fill
struct lxw_fill
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
lxw_font
struct lxw_font
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
lxw_format
struct lxw_format

@brief Struct to represent the formatting properties of an Excel format.

Meta