Skip to content

export chart to excel file with date type column (postgresql) failed  #23584

@armgong

Description

@armgong

A clear and concise description of what the bug is.

How to reproduce the bug

  1. Go to 'new chart'
  2. Click on 'time series line chart'
  3. make a new chart with date type (postgresql) and save
  4. click on "download "->“download to excel” on the new chart
  5. See error
    `2023-04-05 15:53:44,081:ERROR:superset.views.base:Excel does not support datetimes with timezones. Please ensure that datetimes are timezone unaware before writing to Excel.

Expected results

should be export excel with date type colume

Actual results

2023-04-05 15:53:44,081:ERROR:superset.views.base:Excel does not support datetimes with timezones. Please ensure that datetimes are timezone unaware before writing to Excel.

Environment

  • superset version: superset 2.1.0
  • python version: 3.9.13

Additional context

now superset use pandas to export excel files in util/excel.py. IMO, maybe we should remove timezone info from date types column or convert the column to string for success export excel file.
``
def df_to_excel(df: pd.DataFrame, **kwargs: Any) -> Any:
output = io.BytesIO()
# pylint: disable=abstract-class-instantiated
with pd.ExcelWriter(output, engine="xlsxwriter") as writer:
df.to_excel(writer, **kwargs)

return output.getvalue()

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions