# uupaa.csv.downloader.js

> Create and download a CSV file on a browser.

Latest version **0.0.3** (published 2020-01-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install uupaa.csv.downloader.js
pnpm add uupaa.csv.downloader.js
yarn add uupaa.csv.downloader.js
bun add uupaa.csv.downloader.js
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2020-01-28 |
| First published | 2019-07-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 8.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | uupaa.js@gmail.com |
| Maintainers | uupaa |

## Links

- npm: https://www.npmjs.com/package/uupaa.csv.downloader.js
- Repository: https://github.com/uupaa/CSVDownloader.js
- Homepage: https://github.com/uupaa/CSVDownloader.js#readme
- Issues: https://github.com/uupaa/CSVDownloader.js/issues
- npm.io page: https://npm.io/package/uupaa.csv.downloader.js

## Dependencies (1)

- [iconv-lite](https://npm.io/package/iconv-lite.md) ^0.5.0

## Recent versions

- 0.0.3 (latest) — 2020-01-28
- 0.0.2 — 2019-09-03
- 0.0.1 — 2019-07-30

## README

# uupaa.csv.downloader.js

Create and download a CSV file on a browser.

# Usage

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

```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

| Applications                    | Version     |
|---------------------------------|-------------|
| `MAC-EXCEL` as Excel for Mac      | 16          |
| `WIN-EXCEL` as Windows Excel      | 2010        |
| `MAC-NUMS`  as Mac Numbers        | 6.0         |
| `GOG-SHEET` as Google Spreadsheet | N/A         |       

| BOM | TYPE | ENCODE | `MAC-EXCEL` | `WIN-EXCEL` | `MAC-NUMS` | `GOG-SHEET` |
|-----|------|--------|-----------|-----------|----------|-----------|
| NO  | CSV  | CP932  | `NG1`     | OK        | OK       | OK        |
| NO  | TSV  | CP932  | `NG3`     | OK        | OK       | OK        |
| YES | CSV  | UTF-8  | OK        | OK        | OK       | OK        |
| YES | TSV  | UTF-8  | `NG2`     | OK        | OK       | OK        |
| YES | CSV  | UTF-16 | OK        | OK        | OK       | OK        |
| YES | TSV  | UTF-16 | `NG2`     | OK        | OK       | OK        |

- 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.

| options | type    | default |          |
|---------|---------|---------|----------|
| `BOM`   | Boolean | false   | true is Add UNICODE BOM |
| `TSV`   | Boolean | false   | true is Tab separated CSV |
| `ENC`   | CSV_ENC | CSV_ENC.UTF16 | Specify encoding, CSV_ENC.UTF16, CSV_ENC.UTF8 and CSV_ENC.CP932 |
| `DQT`   | Boolean | false   | true is Enclose all values in double quotes |

---
_Source: https://npm.io/package/uupaa.csv.downloader.js · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
