RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
Feat: add cell type coercion for Excel export (#13808)
天海蒼灆356d45fda1c6
diff --git a/agent/component/message.py b/agent/component/message.pyindex 7f9a9d328c..c589a55373 100644--- a/agent/component/message.py+++ b/agent/component/message.py@@ -226,6 +226,38 @@ class Message(ComponentBase):rows = []headers = None++ def _coerce_excel_cell_type(cell: str):+ # Convert markdown cell text to native numeric types when safe,so Excel writes numeric cells instead of text.+ if not isinstance(cell, str):+ return cell++ value = cell.strip()+ if value == "":+ return ""++ # Keep values like "00123" as text to avoid losing leading zeros.+ if re.match(r"^[+-]?0\d+$", value):+ return cell++ # Support thousand separators like 1,234 or 1,234.56+ numeric_candidate = value+ if re.match(r"^[+-]?\d{1,3}(,\d{3})+(\.\d+)?$", value):+ numeric_candidate = value.replace(",", "")++ if re.match(r"^[+-]?\d+$", numeric_candidate):+ try:+ return int(numeric_candidate)+ except ValueError:+ return cell++ if re.match(r"^[+-]?(\d+\.\d+|\d+\.|\.\d+)([eE][+-]?\d+)?$", numeric_candidate) or re.match(r"^[+-]?\d+[eE][+-]?\d+$", numeric_candidate):+ try:+ return float(numeric_candidate)+ except ValueError:+ return cell++ return cellfor line in table_lines:# Split by | and clean up@@ -236,6 +268,7 @@ class Message(ComponentBase):if headers is None:headers = cellselse:+ cells = [_coerce_excel_cell_type(c) for c in cells]rows.append(cells)if headers and rows: