sadpandajoe commented on code in PR #45407:
URL: https://github.com/apache/superset/pull/45407#discussion_r4345868316


##########
tests/unit_tests/utils/excel_tests.py:
##########
@@ -80,6 +80,28 @@ def test_quote_formulas() -> None:
     ]
 
 
+def test_quote_formulas_with_leading_whitespace() -> None:
+    """
+    Formulas are quoted even when a space, tab, or newline comes first.
+
+    Spreadsheet apps still evaluate a cell whose formula prefix is preceded by
+    whitespace, so the guard must strip before inspecting the first character.
+    The streaming writer (``excel_streaming``) and the CSV writer already do
+    this; this keeps the chart XLSX path in line.
+    """
+    df = pd.DataFrame(
+        {"formula": [" =1+1", "\t=1+1", "\n=1+1", "  @SUM(A1)", "normal"]}

Review Comment:
   None of these inputs makes `lstrip()` return an empty string, so the 
`stripped and` guard in `_quote_formula` is untested. If that guard were 
dropped, this test would still pass but exporting a whitespace-only cell like 
`" \t\n"` would raise `IndexError` on `stripped[0]`. Could you add a direct 
`quote_formulas` assertion that `["", " \t\n"]` come back unchanged (not 
through an Excel round-trip, since blank cells read back as missing)?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to