{"record":{"id":"68be2426a27f7d4d","repo":"pola-rs/polars","slug":"the-table-name-parameter-is-not-supported-by-the","errorCode":null,"errorMessage":"the `table_name` parameter is not supported by the 'xlsx2csv' engine","messagePattern":"the `table_name` parameter is not supported by the 'xlsx2csv' engine","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/io/spreadsheet/functions.py","lineNumber":1317,"sourceCode":"    return df\n\n\ndef _read_spreadsheet_xlsx2csv(\n    parser: Any,\n    *,\n    sheet_name: str | None,\n    read_options: dict[str, Any],\n    schema_overrides: SchemaDict | None,\n    columns: Sequence[int] | Sequence[str] | None,\n    table_name: str | None = None,\n    drop_empty_rows: bool,\n    drop_empty_cols: bool,\n    raise_if_empty: bool,\n) -> pl.DataFrame:\n    \"\"\"Use the 'xlsx2csv' library to read data from the given worksheet.\"\"\"\n    if table_name:\n        msg = \"the `table_name` parameter is not supported by the 'xlsx2csv' engine\"\n        raise ValueError(msg)\n\n    csv_buffer = StringIO()\n    with warnings.catch_warnings():\n        # xlsx2csv version 0.8.4 throws a DeprecationWarning in Python 3.13\n        # https://github.com/dilshod/xlsx2csv/pull/287\n        warnings.filterwarnings(\"ignore\", category=DeprecationWarning)\n        parser.convert(outfile=csv_buffer, sheetname=sheet_name)\n\n    read_options.setdefault(\"truncate_ragged_lines\", True)\n    if columns:\n        read_options[\"columns\"] = columns\n\n    cast_to_boolean = []\n    if schema_overrides:\n        for col, dtype in schema_overrides.items():\n            if dtype == Boolean:\n                schema_overrides[col] = UInt8  # type: ignore[index]\n                cast_to_boolean.append(F.col(col).cast(Boolean))","sourceCodeStart":1299,"sourceCodeEnd":1335,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/io/spreadsheet/functions.py#L1299-L1335","documentation":"When reading Excel spreadsheets via `pl.read_excel`, the `table_name` parameter (which selects a named Excel table) is only implemented for the 'calamine' engine. The `_read_spreadsheet_xlsx2csv` helper raises this ValueError up front because the xlsx2csv library cannot look up named tables; passing a table name there would otherwise be silently ignored.","triggerScenarios":"Calling `pl.read_excel(..., table_name='mytable', engine='xlsx2csv')` (or with engine inferred/resolved to 'xlsx2csv') while supplying a non-None `table_name`. The check fires in `_read_spreadsheet_xlsx2csv` before any file is parsed.","commonSituations":"Following documentation or blog examples written for the default calamine engine but running with `engine='xlsx2csv'` explicitly set; inheriting an engine choice from a wrapper or older config; sharing code across environments where the default engine differs.","solutions":["Use the default 'calamine' engine, which supports `table_name`: `pl.read_excel(source, table_name='mytable')` or explicitly `engine='calamine'`.","If xlsx2csv must stay, drop `table_name` and select the sheet/region manually via `sheet_name` plus `read_options` (e.g. skip rows) or slice the resulting DataFrame.","Convert the named table's range into an explicit sheet+range read, or read the whole sheet and filter afterward.","Pin/upgrade polars so the docs and supported engines match your usage."],"exampleFix":"// before\npl.read_excel(\"data.xlsx\", table_name=\"SalesTable\", engine=\"xlsx2csv\")\n// after\npl.read_excel(\"data.xlsx\", table_name=\"SalesTable\")  # default calamine engine","handlingStrategy":"validation","validationCode":"if table_name is not None and engine == \"xlsx2csv\":\n    raise ValueError(\"use engine='calamine' with table_name\")","typeGuard":"def supports_table_name(engine: str) -> bool:\n    return engine in {\"calamine\"}","tryCatchPattern":null,"preventionTips":["Only pass table_name with the calamine engine","Omit engine to use the polars default","Keep read_excel calls and engine choices documented together"],"tags":["python","polars","excel","unsupported-parameter"],"backgroundTag":"unsupported-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"}