XLSX

Styles

Fonts, fills, borders, alignment, and number formats

XLSX uses an index-based style system. When you apply a style to a cell, the library automatically deduplicates and registers it.

Font Styles

{
  "worksheets": [
    {
      "name": "Sheet1",
      "children": [
        {
          "cells": [
            { "value": "Bold" },
            {
              "value": "Styled",
              "style": {
                "font": {
                  "bold": true,
                  "italic": true,
                  "size": 14,
                  "color": "FF0000",
                  "fontName": "Arial"
                }
              }
            }
          ]
        }
      ]
    }
  ]
}

Fill Styles

{
  "worksheets": [
    {
      "name": "Sheet1",
      "children": [
        {
          "cells": [
            { "value": "Yellow", "style": { "fill": { "color": "FFFF00" } } },
            { "value": "Blue", "style": { "fill": { "color": "4472C4" } } }
          ]
        }
      ]
    }
  ]
}

Border Styles

{
  "worksheets": [
    {
      "name": "Sheet1",
      "children": [
        {
          "cells": [
            {
              "value": "Bordered",
              "style": {
                "border": {
                  "top": { "style": "thin", "color": "000000" },
                  "bottom": { "style": "thin", "color": "000000" },
                  "left": { "style": "thin", "color": "000000" },
                  "right": { "style": "thin", "color": "000000" }
                }
              }
            }
          ]
        }
      ]
    }
  ]
}

Border styles: thin, medium, thick, dotted, dashed, double, hair, none.

Alignment

{
  "worksheets": [
    {
      "name": "Sheet1",
      "children": [
        {
          "cells": [
            {
              "value": "Centered",
              "style": {
                "alignment": { "horizontal": "center", "vertical": "center", "wrapText": true }
              }
            }
          ]
        }
      ]
    }
  ]
}

Combining Styles

Styles are combined and deduplicated automatically:

{
  "worksheets": [
    {
      "name": "Sheet1",
      "children": [
        {
          "cells": [
            {
              "value": "Name",
              "style": {
                "font": { "bold": true, "color": "FFFFFF" },
                "fill": { "color": "4472C4" },
                "alignment": { "horizontal": "center" }
              }
            },
            {
              "value": "Score",
              "style": {
                "font": { "bold": true, "color": "FFFFFF" },
                "fill": { "color": "4472C4" },
                "alignment": { "horizontal": "center" }
              }
            }
          ]
        },
        { "cells": [{ "value": "Alice" }, { "value": 95 }] }
      ]
    }
  ]
}

Repeated use of the same style object reuses the same cellXf index — no unnecessary duplication in the output file.

Font Options Reference

OptionTypeDescription
boldbooleanBold formatting
italicbooleanItalic formatting
underlinebooleanUnderline
strikebooleanStrikethrough
sizenumberFont size in points
colorstringHex color
fontNamestringFont family name

Border Options Reference

OptionTypeDescription
stylestringthin, medium, thick, dotted, dashed, etc.
colorstringHex color

Alignment Options Reference

OptionTypeDescription
horizontalstringleft, center, right, fill, justify
verticalstringtop, center, bottom
wrapTextbooleanWrap text within cell
textRotationnumberText rotation in degrees
indentnumberIndent level
Copyright © 2026