Is there a way to add some header information in table export .csv?



  • exportTable () {
      // naive encoding to csv format
      const content = [ this.columns.map(col => wrapCsvValue(col.label)) ].concat(
        this.data.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'
      )
    
      if (status !== true) {
        this.$q.notify({
          message: 'Browser denied file download...',
          color: 'negative',
          icon: 'warning'
        })
      }
    }


  • @iamtetea if you understood the code, content is just the data array converted into string delimited by commas, you can do whatever with it just follow the correct pattern for it to be a valid csv format.


Log in to reply