Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

fix(excel): drop the "None" label for a blank spreadsheet header cell (#19175)

MarMar Labs1455cdfadcdf
diff --git a/deepdoc/parser/excel_parser.py b/deepdoc/parser/excel_parser.py
index e329017a91..5a9c908f40 100644
--- a/deepdoc/parser/excel_parser.py
+++ b/deepdoc/parser/excel_parser.py
@@ -303,7 +303,9 @@ class RAGFlowExcelParser:
col = i + 1
col_min = col if col_min is None else min(col_min, col)
col_max = col if col_max is None else max(col_max, col)
- t = str(ti[i].value) if i < len(ti) else ""
+ # A blank header cell is not a label: str(None) is "None", which is truthy,
+ # so it defeats the separator guard below and lands "None:" in the chunk text.
+ t = str(ti[i].value) if i < len(ti) and ti[i].value is not None else ""
t += (":" if t else "") + str(c.value)
fields.append(t)
if not fields:
diff --git a/test/unit_test/deepdoc/parser/test_excel_parser.py b/test/unit_test/deepdoc/parser/test_excel_parser.py
index c91c69cad7..c3768ec4f4 100644
--- a/test/unit_test/deepdoc/parser/test_excel_parser.py
+++ b/test/unit_test/deepdoc/parser/test_excel_parser.py
@@ -148,6 +148,25 @@ def test_call_keeps_zero_valued_cells():
assert lines[0][1][1] == 2
+def test_call_omits_a_blank_header_instead_of_labelling_it_none():
+ # A blank header cell has no label to give. str(None) is "None", which is
+ # truthy, so it defeats the separator guard and the literal token "None" is
+ # indexed and shown alongside the value it pretends to describe.
+ lines = RAGFlowExcelParser()(_make_xlsx_with_values(["name", None, "city"], ["widget", "note-1", "paris"]))
+ joined = " ".join(text for text, _ in lines)
+ assert joined == "name:widget; note-1; city:paris", lines
+
+
+def test_call_keeps_a_zero_header():
+ # Guards the tempting shorter fix, str(ti[i].value or ""), which would drop
+ # a numeric 0 header the same way it drops a None one. 0 is a real label.
+ lines = RAGFlowExcelParser()(_make_xlsx_with_values(["name", 0], ["widget", "note-1"]))
+ joined = " ".join(text for text, _ in lines)
+ assert "0:note-1" in joined, lines
+
+
@pytest.mark.p2
def test_call_skips_truly_empty_cells():
# None / empty-string cells carry no value and should still be skipped.