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

All values in exported CSV are enclosed within double quotes #2631

Closed
DewangS opened this issue Nov 20, 2020 · 4 comments
Closed

All values in exported CSV are enclosed within double quotes #2631

DewangS opened this issue Nov 20, 2020 · 4 comments
Labels
question Further information is requested wontfix This will not be worked on

Comments

@DewangS
Copy link

DewangS commented Nov 20, 2020

Guidelines

  • Please include a demo of the issue/behavior/question you have

When I use builtin export feature to export data as a TAB or COMMA delimited file, all values including headers in the resultant file are enclosed within double quotes. I've gone through the documentation on material-table.com but there isn't seem to be any explanation on how to prevent this. see below export



- #### Please try to be as detailed as possible

All I want is to export the table as a tab delimited values and I DON'T want these values enclosed in double quotes. If I open the exported file and save as tab delimited file, I can see MS-Excel is removing double quotes. Wonder why the built-in functionality encloses values and column headers in quotes.

My code in ReactJs app is as per below ...

"Title","First Name","Last Name","Address Line 1","Address Line 2","City","State","PostCode","Phone","Mobile","Fax","Email","Company","Order Number","Primary Campus","Category","Permit Type","Receipt Number","Staff\Student ID","Rego No","Make","Alt Rego No","Alt Make","Validations Errors","Warnings"
"","Greg Turnbull","Odgers","14 Empire St","","Poke","AB","C2750","","90909090","","[email protected]","","897878723","Hando",,"General Half Year ","WEB181224","47","8987723","yywte","Mazda 3","iouuu","",
"","Bob","Gaunder","222 CAT drive","","Nona","CT","D2126","","8977776","","[email protected]","","89898","Jacksonville",,"General Annual ","WEB181226","94","787233","FFR782","nissan","","",

<MaterialTable
title="Validation Results"
icons={tableIcons}
columns={exceptionReportColumns}
data={applicationList}
options={{
exportButton: true,
exportAllData: true,
showTitle: false,
isLoading: true,
headerStyle: {
backgroundColor: "#01579b",
color: "#FFF",
},
rowStyle: (rowData) => ({
color: rowData.errors !== "" ? "red" : "",
}),
}}
editable={{
onRowUpdate: (newData, oldData) =>
new Promise((resolve, reject) => {
setTimeout(() => {
const dataUpdate = [...applicationList];
const index = oldData.tableData.id;
dataUpdate[index] = newData;
setApplicationList([...dataUpdate]);

                        resolve();
                      }, 1000);
                    }),
                }}
              />

- #### You may fork one of the following starter templates if you would like:

  - #### [CodeSandbox](https://codesandbox.io/s/material-table-starter-template-xnfpo)
  - #### [StackBlitz](https://stackblitz.com/edit/material-table-starter-template)
@DewangS DewangS added the question Further information is requested label Nov 20, 2020
@DewangS
Copy link
Author

DewangS commented Nov 22, 2020

could someone please reply? this seems to be a bug rather than a query as I just tried to write my custom exportCsv() using the csvBuilder and the exported file doesn't contain values within double quotes. If there is a hack i.e. undocumented feature in MUI Table export functionality such as setting some other flags for export of the data value definition, please advise. Really don't want to end up writing a custom function just to remove double quoted values in the exported CSV. I also noticed that numeric values which are defined as numeric ({ title: 'Birth Year', field: 'birthYear', type: 'numeric' },) type in the column definition gets exported without quotes...

@nelstrom
Copy link

nelstrom commented Dec 1, 2020

I see that you posted a similar issue on mbrn/filefy#22 I think that's where the issue actually belongs, so perhaps this issue should be closed?

In the CsvBuilder class, there's a private function called escapeCell() which adds the quotes: https://github.com/mbrn/filefy/blob/fd154dbb84ebe3b93f97726d644d3e5f151cbca8/src/csv-builder/CsvBuilder.ts#L35-L40

I believe that this is by design. Any field in a CSV file could itself contain a , character. By wrapping string fields in quotes , "", these comma characters are contained within the field column where they belong.

@DewangS
Copy link
Author

DewangS commented Dec 2, 2020

I originally posted here as I wasn't using filefy. Used filefy as I couldn't get any feedback here. Thanks for the explanation though why it doesn't enclose values in quotes when you export the EXPORTED csv file from Excel as a TAB delimited ? This just adds extra step for the end user to use Excel when it shouldn't be needed.

@stale
Copy link

stale bot commented Mar 3, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You can reopen it if it required.

@stale stale bot added the wontfix This will not be worked on label Mar 3, 2021
@stale stale bot closed this as completed Mar 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants