XLSX conversion loses Excel error values such as #DIV/0! and #REF!

未关闭
#2,728 0 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@sunxiuguo 已经在做这个了。

开始于 2026年10月21日。

  • #2732 来自 @sunxiuguo —— 未关闭
  • #2766 来自 @dpka2206 —— 未关闭
  • #2869 来自 @wangkangmao —— 未关闭
  • #2898 来自 @poojithparchuri-iiitk —— 未关闭

评估

难度
3/5
预计耗时
1-2 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
pandas, python
领域
backend, data

调研方向

Start by tracing the built-in XLSX converter's pandas/openpyxl read path; the report shows the error value is lost during pandas' openpyxl cell conversion, before HTML or Markdown rendering. Use the reproduction in the issue to compare error-typed and text-typed cells and check the saved error tokens in the output. Done means each saved Excel error token is retained while a genuinely blank cell remains distinguishable; pull request #2732 is already open.

由索引模型根据 Issue 内容生成。

描述

The built-in XLSX converter replaces Excel error cells with NaN, losing which calculation failed. For example, #DIV/0!, #REF!, and #VALUE! all become indistinguishable from a blank cell. This affects saved error values; reproducing it does not require evaluating formulas.

Reproduced on current main at 69e208746aa5804087e9984d585eab21667e9b0f, using Python 3.12.15, pandas 3.0.6, openpyxl 3.1.5, and MarkItDown 0.1.8 on macOS:

import io
from openpyxl import Workbook, load_workbook
from markitdown import MarkItDown, StreamInfo

workbook = Workbook()
sheet = workbook.active
sheet.title = "Results"
sheet.append(["Case", "Result"])
sheet.append(["Valid value", 42])
for error in ("#DIV/0!", "#REF!", "#VALUE!", "#N/A", "#NUM!", "#NAME?", "#NULL!"):
    sheet.append(["Error " + str(sheet.max_row), error])
sheet.append(["Blank", None])
source = io.BytesIO()
workbook.save(source)
workbook.close()
source.seek(0)
loaded = load_workbook(source, data_only=True)
assert loaded.active["B3"].value == "#DIV/0!"
assert loaded.active["B3"].data_type == "e"
loaded.close()
source.seek(0)
result = MarkItDown(enable_plugins=False).convert_stream(
    source, stream_info=StreamInfo(extension=".xlsx")
)
print(result.markdown)
assert "#DIV/0!" in result.markdown

The assertion fails. Actual output:

## Results
| Case | Result |
| --- | --- |
| Valid value | 42.0 |
| Error 2 | NaN |
| Error 3 | NaN |
| Error 4 | NaN |
| Error 5 | NaN |
| Error 6 | NaN |
| Error 7 | NaN |
| Error 8 | NaN |
| Blank | NaN |

Expected: retain each saved error token in its corresponding cell, so readers can distinguish invalid references, division by zero, other errors, and missing data.

This is distinct from #2498 / #2499, which concern literal text recognized as missing. In a separate workbook containing an error-typed #DIV/0! cell and a text-typed #DIV/0! cell, pd.read_excel(..., dtype=object, keep_default_na=False) still returns NaN for the error cell while preserving the text cell. The error value is lost during pandas' openpyxl cell conversion, before HTML/Markdown rendering. No fix is included here.

主要语言
Python
星标
198k
派生
15k
平均合并
2 小时 16 分钟
30 天内合并 PR
9

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

microsoft/markitdown 的其他 Issue

查看 microsoft/markitdown 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。