No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

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

    Framework
    2
    2
    176
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • I
      iamtetea last edited by

      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'
          })
        }
      }
      metalsadman 1 Reply Last reply Reply Quote 0
      • metalsadman
        metalsadman @iamtetea last edited by metalsadman

        @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.

        1 Reply Last reply Reply Quote 0
        • First post
          Last post