Skip to content

Commit

Permalink
Remove excel logic from legacy API
Browse files Browse the repository at this point in the history
  • Loading branch information
EugeneTorap committed Jan 27, 2023
1 parent 8a18b98 commit 4c98433
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 16 deletions.
7 changes: 0 additions & 7 deletions superset/views/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@
json_errors_response,
json_success,
validate_sqlatable,
XlsxResponse,
)
from superset.views.log.dao import LogDAO
from superset.views.sql_lab.schemas import SqlJsonPayloadSchema
Expand Down Expand Up @@ -488,12 +487,6 @@ def generate_json(
viz_obj.get_csv(), headers=generate_download_headers("csv")
)

if response_type == ChartDataResultFormat.XLSX:
return XlsxResponse(
viz_obj.get_excel(ChartDataResultFormat(response_type)),
headers=generate_download_headers("xlsx"),
)

if response_type == ChartDataResultType.QUERY:
return self.get_query_string_response(viz_obj)

Expand Down
10 changes: 1 addition & 9 deletions superset/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
from pandas.tseries.frequencies import to_offset

from superset import app
from superset.common.chart_data import ChartDataResultFormat
from superset.common.db_query_status import QueryStatus
from superset.constants import NULL_STRING
from superset.errors import ErrorLevel, SupersetError, SupersetErrorType
Expand All @@ -77,7 +76,7 @@
VizData,
VizPayload,
)
from superset.utils import core as utils, csv, excel
from superset.utils import core as utils, csv
from superset.utils.cache import set_and_log_cache
from superset.utils.core import (
apply_max_row_limit,
Expand Down Expand Up @@ -671,13 +670,6 @@ def get_csv(self) -> Optional[str]:
include_index = not isinstance(df.index, pd.RangeIndex)
return csv.df_to_escaped_csv(df, index=include_index, **config["CSV_EXPORT"])

def get_excel(self, excel_format: ChartDataResultFormat) -> Optional[bytes]:
df = self.get_df_payload()["df"]
include_index = not isinstance(df.index, pd.RangeIndex)
return excel.df_to_excel(
df, index=include_index, excel_format=excel_format, **config["EXCEL_EXPORT"]
)

def get_data(self, df: pd.DataFrame) -> VizData: # pylint: disable=no-self-use
return df.to_dict(orient="records")

Expand Down

0 comments on commit 4c98433

Please sign in to comment.