0.0.3 • Published 5 years ago

uupaa.csv.downloader.js v0.0.3

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

uupaa.csv.downloader.js

Create and download a CSV file on a browser.

Usage

$ npm i -S uupaa.csv.downloader.js

const { CSVDownloader, CSV_ENC } = require("uupaa.csv.downloader.js");
const csv = new CSVDownloader();
csv.addHead([ "created_at", "updated_at", "data" ]);
csv.addBody([ 123, 123, "123" ]);
csv.addBody([ 123, 123, "123" ]);
csv.download("3.csv", { BOM: true, TSV: false, ENC: CSV_ENC.UTF8,  DQT: true });
csv.download("5.csv", { BOM: true, TSV: false, ENC: CSV_ENC.UTF16, DQT: true })
csv.clear();

CSV file type and availabilities

ApplicationsVersion
MAC-EXCEL as Excel for Mac16
WIN-EXCEL as Windows Excel2010
MAC-NUMS as Mac Numbers6.0
GOG-SHEET as Google SpreadsheetN/A
BOMTYPEENCODEMAC-EXCELWIN-EXCELMAC-NUMSGOG-SHEET
NOCSVCP932NG1OKOKOK
NOTSVCP932NG3OKOKOK
YESCSVUTF-8OKOKOKOK
YESTSVUTF-8NG2OKOKOK
YESCSVUTF-16OKOKOKOK
YESTSVUTF-16NG2OKOKOK
  • OK: It's OK.
  • NG1: It was garbled.
  • NG2: Tab separator(tsv) not supported.
  • NG3: NG1 and NG2.

If you need to support excel on Mac, use BOM and CSV.

CSVDownloader API

new CSVDownloader()

const csv = new CSVDownloader() is constructor.

CSVDownloader#clear()

CSVDownloader#clear():void is clear csv header and csv body data.

CSVDownloader#addHead()

CSVDownloader#addHead(array:Array):void is add csv header.

CSVDownloader#addBody()

CSVDownloader#addBody(array:Array):void is add csv row to body.

CSVDownloader#download()

CSVDownloader#download(filename:String, options = { BOM: false, TSV: false, ENC: CSV_ENC.UTF16, DQT: false }):void is create csv file and download.

optionstypedefault
BOMBooleanfalsetrue is Add UNICODE BOM
TSVBooleanfalsetrue is Tab separated CSV
ENCCSV_ENCCSV_ENC.UTF16Specify encoding, CSV_ENC.UTF16, CSV_ENC.UTF8 and CSV_ENC.CP932
DQTBooleanfalsetrue is Enclose all values in double quotes
0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago