{"record":{"id":"d6ad0918cfcd3f0a","repo":"pola-rs/polars","slug":"table-named-table-name-r-not-found-in-sheet-she","errorCode":null,"errorMessage":"table named {table_name!r} not found in sheet {sheet_name!r}","messagePattern":"table named (.+?) not found in sheet (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/io/spreadsheet/functions.py","lineNumber":1103,"sourceCode":"                elif base_dtype == Boolean:\n                    parser_dtypes[name] = \"boolean\"\n\n        read_options[\"dtypes\"] = parser_dtypes\n\n    if fastexcel_version < (0, 11, 2):\n        ws = parser.load_sheet_by_name(name=sheet_name, **read_options)\n        df: pl.DataFrame = ws.to_polars()\n    else:\n        if table_name:\n            if col_names := read_options.get(\"use_columns\"):\n                selected_col_names = set(col_names)\n                read_options[\"use_columns\"] = lambda col: col.name in selected_col_names\n\n            xl_table = parser.load_table(table_name, **read_options)\n\n            if sheet_name and sheet_name != xl_table.sheet_name:\n                msg = f\"table named {table_name!r} not found in sheet {sheet_name!r}\"\n                raise RuntimeError(msg)\n            df = xl_table.to_polars()\n\n        elif _PYARROW_AVAILABLE:\n            # eager loading is faster / more memory-efficient, but requires pyarrow\n            ws_arrow = parser.load_sheet_eager(sheet_name, **read_options)\n            df = cast(\"pl.DataFrame\", from_arrow(ws_arrow))\n        else:\n            ws_arrow = parser.load_sheet(sheet_name, **read_options)\n            df = cast(\"pl.DataFrame\", from_arrow(ws_arrow))\n\n        if read_options.get(\"header_row\", False) is None and not read_options.get(\n            \"column_names\"\n        ):\n            df.columns = [f\"column_{i}\" for i in range(df.width)]\n\n    df = _drop_null_data(\n        df,\n        raise_if_empty=raise_if_empty,","sourceCodeStart":1085,"sourceCodeEnd":1121,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/io/spreadsheet/functions.py#L1085-L1121","documentation":"With the calamine engine, `load_table` looks up the named table workbook-wide; if the resolved table's sheet differs from the requested `sheet_name`, polars raises this RuntimeError because the table named `table_name` does not exist within that specific sheet. The table name may exist elsewhere in the workbook.","triggerScenarios":"`pl.read_excel('f.xlsx', engine='calamine', table_name='Table1', sheet_name='Sheet2')` where Table1 actually lives on Sheet1; passing a sheet_name that doesn't match the table's parent sheet.","commonSituations":"Assuming table names are global; workbook reorganized so tables moved sheets; copy-pasted sheet_name from a different workbook version.","solutions":["Remove `sheet_name` (or pass the table's actual sheet) so the table is located on its own sheet.","List available tables per sheet (openpyxl: ws.tables) to find where the table lives.","Verify the exact table name and its sheet in Excel (Formulas > Name Manager)."],"exampleFix":"// before\npl.read_excel('f.xlsx', engine='calamine', table_name='SalesTable', sheet_name='Raw')\n// after\npl.read_excel('f.xlsx', engine='calamine', table_name='SalesTable')  # or sheet_name='Data' where the table lives","handlingStrategy":"validation","validationCode":"import openpyxl\nwb = openpyxl.load_workbook(path, read_only=False)\nfound = [(s, t) for s in wb.sheetnames for t in wb[s].tables]\nif (sheet_name, table_name) not in found:\n    raise ValueError(f'{table_name!r} not on {sheet_name!r}; available: {found}')","typeGuard":null,"tryCatchPattern":"try:\n    df = pl.read_excel(path, engine='calamine', table_name=table_name, sheet_name=sheet_name)\nexcept RuntimeError as e:\n    if 'not found in sheet' in str(e):\n        df = pl.read_excel(path, engine='calamine', table_name=table_name)  # search workbook-wide\n    else:\n        raise","preventionTips":["Discover table->sheet mapping with openpyxl before reading","Omit sheet_name when the table name is unique in the workbook","Verify table locations in Excel's Name Manager"],"tags":["polars","excel","table-not-found"],"backgroundTag":"resource-not-found","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"}