-
Notifications
You must be signed in to change notification settings - Fork 664
How to export JavaScript array info to csv on client side
agershun edited this page Dec 28, 2014
·
4 revisions
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][1]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]);
}
© 2014-2024, Andrey Gershun & Mathias Rangel Wulff
Please help improve the documentation by opening a PR on the wiki repo