{"record":{"id":"152d7c3b670a8458","repo":"pola-rs/polars","slug":"invalid-table-style-key-key-r","errorCode":null,"errorMessage":"invalid table style key: {key!r}","messagePattern":"invalid table style key: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/io/spreadsheet/_write_utils.py","lineNumber":556,"sourceCode":"    return table_columns, column_formats, df  # type: ignore[return-value]\n\n\ndef _xl_setup_table_options(\n    table_style: dict[str, Any] | str | None,\n) -> tuple[dict[str, Any] | str | None, dict[str, Any]]:\n    \"\"\"Setup table options, distinguishing style name from other formatting.\"\"\"\n    if isinstance(table_style, dict):\n        valid_options = (\n            \"style\",\n            \"banded_columns\",\n            \"banded_rows\",\n            \"first_column\",\n            \"last_column\",\n        )\n        for key in table_style:\n            if key not in valid_options:\n                msg = f\"invalid table style key: {key!r}\"\n                raise ValueError(msg)\n\n        table_options = table_style.copy()\n        table_style = table_options.pop(\"style\", None)\n    else:\n        table_options = {}\n\n    return table_style, table_options\n\n\n@overload\ndef _xl_worksheet_in_workbook(\n    wb: Workbook, ws: Worksheet, *, return_worksheet: Literal[False] = ...\n) -> bool: ...\n@overload\ndef _xl_worksheet_in_workbook(\n    wb: Workbook, ws: Worksheet, *, return_worksheet: Literal[True]\n) -> Worksheet: ...\n","sourceCodeStart":538,"sourceCodeEnd":574,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/io/spreadsheet/_write_utils.py#L538-L574","documentation":"When table_style is given as a dict to write_excel, only a fixed set of keys (e.g. 'style', banded rows/columns, first/last_column) are valid. This ValueError fires for any unknown key, catching typos in the styling options dict.","triggerScenarios":"write_excel(table_style={'stlye': 'TableStyleMedium9'}) or any misspelled/unsupported key such as 'banded_col' instead of 'banded_columns'.","commonSituations":"Typos in style dict keys, copying options from a different library (xlsxwriter/openpyxl) that uses different key names, or version changes to valid keys.","solutions":["Check valid keys: style, banded_rows, banded_columns, first_column, last_column, row_totals, column_totals etc., and correct the key spelling.","Pass just a style name string if you only need a table style: table_style='TableStyleMedium9'.","Inspect the write_excel signature/docstring for the current accepted table_style keys in your polars version."],"exampleFix":"// before\ndf.write_excel('out.xlsx', table_style={'stlye': 'TableStyleMedium9'})\n// after\ndf.write_excel('out.xlsx', table_style={'style': 'TableStyleMedium9'})","handlingStrategy":"validation","validationCode":"VALID = {'style','banded_rows','banded_columns','first_column','last_column','row_totals','column_totals'}\nbad = set(table_style) - VALID\nassert not bad, f'unknown table_style keys: {bad}'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Copy key names from the current polars docs for your version","Prefer a plain style-name string when no extra options are needed"],"tags":["excel","polars","table-style","config"],"backgroundTag":"invalid-enum-value","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}