Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
armgong opened this issue Apr 5, 2023 · 1 comment · Fixed by #25318
Closed

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

armgong opened this issue Apr 5, 2023 · 1 comment · Fixed by #25318
Assignees
Labels

Comments

@armgong
Copy link

armgong commented Apr 5, 2023

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()

@armgong armgong added the #bug Bug report label Apr 5, 2023
@yousoph
Copy link
Member

yousoph commented Jun 23, 2023

I've seen this with specifically the datetime with timezone column type. The CSV export works and casting the column to a datetime without timezone also works as a workaround

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants