docling-project/docling · error · RuntimeError

expected one table for {merge_count} merges, got {len(docume

Error message

expected one table for {merge_count} merges, got {len(document.tables)}

What it means

Error "expected one table for {merge_count} merges, got {len(document.tables)}" thrown in docling-project/docling.

Source

Thrown at perfs/xlsx_merged_cells.py:149

def _run_benchmark(
    output_dir: Path,
    *,
    merge_count: int,
    runtime_info: RuntimeInfo,
) -> BenchmarkResult:
    workbook_path = output_dir / f"merged-ranges-{merge_count}.xlsx"
    generation_seconds = _create_workbook(workbook_path, merge_count=merge_count)

    tracemalloc.start()
    started = time.perf_counter()
    converter = DocumentConverter(allowed_formats=[InputFormat.XLSX])
    document = converter.convert(workbook_path).document
    conversion_seconds = time.perf_counter() - started
    _, peak_memory = tracemalloc.get_traced_memory()
    tracemalloc.stop()

    if len(document.tables) != 1:
        raise RuntimeError(
            f"expected one table for {merge_count} merges, got {len(document.tables)}"
        )
    table = document.tables[0]
    if table.data.num_rows != merge_count or table.data.num_cols != 4:
        raise RuntimeError(
            f"unexpected table dimensions: {table.data.num_rows}x{table.data.num_cols}"
        )

    return BenchmarkResult(
        python_version=runtime_info.python_version,
        platform=runtime_info.platform,
        docling_version=runtime_info.docling_version,
        commit_sha=runtime_info.commit_sha,
        merge_count=merge_count,
        non_empty_cells=merge_count * 2,
        rectangle_area=merge_count * 4,
        generation_seconds=round(generation_seconds, 6),
        conversion_seconds=round(conversion_seconds, 6),

View on GitHub (pinned to 61d76f1ff3)

Solutions

  1. Verify the generated workbook: with N merges the script creates one sheet with N rows of merged ranges; conversion is expected to yield exactly one table.
  2. Check the Docling version being benchmarked — a regression in the XLSX backend can split or drop tables; pin or bisect docling versions.
  3. Inspect the merged-ranges-N.xlsx file in the output directory with openpyxl to confirm merges were written correctly before conversion.

When it happens

Trigger: Raised by perfs/xlsx_merged_cells.py when converting the generated merged-cells XLSX yields a document whose table count is not exactly one.

Common situations: Regression in MsExcelDocumentBackend merged-cell handling, or a workbook layout that openpyxl reports in a way that splits or drops the expected single table.


AI-assisted analysis of docling-project/docling@61d76f1ff3 (2026-08-14). Data as JSON: /api/errors/8e9abc4b3860416c. Report an issue: GitHub.