Skip to content

Commit c4eb7de

Browse files
rusackasclaude
andauthored
fix(excel): remove unwanted index column from Excel exports (apache#38176)
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 228b598 commit c4eb7de

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

superset/common/query_context_processor.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,9 @@ def get_data(
259259
)
260260
elif self._query_context.result_format == ChartDataResultFormat.XLSX:
261261
excel.apply_column_types(df, coltypes)
262-
result = excel.df_to_excel(df, **current_app.config["EXCEL_EXPORT"])
262+
result = excel.df_to_excel(
263+
df, index=include_index, **current_app.config["EXCEL_EXPORT"]
264+
)
263265
return result or ""
264266

265267
return df.to_dict(orient="records")

tests/unit_tests/common/test_query_context_processor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def test_get_data_xlsx(
126126
result = processor.get_data(df, coltypes)
127127
assert result == b"binary data"
128128
mock_apply_column_types.assert_called_once_with(df, coltypes)
129-
mock_df_to_excel.assert_called_once_with(df)
129+
mock_df_to_excel.assert_called_once_with(df, index=False)
130130

131131

132132
def test_get_data_json(processor, mock_query_context):
@@ -201,7 +201,7 @@ def test_get_data_empty_dataframe_xlsx(
201201
result = processor.get_data(df, coltypes)
202202
assert result == b"binary data empty"
203203
mock_apply_column_types.assert_called_once_with(df, coltypes)
204-
mock_df_to_excel.assert_called_once_with(df)
204+
mock_df_to_excel.assert_called_once_with(df, index=False)
205205

206206

207207
def test_get_data_nan_values_json(processor, mock_query_context):

0 commit comments

Comments
 (0)