Skip to main content
Use cell_styles when you know exactly which cell you want to change. Each entry names a position and carries any combination of font, fill, border, alignment, and number format.
row is 1-based and col is 0-based, so cell B2 is {"row": 2, "col": 1}. See Conventions for the full indexing table.
To style cells based on the values they hold rather than where they sit, use conditional formatting instead.

Font

bool
bool
bool
float
Point size.
str
Hex color. Six or eight digits both work.
str
Typeface, such as "Arial".

Fill

"solid" | "gray125" | "none"
Use solid for a flat background. gray125 gives light stippled shading.
str
The fill color for solid.
str
The background color behind a pattern.
This is how you shade a header row. styled_headers gives bold only, so add a cell_styles entry per header cell when you want a background color.

Border

Set left, right, top, and bottom independently. Each takes a style and a color.
"thin" | "medium" | "thick" | "double" | "dotted" | "dashed"
str
Hex color.

Alignment

"left" | "center" | "right" | "justify"
"top" | "center" | "bottom"
bool
Wraps long text inside the cell instead of letting it overflow.
int
Degrees, 0 to 180, or 255 for vertical text.
Rotation numbering isn’t obvious, so here’s what the ranges do:
No rotation. This is the default.
Counterclockwise. Use 45 to angle text up and to the right, which fits more header text into a narrow column.
Clockwise. 91 sits one degree below horizontal and 180 points straight down.
Vertical. Letters stack top to bottom without rotating.

Number format

str
Any built-in name or Excel format code. See Number formats.
Setting a format here overrides column_formats for that one cell.

A complete cell