Skip to main content
A few rules apply everywhere in Jetxl. Read this once and the rest of the guides make more sense.

Colors

Give a color as a hex string. Jetxl accepts several spellings and normalizes them for you. You don’t need to memorize alpha. Paste the six-digit hex from your design tool and Jetxl makes it opaque.
When a color is unusable, Jetxl drops it and writes the file without it. You get a spreadsheet with default coloring rather than an error, so check your output if a color doesn’t appear.
Chart text colors take the same forms. If you give eight digits, Jetxl discards the alpha, because the chart format Excel uses accepts only six.

Rows and columns

Indexing isn’t uniform, and this causes more mistakes than anything else in the API. Cell B2 in cell_styles is {"row": 2, "col": 1}. The row matches what Excel shows you; the column counts from zero, like a Python list.
When a style lands one row off, check this table first. That’s almost always the cause.

Errors

Jetxl fails in three different ways depending on what’s wrong. Errors raised from the Rust core arrive as OSError, not ValueError, so catch OSError when you need to handle them.
A number format code that’s empty or all letters, such as "accounting", raises an OSError naming the bad code. So does an unsupported column type, and exceeding Excel’s grid limits.
An unrecognized comparison operator becomes greater_than instead of raising. Check your spelling, because greater_then produces a working file with the wrong rule.
An unusable color is omitted. So is a conditional format with an unrecognized rule_type, and a table missing a required key such as name. The rest of the file writes normally, with no warning that the feature didn’t apply.
After adding a conditional format, table or chart, open the file once and confirm it’s there. A dropped feature looks identical to one you forgot to add.

Naming

Functions ending in _arrow read Arrow memory. Functions ending in _to_bytes return the workbook instead of writing a file. Plural names, such as write_sheets_arrow, take a list of sheets.