csv-exportor
A Javascript library for browsers to generate and download csv file from array.
The csv parser is based on module comma-separated-values
refer to comma-separated-values
to see all the allowed array patten
and options
.
using window.URL.createObjectURL
to create file stream, so please pay attention to the browser compatibility.
Demo
/*using vue2 to demo its usageby click the button, your brower would start a download of file 'test.csv' immediately.*/<template> ... <button @click="exportCsv">EXPORT</button> ...</template> { return tableData: "a""b""c""d""e""f" header: "foo""bar""baz" } methods: { CsvExportor; }
Installation
Use Yarn or npm:
$ yarn add csv-exportor
$ npm i csv-exportor --save
Module Loading
It's an UMD module, so you can:
// ECMAScript 2015+ (via Babel)
// CommonJSconst CsvExportor =
<!-- browser globals -->
Usage
/* generate csv file from data, and automaticly download the file for browser */CsvExportor; // generate data url of the generated csv fileCsvExportor;
LICENSE MIT