This is an automated email from the ASF dual-hosted git repository.
rusackas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new c4eb7de6de8 fix(excel): remove unwanted index column from Excel
exports (#38176)
c4eb7de6de8 is described below
commit c4eb7de6de8ba5bdf927b67c87617ec3f43c90dc
Author: Evan Rusackas <[email protected]>
AuthorDate: Mon Feb 23 11:28:40 2026 -0500
fix(excel): remove unwanted index column from Excel exports (#38176)
Co-authored-by: Claude Opus 4.5 <[email protected]>
---
superset/common/query_context_processor.py | 4 +++-
tests/unit_tests/common/test_query_context_processor.py | 4 ++--
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/superset/common/query_context_processor.py
b/superset/common/query_context_processor.py
index 7106d581b78..52fc6d24f28 100644
--- a/superset/common/query_context_processor.py
+++ b/superset/common/query_context_processor.py
@@ -259,7 +259,9 @@ class QueryContextProcessor:
)
elif self._query_context.result_format ==
ChartDataResultFormat.XLSX:
excel.apply_column_types(df, coltypes)
- result = excel.df_to_excel(df,
**current_app.config["EXCEL_EXPORT"])
+ result = excel.df_to_excel(
+ df, index=include_index,
**current_app.config["EXCEL_EXPORT"]
+ )
return result or ""
return df.to_dict(orient="records")
diff --git a/tests/unit_tests/common/test_query_context_processor.py
b/tests/unit_tests/common/test_query_context_processor.py
index a1d3814a02e..3bf558072b1 100644
--- a/tests/unit_tests/common/test_query_context_processor.py
+++ b/tests/unit_tests/common/test_query_context_processor.py
@@ -126,7 +126,7 @@ def test_get_data_xlsx(
result = processor.get_data(df, coltypes)
assert result == b"binary data"
mock_apply_column_types.assert_called_once_with(df, coltypes)
- mock_df_to_excel.assert_called_once_with(df)
+ mock_df_to_excel.assert_called_once_with(df, index=False)
def test_get_data_json(processor, mock_query_context):
@@ -201,7 +201,7 @@ def test_get_data_empty_dataframe_xlsx(
result = processor.get_data(df, coltypes)
assert result == b"binary data empty"
mock_apply_column_types.assert_called_once_with(df, coltypes)
- mock_df_to_excel.assert_called_once_with(df)
+ mock_df_to_excel.assert_called_once_with(df, index=False)
def test_get_data_nan_values_json(processor, mock_query_context):