-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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] Customize separator in CSV export #1440
Comments
This comment has been minimized.
This comment has been minimized.
The solution for point 3 would be to add sequence of bytes (0xEF, 0xBB, 0xBF) at the beginning of a csv file. This would allow Excel to automatically detect file encoding as UTF-8, but according to the Unicode standard, the BOM for UTF-8 files is not recommended. The implementation of this solution is very simple and requires replacement in useGridCsvExport.tsx:
by
It should be optional and by default it should work as it currently is. It would be great to add options in the GridToolbarExport that would allow you to configure:
|
@michallukowski maybe you could do a PR for the UTF 8 fix 🤔 |
…mui#1440 This feature allows to: - set the file name - set flag utf8WithBom to generate csv file as UTF-8 with BOM It may be extended with further options in the future
…mui#1440 This feature allows to: - set the file name - set flag utf8WithBom to generate csv file as UTF-8 with BOM It may be extended with further options in the future
Regarding point 3. it was fixed in #1695 with: <GridToolbarExport
csvOptions={{
utf8WithBom: true,
}}
/> We could probably add documentation about this Maybe: diff --git a/packages/grid/_modules_/grid/models/gridExport.ts b/packages/grid/_modules_/grid/models/gridExport.ts
index eeb97c27..e1576744 100644
--- a/packages/grid/_modules_/grid/models/gridExport.ts
+++ b/packages/grid/_modules_/grid/models/gridExport.ts
@@ -2,7 +2,16 @@
* The options to apply on the CSV export.
*/
export interface GridExportCsvOptions {
+ /**
+ * String to use as the file name.
+ * @default `document.title`
+ */
fileName?: string;
+ /**
+ * If `true`, the UTF-8 Byte Order Mark (BOM) prefixes the exported file.
+ * This can allow Excel to automatically detect file encoding as UTF-8.
+ * @default false
+ */
utf8WithBom?: boolean;
} ? Regarding point 1, maybe we can add a simple new option: diff --git a/packages/grid/_modules_/grid/models/gridExport.ts b/packages/grid/_modules_/grid/models/gridExport.ts
index eeb97c27..6a73ed68 100644
--- a/packages/grid/_modules_/grid/models/gridExport.ts
+++ b/packages/grid/_modules_/grid/models/gridExport.ts
@@ -2,6 +2,11 @@
* The options to apply on the CSV export.
*/
export interface GridExportCsvOptions {
+ /**
+ * The delimiter inserted between cell values.
+ * @default ','
+ */
+ delimiter?: string;
fileName?: string;
utf8WithBom?: boolean;
} for delimiter vs. separator see https://en.wikipedia.org/wiki/Delimiter For point 2, I have |
I'm closing as the 3 points raised in this issue have been solved. |
Hi,
i've worked a little bit with Data Grid
Can you make the separator for csv export selectable? In Germany its a semicolon, not a comma. It would be great to export it with an ; instead of ,Fixed in [DataGrid] Allow to set in GridExportCsvOptions delimiter #1859Can you add the choice, if a column should not be exported to csv? I'm creating links in some columns, they should not be exported. And i haven't found a way to prevent itDuplicate of [DataGrid] Allow to remove column from CSV export #1435The Coding of the file show cryptic letters instead of german umlaut. So, if i export the word "Fakultät" (Fakultät), Excel dont uses utf-8 for file coding. If i open the csv over Data import from file i can change the coding of the file. Is there a way to export in itf-8?Fixed in [DataGrid] Allow to customize GridToolbarExport's CSV export #1695Thanks,
friedensstifter
The text was updated successfully, but these errors were encountered: