This is an automated email from the ASF dual-hosted git repository.

rusackas pushed a commit to branch fix-excel-export-index
in repository https://gitbox.apache.org/repos/asf/superset.git

commit adb3a7f779a4dd35b535dad0639d1af1b4f79aa0
Author: Evan Rusackas <[email protected]>
AuthorDate: Sun Feb 22 20:47:13 2026 -0800

    fix(excel): remove unwanted index column from Excel exports
    
    The Excel export was including an unwanted index column because
    `df.to_excel()` defaults to `index=True`. CSV export already handled
    this correctly by passing `index=include_index`.
    
    This fix applies the same logic to Excel exports: only include the
    index column if the DataFrame has a custom index (not a RangeIndex).
    
    Closes #32113
    
    Co-Authored-By: Claude Opus 4.5 <[email protected]>
---
 superset/common/query_context_processor.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

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")

Reply via email to