fix(excel): remove unwanted index column from Excel exports (#38176)

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
(cherry picked from commit c4eb7de6de)
This commit is contained in:
Evan Rusackas
2026-02-23 11:28:40 -05:00
committed by Joe Li
parent 0976718c5c
commit 564ed6cd13
2 changed files with 5 additions and 3 deletions

View File

@@ -1004,7 +1004,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")

View File

@@ -85,7 +85,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):
@@ -160,7 +160,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):