# ph-export

> xls csv export js

Latest version **1.0.0** (published 2021-08-23) · 0 weekly downloads

## Install

```sh
npm install ph-export
pnpm add ph-export
yarn add ph-export
bun add ph-export
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2021-08-23 |
| First published | 2021-08-23 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 2.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | phoeon |

## Links

- npm: https://www.npmjs.com/package/ph-export
- npm.io page: https://npm.io/package/ph-export

## Recent versions

- 1.0.0 (latest) — 2021-08-23

## README

# 🚀 Welcome to your new awesome project!

This project has been created using **webpack-cli**, you can now run

```
npm install ph-export
```

usage

```html
<button data-export="xls">xls</button>
<button data-export="cvs">cvs</button>
```
``` typescript
import { export2csv,export2xls } from 'ph-export'
interface Row{
    name:string,
    age:number,
    gender:string,
    [k:string]:any
}
const headers = [
    {name:"姓名",key:"name"},
    {name:"年龄",key:"age"},
    {name:"性别",key:"gender"}
]
const list:Array<Row> = [{
    name:"章三",
    age:21,
    gender:"男"
},{
    name:"里四",
    age:17,
    gender:"女"
},{
    name:"王武",
    age:25,
    gender:"中"
}]

let str = headers.map(th=>th.name).join(",")+"\n"//表头
str+=list.map(row=>{
    return headers.map(th=>row[th.key]||'').join("\t,")
}).join("\n")

document.addEventListener("click",(e:MouseEvent)=>{
    const t = e.target as HTMLElement
    switch(t.dataset.export){
        case "xls":
            export2xls(str,"test");
            break
        case "cvs":
            export2csv(str,"test");
            break
    }
})
```

to bundle your application

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