mirror of
https://github.com/apache/superset.git
synced 2026-05-06 16:34:32 +00:00
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:
@@ -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")
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user