> ## Documentation Index
> Fetch the complete documentation index at: https://jetxl.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Cell styles

> Set the font, fill, border, and alignment of individual cells

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.

```python theme={null}
jet.write_sheet_arrow(
    df.to_arrow(),
    "styled.xlsx",
    cell_styles=[
        {
            "row": 2,
            "col": 1,
            "font": {"bold": True, "color": "FF0000"},
            "fill": {"pattern": "solid", "fg_color": "FFFF00"},
        }
    ],
)
```

<Warning>
  `row` is 1-based and `col` is 0-based, so cell B2 is `{"row": 2, "col": 1}`. See [Conventions](/guides/conventions) for the full indexing table.
</Warning>

To style cells based on the values they hold rather than where they sit, use [conditional formatting](/guides/conditional-formatting) instead.

## Font

<ParamField path="bold" type="bool" />

<ParamField path="italic" type="bool" />

<ParamField path="underline" type="bool" />

<ParamField path="size" type="float">Point size.</ParamField>
<ParamField path="color" type="str">Hex color. Six or eight digits both work.</ParamField>
<ParamField path="name" type="str">Typeface, such as `"Arial"`.</ParamField>

## Fill

<ParamField path="pattern" type="&#x22;solid&#x22; | &#x22;gray125&#x22; | &#x22;none&#x22;">
  Use `solid` for a flat background. `gray125` gives light stippled shading.
</ParamField>

<ParamField path="fg_color" type="str">The fill color for `solid`.</ParamField>
<ParamField path="bg_color" type="str">The background color behind a pattern.</ParamField>

<Tip>
  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.
</Tip>

## Border

Set `left`, `right`, `top`, and `bottom` independently. Each takes a `style` and a `color`.

<ParamField path="style" type="&#x22;thin&#x22; | &#x22;medium&#x22; | &#x22;thick&#x22; | &#x22;double&#x22; | &#x22;dotted&#x22; | &#x22;dashed&#x22;" />

<ParamField path="color" type="str">Hex color.</ParamField>

```python theme={null}
"border": {
    "left":   {"style": "thin",   "color": "000000"},
    "right":  {"style": "medium", "color": "000000"},
    "top":    {"style": "thick",  "color": "0070C0"},
    "bottom": {"style": "double", "color": "000000"},
}
```

## Alignment

<ParamField path="horizontal" type="&#x22;left&#x22; | &#x22;center&#x22; | &#x22;right&#x22; | &#x22;justify&#x22;" />

<ParamField path="vertical" type="&#x22;top&#x22; | &#x22;center&#x22; | &#x22;bottom&#x22;" />

<ParamField path="wrap_text" type="bool">Wraps long text inside the cell instead of letting it overflow.</ParamField>
<ParamField path="text_rotation" type="int">Degrees, 0 to 180, or `255` for vertical text.</ParamField>

Rotation numbering isn't obvious, so here's what the ranges do:

<AccordionGroup>
  <Accordion title="0" icon="arrow-right">
    No rotation. This is the default.
  </Accordion>

  <Accordion title="1 to 90" icon="arrow-turn-up">
    Counterclockwise. Use `45` to angle text up and to the right, which fits more header text into a narrow column.
  </Accordion>

  <Accordion title="91 to 180" icon="arrow-turn-down">
    Clockwise. `91` sits one degree below horizontal and `180` points straight down.
  </Accordion>

  <Accordion title="255" icon="arrows-up-down">
    Vertical. Letters stack top to bottom without rotating.
  </Accordion>
</AccordionGroup>

## Number format

<ParamField path="number_format" type="str">
  Any built-in name or Excel format code. See [Number formats](/guides/number-formats).
</ParamField>

Setting a format here overrides `column_formats` for that one cell.

## A complete cell

```python theme={null}
cell_styles = [
    {
        "row": 1,
        "col": 0,
        "font": {"bold": True, "size": 14.0, "color": "FFFFFF", "name": "Arial"},
        "fill": {"pattern": "solid", "fg_color": "0070C0"},
        "border": {"bottom": {"style": "medium", "color": "000000"}},
        "alignment": {"horizontal": "center", "vertical": "center", "wrap_text": True},
        "number_format": "currency",
    }
]
```
