-
Notifications
You must be signed in to change notification settings - Fork 664
How to export JavaScript array info to csv on client side
Mathias Rangel Wulff edited this page Jun 13, 2015
·
4 revisions
Source: StackOverflow.com
There are the attribute info in array, which looks like this:
[["name1", "city_name1", ...]["name2", "city_name2", ...]]
Any idea how I can export this to csv on the client side?
You can use AlaSQL.js library to export data locally in CSV (and XLSX as well) file format.
Below you can see a simple working example how to export data to CSV format.
<script src="http://alasql.org/console/alasql.min.js"></script>
<button onclick="exportData()">Export data to CSV file</button>
var data = [["Minsk",100000], ["Riga",200000]];
function exportData() {
alasql("SELECT * INTO CSV('cities.csv') FROM ?",[data]);
}
You can try this example at jsFiddle.
© 2014-2024, Andrey Gershun & Mathias Rangel Wulff
Please help improve the documentation by opening a PR on the wiki repo