-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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] Make the CSV export respect the valueFormatter
#1922
[DataGrid] Make the CSV export respect the valueFormatter
#1922
Conversation
valueFormatter
delimiterCharacter: GridExportCsvDelimiter; | ||
} | ||
|
||
export function buildCSV(options: BuildCSVOptions): string { | ||
const { columns, rows, selectedRows, getCellValue, delimiterCharacter } = options; | ||
const { columns, rows, selectedRows, getCellParams, delimiterCharacter } = options; |
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.
Should we make it an opt out option?
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.
Applying the same logic then we should also make delimiterCharacter
optional. Although you need either 'getCellParams' or getCellValue
here to get the actual cell value because we only have access to the cell ID and using the apiRef
in here is not ideal as that file is with helper/utility functions that are grid agnostic.
IMO we can keep it for now as it is.
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.
That's ok, I meant using the value formatter, there might be cases where one would prefer the raw value, maybe it should be column based as well 🤔
What do you think? @mui-org/x
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.
The first step was to apply the same valueFormatter
to the CSV export, that might be sufficient for most of the use cases. If someone requests for a per-column formatting, we can add an exclusive value formatter for the export: #1814 (comment)
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.
Yes that's what we said originally. I'm just being extra cautious here about numbers, ie 1,000
, should be exported as "1,000"
, would that be interpreted as numbers by excel? 🤔
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.
Just tested and it seems ok. Let's not do the option for now
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.
Yeah, we had a PR about that: #1656 (comment) If the OS is correctly configured, we just need to use the same formatting in the CSV export.
delimiterCharacter: GridExportCsvDelimiter; | ||
} | ||
|
||
export function buildCSV(options: BuildCSVOptions): string { | ||
const { columns, rows, selectedRows, getCellValue, delimiterCharacter } = options; | ||
const { columns, rows, selectedRows, getCellParams, delimiterCharacter } = options; |
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.
The first step was to apply the same valueFormatter
to the CSV export, that might be sufficient for most of the use cases. If someone requests for a per-column formatting, we can add an exclusive value formatter for the export: #1814 (comment)
Fix #1814