{"record":{"id":"905b03a0740588bd","repo":"pola-rs/polars","slug":"no-named-tables-found-in-sheet-sheet-name-r-loo","errorCode":null,"errorMessage":"no named tables found in sheet {sheet_name!r} (looking for {table_name!r})","messagePattern":"no named tables found in sheet (.+?) \\(looking for (.+?)\\)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/io/spreadsheet/functions.py","lineNumber":1242,"sourceCode":"        ws = parser[sheet_name]\n\n    # prefer detection of actual table objects; otherwise read\n    # data in the used worksheet range, dropping null columns\n    if tables := getattr(ws, \"tables\", None):\n        table = tables[table_name] if table_name else next(iter(tables.values()))\n        rows = list(ws[table.ref])\n        if not rows:\n            return _empty_frame(raise_if_empty)\n        if has_header:\n            header.extend(cell.value for cell in rows.pop(0))\n        else:\n            header.extend(f\"column_{n}\" for n in range(len(rows[0])))\n        if table.totalsRowCount:\n            rows = rows[: -table.totalsRowCount]\n        rows_iter = rows\n    elif table_name:\n        msg = f\"no named tables found in sheet {sheet_name!r} (looking for {table_name!r})\"\n        raise RuntimeError(msg)\n    else:\n        if not has_header:\n            if not (rows_iter := list(ws.iter_rows())):\n                return _empty_frame(raise_if_empty)\n            n_cols = len(rows_iter[0])\n            header = [f\"column_{n}\" for n in range(n_cols)]\n        else:\n            rows_iter = ws.iter_rows()\n            for row in rows_iter:\n                row_values = [cell.value for cell in row]\n                if any(v is not None for v in row_values):\n                    header.extend(row_values)\n                    break\n\n    dtype = String if no_inference else None\n    series_data = []\n    for name, column_data in zip(header, zip(*rows_iter, strict=False), strict=False):\n        if name or not drop_empty_cols:","sourceCodeStart":1224,"sourceCodeEnd":1260,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/io/spreadsheet/functions.py#L1224-L1260","documentation":"When reading with the openpyxl engine and `table_name` is given, if the worksheet exposes no table objects at all, polars raises this RuntimeError saying no named tables exist in the sheet (while naming the table that was being looked for). The sheet contains plain cell data, not a formal Excel table.","triggerScenarios":"`pl.read_excel('f.xlsx', engine='openpyxl', table_name='Table1', sheet_name='Data')` where `ws.tables` is empty/None — the data range was never defined as an Excel table.","commonSituations":"Sheets that are plain ranges with headers; CSV-derived xlsx files; assuming any header block counts as a 'table'; receiving workbooks from systems that don't create table objects.","solutions":["Drop `table_name` and read the sheet's used range directly: pl.read_excel('f.xlsx', sheet_name='Data').","Or define a named table in Excel (select range > Insert > Table) and re-save.","Or use the calamine engine with table_name after upgrading fastexcel>=0.12, once a real table exists."],"exampleFix":"// before\npl.read_excel('f.xlsx', engine='openpyxl', sheet_name='Data', table_name='Sales')\n// after\npl.read_excel('f.xlsx', engine='openpyxl', sheet_name='Data')  # no named table exists; read used range","handlingStrategy":"validation","validationCode":"import openpyxl\nws = openpyxl.load_workbook(path)[sheet_name]\nif not getattr(ws, 'tables', None):\n    # no named tables: read the used range instead\n    df = pl.read_excel(path, engine='openpyxl', sheet_name=sheet_name)","typeGuard":null,"tryCatchPattern":"try:\n    df = pl.read_excel(path, engine='openpyxl', table_name=table_name, sheet_name=sheet_name)\nexcept RuntimeError as e:\n    if 'no named tables found' in str(e):\n        df = pl.read_excel(path, engine='openpyxl', sheet_name=sheet_name)\n    else:\n        raise","preventionTips":["Only use table_name when the workbook genuinely defines Excel tables","Default to plain sheet reads for CSV-derived or machine-generated workbooks","Ask workbook authors to Insert > Table if structured table access is required"],"tags":["polars","excel","openpyxl","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"}