I am using Quasar freamwork and Perisan words in my site. I used Export-data util for exporting csv file from data tables.
This is js codes that export data :
function wrapCsvValue(val, formatFn) {
let formatted = formatFn !== void 0
? formatFn(val)
: val
formatted = formatted === void 0 || formatted === null
? ''
: String(formatted)
formatted = formatted.split('"').join('""')
return `"${formatted}"`
}
exportTable() {
const content = [this.columns.map(col => wrapCsvValue(col.label))].concat(
this.rows.map(row => this.columns.map(col => wrapCsvValue(
typeof col.field === 'function'
? col.field(row)
: row[col.field === void 0 ? col.name : col.field],
col.format
)).join(','))
).join('\r\n')
const status = exportFile(
'table-export.csv',
content,
'text/csv'
)
}
When I export table, this returns unreadable data when I open it in excel. but when I use it on online excel viewers It is okay. What can I do?
Solution that worked for me:
const status = exportFile(
'table-export.csv',
"ufeff"+content,
'text/csv')