docling-project / docling-project/docling

[Bee] Excel backend duplicates cells of a sparse table as extra tables

Open
#4,230 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
66.4k
Forks
4.8k
Avg merge
2d 21h
Merged PRs (30d)
84

Description

### Bug

When a worksheet has a single table with empty cells, non-empty cells that are not directly adjacent to the rest of the table (e.g. a column whose first value has an empty cell above it) are exported twice: once inside the main table, and again as a separate small table.

Minimal sheet (`sparse_sheet.xlsx`): [sparse_sheet.xlsx](https://github.com/user-attachments/files/32133418/sparse_sheet.xlsx)

Expected: 1 table of shape (4, 3).
Actual: 2 tables, shapes `[(4, 3), (2, 1)]`. Markdown export:

```
| ID | Name | Note |
|------|--------|--------|
| 1 | alpha | |
| 2 | | foo |
| 3 | | bar |

| foo |
|-------|
| bar |
```

`foo`/`bar` already appear in the first table and are repeated as a standalone table. On real sparse sheets (e.g. ~100-column exports) this produces many such duplicate fragment tables.

### Steps to reproduce

Attached: `sparse_sheet.xlsx` and the code:

```python
from pathlib import Path
from docling.document_converter import DocumentConverter

xlsx = Path("sparse_sheet.xlsx")
doc = DocumentConverter().convert(xlsx).document
xlsx.with_suffix(".md").write_text(doc.export_to_markdown())

shapes = [(t.data.num_rows, t.data.num_cols) for t in doc.tables]
print(f"actual: {len(doc.tables)} tables of shapes {shapes}")
assert shapes == [(4, 3)]
```

Output:

```
actual: 2 tables of shapes [(4, 3), (2, 1)]
AssertionError
```

### Docling version

```
Docling version: 2.110.0
Docling Core version: 2.91.0
Docling IBM Models version: 3.14.0
```

### Python version

```
Python 3.12.12
```

Contributor guide

Open the contributing guide

Research direction

Start with the attached sparse_sheet.xlsx and the DocumentConverter reproduction shown in the issue, then trace the Bee Excel backend while inspecting how doc.tables are assembled. Confirm the current result has shapes [(4, 3), (2, 1)]; done means the sparse sheet produces one table of shape (4, 3) and no duplicated fragment in Markdown export.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.