-2
The quasar only provides examples of how to download a table in CSV format. I wonder if it is possible, using the same logic, to download tables in excel. Code of how I am doing. The file comes to be downloaded but does not open. excel says that the file is either with wrong or corrupted extension.
function wrapExcelValue (val, formatFn) {
let formatted = typeof formatFn !== 'undefined'
? formatFn(val)
: val
formatted = typeof formatted === 'undefined' || formatted === null
? ''
: String(formatted)
formatted = formatted.split('"').join('""').split('\n').join('\\n').split('\r').join('\\r')
return `"${formatted}"`
}
exportExcel () {
// naive encoding to excel format
console.log('Excel')
const content = [this.columns.map(col => wrapExcelValue(col.label))].concat(
this.data.map(row => this.columns.map(col => wrapExcelValue(
row[col.name],
col.format
)).join(','))
).join('\r\n')
const date = new Date()
const status = exportFile(
'mensagens_' + this.altDate(date.getTime()) + '.xlsx',
content,
'text/xlsx'
)
if (status !== true) {
this.$q.notify({
message: 'Download rejeitado pelo navegador...',
color: 'negative',
icon: 'warning'
})
}
}