Skip to content

Datatype not correctly exported to xlsx - with patch suggestion #23375

@squalou

Description

@squalou

Seen this when exporting to xslx. Some numeric fields ends up as numeric format, some ends as strings. It may depend on column but I did not find a logical pattern.

How to reproduce the bug

  1. Create a dataset based on a table including some numeric decimal fields
  2. Create custom metrics in this dataset (for instance CAST(SUM(my_column) AS DECIMAL 9,2))
  3. Create a table chart based on this dataset, include fields, add the custom metric as aggregate function
  4. Click on Download / Export to Xlsx
  5. Open the xlsx : at least the column obtained from the custom metric will be considered as string
  6. ... some other columns (shown with '#' type in superset UI) sometimes end up as string too

Expected results

Ideally I'd like to have

  • numeric data column end up as numeric
  • keep date data as dates, not converted to numeric
  • be able to set Metric datatype, and have them as numeric in the end

Actual results

some values are string.

Screenshots

a custom metric
image

some data in superset
image

result after export

image

Due to fr locale it's easy to see the numerci fields : they have 'commas' in them. (and string are left aligned)

Environment

(please complete the following information):

  • browser type and version: Firefox 110
  • superset version: superset version : 2.1.0-rc2
  • python version: python --version : 3.8.16
  • node.js version: node -v :
  • any feature flags active: none

Checklist

Make sure to follow these steps before submitting your issue - thank you!

  • I have checked the superset logs for python stacktraces and included it here as text if there are any.
  • I have reproduced the issue with at least the latest released version of superset.
  • I have checked the issue tracker for the same issue and I haven't found one similar.

Additional context

I tried to play around with EXCEL_EXPORT config according to padans documentation, but there's no solution here.

I extracted sheet.xml from the exported xlsx to double check that some fields are indeed noted as strings ("s"), and some other contain numeric value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    #bugBug report

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions