#2664·agentscope

[Bug]: ExcelParser drops image-only and single-row worksheets

Author: yang0228Created Sep 16, 2026Updated Sep 16, 2026

Prerequisites

  • I searched existing issues, pull requests, and discussions and did not find this bug reported.
  • This is a bug, not a usage question.

Background / Description

ExcelParser silently drops worksheets containing only an embedded image, even with include_image=True. It also drops a worksheet containing a single populated row: pandas treats that row as column headers, so the DataFrame has columns but zero data rows.

Expected: image-only worksheets produce image sections when enabled; a single populated row remains present in the rendered table. Truly blank worksheets should still produce no sections.

Actual: both cases return [], with no warning. Adding a second populated row makes both table and image extraction work.

Error Messages

There is no exception. The reproduction prints:

image-only []
single-row []
table-and-image ['text', 'data']

Expected section types are ['data'], ['text'], and ['text', 'data'], respectively.

Steps to Reproduce

Install agentscope, pandas, openpyxl, and Pillow, then run:

python
import asyncio
import io

from openpyxl import Workbook
from openpyxl.drawing.image import Image as XLImage
from PIL import Image

from agentscope.rag import ExcelParser


async def main():
    for case in ("image-only", "single-row", "table-and-image"):
        workbook = Workbook()
        sheet = workbook.active
        if case != "image-only":
            sheet.append(["Revenue", "Year"])
        if case == "table-and-image":
            sheet.append([100, 2026])
        if case != "single-row":
            png = io.BytesIO()
            Image.new("RGB", (2, 2), "red").save(png, format="PNG")
            png.seek(0)
            sheet.add_image(XLImage(png), "A3")
        output = io.BytesIO()
        workbook.save(output)
        workbook.close()
        sections = await ExcelParser(include_image=True).parse(
            output.getvalue(), "example.xlsx"
        )
        print(case, [section.content.type for section in sections])


asyncio.run(main())

Environment

  • AgentScope: 2.0.8, reproduced on main at 3ae8a1f4eca2dec6a519753e0c1f0e76ef83731f
  • Python: 3.12.13
  • OS: macOS
  • pandas: 3.0.5; openpyxl: 3.1.5; Pillow: 12.3.0

Root Cause / Proposed Fix

ExcelParser._parse_sheet returns immediately when df.empty is true, before image extraction. That condition also excludes header-only DataFrames.

I would like to contribute a focused fix: render tables when columns exist, and extract images independently of whether there are data rows. Simply deleting the empty check would risk emitting a meaningless table for genuinely blank sheets, so those should remain excluded. Regression coverage will include Markdown/JSON, merged/separate sheets, and include_image=False. No public API or dependency changes are needed.

Source: agentscope-ai/agentscope