firecrawl / firecrawl/anydoc

Expose worksheet identity and source coordinates in to_document()

Open
#10 0 comments 0 reactions 0 assignees View on GitHub
enhancement P2
Dominant language
Rust
Stars
21.5k
Forks
1.3k
Avg merge
42m
Merged PRs (30d)
17

Description

## Summary

`to_document()` loses both the source range origin and, for single-sheet workbooks, the worksheet name.

As a result, a caller cannot determine that a returned table cell came from `C3` on a sheet named `Data Sheet`; it appears as cell `[0][0]` in an anonymous table.

## Reproduction

Tested with `firecrawl-anydoc==0.1.2` and `openpyxl==3.1.5`.

```python
from pathlib import Path

import anydoc
from openpyxl import Workbook

path = Path("source-origin.xlsx")

workbook = Workbook()
sheet = workbook.active
sheet.title = "Data Sheet"
sheet["C3"] = "Only value"
workbook.save(path)

document = anydoc.to_document(path.read_bytes())
table = next(block.table for block in document.blocks if block.table is not None)

print([block.kind for block in document.blocks])
print(len(table.grid), len(table.grid[0]))
print([name for name in dir(table) if not name.startswith("_")])
print(anydoc.to_markdown(path))
```

## Observed

```text
['table']
1 1
['grid', 'header_rows', 'kind']
| |
| --- |
| Only value |
```

The crop itself is useful, but neither the table nor its surrounding blocks expose the source origin `(row=2, column=2)` / `C3`. Because the workbook has only one sheet, no heading or other block carries the worksheet name either.

Multi-sheet workbooks do emit sheet-name headings, so worksheet identity currently depends on how many sheets the workbook contains.

## Expected

The structured document model should preserve worksheet identity and source coordinates independently of Markdown rendering.

For example, a table or worksheet wrapper could expose `sheet_name` and a source range such as `C3:C3` (or zero-based row/column offsets). This would retain the benefits of cropping while allowing callers to map returned cells back to the workbook.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing the anydoc.to_document() entry point and the structured table model shown in the reproduction. Inspect how single-sheet and multi-sheet workbook handling currently preserve worksheet information and how cropped cell ranges are represented. Done means callers can obtain worksheet identity and source coordinates from the structured document independently of Markdown rendering.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, rust
Domain
backend-api-design
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.