Export table data to CSV

Get help with using Metro 4 components
Post Reply
russelguinarez
Posts: 16
Joined: Fri Feb 08, 2019 5:47 pm
Status: Offline

Export table data to CSV

Post by russelguinarez » Thu Feb 14, 2019 6:00 pm

Hi,

How does this work? Should I put a button somewhere? The instruction only shows this code.

Code: Select all

var table = $(el).data('table');
table.export('CSV', 'all', 'table-export.csv', {
    csvDelimiter: "\t",
    csvNewLine: "\r\n",
    includeHeader: true
});
How to make it work?

Thanks

User avatar
olton
Site Admin
Posts: 237
Joined: Mon Apr 09, 2018 6:19 pm
Location: Kiev, Ukraine
Status: Offline

Post by olton » Thu Feb 14, 2019 6:16 pm

if a table has a role table - https://metroui.org.ua/table-component. ... ble_export
if a table without role table

Code: Select all

var file_name = "table.csv";
var table = document.querySelector("table");
var options = {
        csvDelimiter: "\t",
        csvNewLine: "\r\n",
        includeHeader: true
};
Metro.export.tableToCSV(table, file_name, options)

Post Reply