Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Quasar exportFile utf-8 encoding

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?

like image 586
amin hd Avatar asked Jun 06 '26 07:06

amin hd


1 Answers

Solution that worked for me:

const status = exportFile(
'table-export.csv',
"ufeff"+content,
'text/csv')
like image 53
user16027291 Avatar answered Jun 09 '26 04:06

user16027291



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!