# data2excel

> This is a script helping the front end to convert the data into Excel.

Latest version **1.0.2** (published 2021-06-10) · ISC license · 0 weekly downloads

## Install

```sh
npm install data2excel
pnpm add data2excel
yarn add data2excel
bun add data2excel
```

## 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.2 |
| Published | 2021-06-10 |
| First published | 2021-06-10 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | yuqixuan |
| Maintainers | yuqixuan |

## Links

- npm: https://www.npmjs.com/package/data2excel
- Repository: https://github.com/yuqixuan/data2excel
- Homepage: https://github.com/yuqixuan/data2excel#readme
- Issues: https://github.com/yuqixuan/data2excel/issues
- npm.io page: https://npm.io/package/data2excel

## Recent versions

- 1.0.2 (latest) — 2021-06-10
- 1.0.1 — 2021-06-10
- 1.0.0 — 2021-06-10

## README

# data2excel

### 使用方法

1. 安装 npm i data2excel --save
2. 引入 import { data2excel } from 'data2excel'
3. data2excel(column, data, [title], [filename])

### data2excel方法介绍

* column: 必填，类型为对象数组，对象包含name(列名)，style(可选，控制该字段的样式)
* data: 必填，类型为对象数组，对象包含style(可选，控制一行字段的样式)
* title: 可选，如果传进来一个字符串，直接作为excel第一行，无样式，如果想要添加样式，需传入对象，{name: 'title', style: 'xxx'}
* filename: 可选，下载的excel文件名 

```js
<-- excample --!>
  const column = [
    {
      name: 'name',
      style: 'font-weight: bold'
    },
    {
      name: 'phone',
      style: 'font-weight: bold'
    },
    {
      name: 'email',
      style: 'font-weight: bold'
    }
  ]

  const data = [
    {
      name:'路人甲',
      phone:'123456',
      email:'123@123456.com',
      style: 'font-weight: bold'
    },
    {
      name:'炮灰乙',
      phone:'123456',
      email:'123@123456.com'
    },
    {
      name:'土匪丙',
      phone:'123456',
      email:'123@123456.com'
    },
    {
      name:'流氓丁',
      phone:'123456',
      email:'123@123456.com'
    },
  ]
  
 data2excel(column, data, {name: 'this is a title', style: 'font-weight: bold; font-size: 30px'})
```

### 优点

可以灵活控制每一行的样式，体积小

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