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 #22

Open
DewangS opened this issue Nov 23, 2020 · 0 comments
Open

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

DewangS opened this issue Nov 23, 2020 · 0 comments

Comments

@DewangS
Copy link

DewangS commented Nov 23, 2020

I am using this package in my ReactJS code with material-table. In the exported CSV, all values are enclosed within double quotes. (see below)

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.

"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={columns}
data={applicationList}
options={{
exportButton: true,
exportAllData: true,
exportDelimiter: " ",
exportCsv: (columns, applicationList) => {
const repoColumns = columns.filter(columnDef => {
return !columnDef.hidden && columnDef.field && columnDef.export !== false;
});

                  let data = applicationList.map(rowData =>
                      columns.map(columnDef => {
                        return columnDef.render ? columnDef.render(rowData) : rowData[columnDef.field];
                      })
                    );
                    
                    alert('You should develop a code to export ' + data + ' rows');
                    new CsvBuilder(fileName+"_01")
                        .setDelimeter(',')
                        .setColumns(columns.map(columnDef => columnDef.title))
                        .addRows(data)
                        .exportFile();
                  },
                  showTitle: false,
                  isLoading: true,
                  //exportDelimiter: '        ',
                  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);
                    }),
                }}
              />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant