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

[data grid] Apostrophe added to numbers on CSV export #13790

Closed
dorpe opened this issue Jul 10, 2024 · 13 comments
Closed

[data grid] Apostrophe added to numbers on CSV export #13790

dorpe opened this issue Jul 10, 2024 · 13 comments
Labels
component: data grid This is the name of the generic UI component, not the React module! feature: Export support: premium standard Support request from a Premium standard plan user. https://mui.com/legal/technical-support-sla/

Comments

@dorpe
Copy link

dorpe commented Jul 10, 2024

Steps to reproduce

Steps:

  1. Export a table to CSV

Current behavior

When exporting to CSV, an apostrophe appears before any negative number in Excel. For example, -20 shows up as '-20. This issue occurs only for numbers with fewer than five digits.

Expected behavior

When exporting to CSV, the number should be exactly like the number in the frontend table.

Context

Export a table to CSV.

Your environment

npx @mui/envinfo
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.

Search keywords: Apostrophe adds when export
Order ID: 90144

@dorpe dorpe added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Jul 10, 2024
@arminmeh arminmeh added the component: data grid This is the name of the generic UI component, not the React module! label Jul 10, 2024
@arminmeh arminmeh changed the title Apostrophe adds when export [DataGrid] Apostrophe adds when export Jul 10, 2024
@arminmeh
Copy link
Contributor

Hello @dorpe

Thanks for reporting the issue.
Can you check the support page and provide a link to the sandbox with the issue you are mentioning?

@arminmeh arminmeh added status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jul 10, 2024
@dorpe
Copy link
Author

dorpe commented Jul 11, 2024

Hey @arminmeh
Our product is protected behind MFA, so we created this snippet. Just press on "EXPORT," and you can see that some negative numbers are exported with an apostrophe before the number (especially zeros and negative numbers up to 6 digits). For example, see rows 9, 25, and 26.

Link:
https://stackblitz.com/edit/react-rmcqtb?file=Demo.js

@github-actions github-actions bot added status: waiting for maintainer These issues haven't been looked at yet by a maintainer and removed status: waiting for author Issue with insufficient information labels Jul 11, 2024
@DanailH
Copy link
Member

DanailH commented Jul 11, 2024

This is weird. I can confirm that it also happens in Preview on Mac. It does look like a bug on our end.

@DanailH DanailH added bug 🐛 Something doesn't work feature: Export and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jul 11, 2024
@michelengelen michelengelen added the support: premium standard Support request from a Premium standard plan user. https://mui.com/legal/technical-support-sla/ label Jul 15, 2024
@michelengelen michelengelen changed the title [DataGrid] Apostrophe adds when export [data grid] Apostrophe adds when export Jul 15, 2024
@michelengelen michelengelen changed the title [data grid] Apostrophe adds when export [data grid] Apostrophe added to numbers on export Jul 15, 2024
@dorpe
Copy link
Author

dorpe commented Jul 16, 2024

Hey, team, any estimation of when it will be fixed?

@AviDuda
Copy link

AviDuda commented Jul 16, 2024

This was introduced in #13115. Wouldn't always quoting the value instead of doing this check be better, as negative values and also values starting with e.g. @ are a completely normal thing?

@jonnylink
Copy link

jonnylink commented Jul 17, 2024

License holder here asking the same. This bug has generated helpdesk issues for our team (so it's a production bug). This seems like it should be prioritized.

@arminmeh arminmeh self-assigned this Jul 18, 2024
@arminmeh
Copy link
Contributor

hey @dorpe
I see that in your example you are setting escapeFormulas to false to disable escaping.
Thing is that this should be added to the slotProps rather to slots to be picked up by the toolbar.

So, instead of

slots={{
  toolbar: {
    ...GridToolbar,
    csvOptions: {
      escapeFormulas: false,
    },
  },
}}

have

slots={{
  toolbar: GridToolbar,
}}
slotProps={{
  toolbar: {
    csvOptions: {
      escapeFormulas: false,
    },
  },
}}

After that, exports should be generated as you expect.

If the expectation is that the exception should be made in processing of the negative numbers even when escapeFormulas is true I can keep the issue open, but then it will be treated as an improvement rather than a bug since the way it is working now is described here

@arminmeh arminmeh removed their assignment Jul 18, 2024
@arminmeh arminmeh added the status: waiting for author Issue with insufficient information label Jul 18, 2024
@dorpe
Copy link
Author

dorpe commented Jul 18, 2024

Thank you, everyone. The issue has been resolved.

@github-actions github-actions bot added status: waiting for maintainer These issues haven't been looked at yet by a maintainer and removed status: waiting for author Issue with insufficient information labels Jul 18, 2024
@arminmeh
Copy link
Contributor

Thanks for the fast response.
I will close this issue then.

If the change that I have posted does not work out for other people that have facing the same issue, feel free to re-open the issue with the additional info.

@arminmeh arminmeh removed bug 🐛 Something doesn't work status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jul 18, 2024
Copy link

⚠️ This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

@dorpe: How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey.

@jonnylink
Copy link

jonnylink commented Jul 18, 2024

Please re-open.

We do not have this setting and are experiencing the same issue.
Also, it's definitely not intended behavior for a misplaced setting to cause an issue like this, so it should be fixed.

EDIT: I suspect the exact same change is causing this issue and that there are likely many undiscovered avenues to reach this bug. Please fix the root cause.

@arminmeh
Copy link
Contributor

arminmeh commented Jul 18, 2024

@jonnylink
change happened because escaping was introduced and has been turned on by default (check the PR comment)
@cherniavskii we have probably missed to announce it better in v7.5.1 release notes

@jonnylink
Copy link

Got it! Thank you for the clarification.

@arminmeh arminmeh changed the title [data grid] Apostrophe added to numbers on export [data grid] Apostrophe added to numbers on CSV export Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: data grid This is the name of the generic UI component, not the React module! feature: Export support: premium standard Support request from a Premium standard plan user. https://mui.com/legal/technical-support-sla/
Projects
None yet
Development

No branches or pull requests

6 participants