filefy icon indicating copy to clipboard operation
filefy copied to clipboard

All values in exported CSV are enclosed within double quotes

Open DewangS opened this issue 4 years ago • 0 comments

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);
                    }),
                }}
              />

DewangS avatar Nov 23 '20 21:11 DewangS