#13041·haystack

XLSXToDocument assigns hyperlinks to the wrong cells with skiprows or usecols

Author: Harsh23KashyapCreated Sep 30, 2026Updated Sep 30, 2026

Describe the bug

XLSXToDocument can attach a cell's hyperlink to another cell when read_excel_kwargs includes skiprows or usecols. Conversion succeeds, but the resulting document pairs the wrong text and URL. This can give indexed spreadsheet data a false source link.

The converter reads hyperlinks at their original Excel coordinates, then uses those coordinates as positions in the filtered pandas DataFrame. Dropping rows or columns changes those positions.

Reproduction

python
from io import BytesIO
from openpyxl import Workbook
from haystack.components.converters import XLSXToDocument
from haystack.dataclasses import ByteStream

workbook = Workbook()
sheet = workbook.active
sheet.append(["Heading", "HeadingB"])
sheet.append(["Alice", "Bob"])
sheet.append(["Carol", "Dave"])
sheet["A2"].hyperlink = "https://example.com/alice"
sheet["B2"].hyperlink = "https://example.com/bob"
buffer = BytesIO()
workbook.save(buffer)
workbook.close()

for kwargs in ({}, {"skiprows": 1}, {"usecols": "B"}):
    documents = XLSXToDocument(
        link_format="markdown", read_excel_kwargs=kwargs
    ).run(sources=[ByteStream(data=buffer.getvalue())])["documents"]
    print(kwargs, documents[0].content)

With no filtering, the output links Alice to /alice and Bob to /bob, as expected.

With skiprows=1, the output is:

csv
,A,B
1,Alice,Bob
2,[Carol](https://example.com/alice),[Dave](https://example.com/bob)

Alice and Bob lose their links, and Carol and Dave receive them instead.

With usecols="B", the output is:

csv
,A
1,HeadingB
2,[Bob](https://example.com/alice)
3,Dave

Bob receives Alice's link; Bob's own link is dropped.

Expected behavior

Links should stay with their original cells after row or column selection. skiprows=1 should retain Alice's and Bob's links on the first output row. usecols="B" should retain Bob's link to /bob and exclude Alice's link.

Environment

Reproduced twice with pandas 3.0.6 and openpyxl 3.1.5. The converter source matches current main at 0499239e66f515feab503a2768ba785cace6de91.

I can prepare a draft PR with regression tests if this approach fits the intended behavior.