-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[DataGrid] Handle special chars when doing CSV export #1154
[DataGrid] Handle special chars when doing CSV export #1154
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- How about we add a test case that reproduce the issue? I think that we can test the function in isolatation. No need to mount the grid component.
- What happens if there a double quote in the cell we are exporting? See http://www.creativyst.com/Doc/Articles/CSV/CSV01.htm#FileFormat
- Should we only add the " if there is a comma in order to save space in the CSV export?
packages/grid/_modules_/grid/hooks/features/export/seralizers/csvSeraliser.ts
Outdated
Show resolved
Hide resolved
packages/grid/_modules_/grid/hooks/features/export/seralizers/csvSeraliser.ts
Outdated
Show resolved
Hide resolved
899537a
to
2f067a1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding the tests, I think that we can improve them:
- Only test the CSV exporter without the data grid. We will need to the same for the Excel exported.
- Cover edge cases you have considered but aren't tested. e.g.
"
inside the value of one cell.
What do you think?
packages/grid/_modules_/grid/hooks/features/export/seralizers/csvSeraliser.ts
Outdated
Show resolved
Hide resolved
…taGrid-1143-wrong-csv-parcer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Things I would have done differently if I was working on this:
- In the tests, I would have used 2-dimensional data. Note one row, nor one column, but at least two columns and rows.
- I would have split the problem into two phases. One phase about constructing the 2d data structure for export. And a second phase to convert this 2d structure into a CSV. Hopefully, this would bring two values. I suspect that the first phase would be shared with the Excel export. I also assume that it would allow, in the future to write unit tests that run much faster for covering more formatting edge-cases and more formating options, like custom delimiters.
packages/grid/_modules_/grid/hooks/features/export/seralizers/csvSeraliser.ts
Outdated
Show resolved
Hide resolved
I started using mui x datagrid well after this was merged (end of 2023) and I still see the issue... I'm just curious what is the best way to check if the commit is in the version of mui x I'm using? |
On |
hmm, nevermind, I found it by searching for the content of the commit: commit 82f3d84
wonder why it isn't working -- we're still seeing screwed up exports when we have values with commas in them |
Fixes #1143