# vue-elementui-exceltable

> An editable table component for Vue

Latest version **1.1.9** (published 2020-09-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install vue-elementui-exceltable
pnpm add vue-elementui-exceltable
yarn add vue-elementui-exceltable
bun add vue-elementui-exceltable
```

## 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.1.9 |
| Published | 2020-09-03 |
| First published | 2020-06-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 10.13.0 |
| Dependencies | 0 |
| Unpacked size | 666 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | LiuXin |
| Maintainers | startblingbling |
| Keywords | vue-exceltable, vue editable table, vue component, vue |

## Links

- npm: https://www.npmjs.com/package/vue-elementui-exceltable
- Repository: https://github.com/startblingbling/vue-exceltable
- Homepage: https://github.com/startblingbling/vue-exceltable#readme
- Issues: https://github.com/startblingbling/vue-exceltable/issues
- npm.io page: https://npm.io/package/vue-elementui-exceltable

## Alternatives

- [@lexical/table](https://npm.io/package/@lexical/table.md) — 3.0M weekly downloads
- [mantine-datatable](https://npm.io/package/mantine-datatable.md) — 98.2K weekly downloads
- [react-native-collapsible-tab-view](https://npm.io/package/react-native-collapsible-tab-view.md) — 70.6K weekly downloads
- [@handsontable/vue3](https://npm.io/package/@handsontable/vue3.md) — 16.1K weekly downloads
- [vuewordcloud](https://npm.io/package/vuewordcloud.md) — 7.2K weekly downloads

## Recent versions

- 1.1.9 (latest) — 2020-09-03
- 1.1.8 — 2020-09-03
- 1.1.7 — 2020-09-03
- 1.1.6 — 2020-08-31
- 1.1.5 — 2020-08-28
- 1.1.4 — 2020-08-07
- 1.1.3 — 2020-07-23
- 1.1.2 — 2020-07-06
- 1.1.1 — 2020-07-06
- 1.1.0 — 2020-07-03
- 1.0.10 — 2020-07-03
- 1.0.9 — 2020-07-03
- 1.0.8 — 2020-07-03
- 1.0.7 — 2020-07-03
- 1.0.6 — 2020-06-22
- … 6 more at https://npm.io/package/vue-elementui-exceltable/versions

## README

# vue-elementui-exceltable 可编辑的表格组件

在 vue-willtable 表格的基础上做了些许修改

[vue-willtable 项目地址]（https://github.com/KevinMint55/vue-willtable)

原项目作者

[WillWu](https://www.willwuwei.com)

## 修改

- 增加级联选择器
- 修改 date,month,select,cascader 使用时，均需要两个单元格，前一个单元格展示选中的文本，后一个单元格不展示存放选中的 value 值
- 示例 ：{
  title: '日期',
  key: 'dateLabel',
  type: 'date',
  width: 100,
  show: true,
  requiredIcon: true //表头添加\*，表示必填
  },
  {
  title: '日期',
  key: 'date',
  width: 0,
  show: false
  },
- 单元格编辑完后，在单元格未失去焦点时，调用 this.$refs.vueElementuiExceltable.$refs.willtables.clickoutside()，此时的表格数据中会有刚刚编辑完的单元格数据

## 安装

```
npm install vue-elementui-exceltable --save
```

## 挂载

### 挂载在全局

```javascript
import Vue from 'vue'
import VueElementuiExceltable from 'vue-elementui-exceltable'

// require styles
import 'vue-elementui-exceltable/dist/vue-elementui-exceltable.min.css'

Vue.component('VueElementuiExceltable', VueElementuiExceltable)
```

### 挂载在组件

```javascript
import VueElementuiExceltable from 'vue-elementui-exceltable'

// require styles
import 'vue-elementui-exceltable/dist/vue-elementui-exceltable.min.css'

export default {
  components: {
    VueElementuiExceltable
  }
}
```

## 使用例子

```vue
<template>
  <vue-elementui-exceltable
    ref="willtables"
    :columns="columns"
    v-model="data"
    :showIcon="showIcon"
    @selection-change="selectionChange"
    :maxHeight="maxHeight"
    :disabled="disabled"
    :cellStyle="cellStyle"
    :cellClassName="cellClassName"
    :rowHeight="rowHeight"
  >
  </vue-elementui-exceltable>
</template>
<script>
export default {
  props: {
    columns: {
      type: Object,
      required: true
    },
    data: {
      type: Array,
      required: true
    },
    maxHeight: {
      type: Number,
      default: 800,
      required: false
    },
    showIcon: {
      type: Boolean,
      default: () => {
        return true
      },
      required: false
    },
    disabled: {
      type: Boolean,
      default: false,
      required: false
    },
    cellStyle: {
      type: Function,
      default: () => {},
      required: false
    },
    cellClassName: {
      type: Function,
      default: () => {},
      required: false
    },
    rowHeight: {
      type: Number,
      default: 28,
      required: false
    }
  },
  data () {
    return {}
  },
  methods: {
    getData () {
      const data = [
        {
          titleEn: '',
          titleCn: '',
          publisherEn: '',
          publisherCn: '',
          authorEn: '',
          authorCn: '',
          isbn: '',
          copyStatus: '',
          pubDate: '',
          pageNum: '',
          format: '',
          edition: '',
          series: '',
          classify: '',
          lang: '',
          country: ''
        },
        {
          titleEn: '',
          titleCn: '',
          publisherEn: '',
          publisherCn: '',
          authorEn: '',
          authorCn: '',
          isbn: '',
          copyStatus: '',
          pubDate: '',
          pageNum: '',
          format: '',
          edition: '',
          series: '',
          classify: '',
          lang: '',
          country: ''
        },
        {
          titleEn: '',
          titleCn: '',
          publisherEn: '',
          publisherCn: '',
          authorEn: '',
          authorCn: '',
          isbn: '',
          copyStatus: '',
          pubDate: '',
          pageNum: '',
          format: '',
          edition: '',
          series: '',
          classify: '',
          lang: '',
          country: ''
        },
        {
          titleEn: '',
          titleCn: '',
          publisherEn: '',
          publisherCn: '',
          authorEn: '',
          authorCn: '',
          isbn: '',
          copyStatus: '',
          pubDate: '',
          pageNum: '',
          format: '',
          edition: '',
          series: '',
          classify: '',
          lang: '',
          country: ''
        },
        {
          titleEn: '',
          titleCn: '',
          publisherEn: '',
          publisherCn: '',
          authorEn: '',
          authorCn: '',
          isbn: '',
          copyStatus: '',
          pubDate: '',
          pageNum: '',
          format: '',
          edition: '',
          series: '',
          classify: '',
          lang: '',
          country: ''
        },
        {
          titleEn: '',
          titleCn: '',
          publisherEn: '',
          publisherCn: '',
          authorEn: '',
          authorCn: '',
          isbn: '',
          copyStatus: '',
          pubDate: '',
          pageNum: '',
          format: '',
          edition: '',
          series: '',
          classify: '',
          lang: '',
          country: ''
        },
        {
          titleEn: '',
          titleCn: '',
          publisherEn: '',
          publisherCn: '',
          authorEn: '',
          authorCn: '',
          isbn: '',
          copyStatus: '',
          pubDate: '',
          pageNum: '',
          format: '',
          edition: '',
          series: '',
          classify: '',
          lang: '',
          country: ''
        },
        {
          titleEn: '',
          titleCn: '',
          publisherEn: '',
          publisherCn: '',
          authorEn: '',
          authorCn: '',
          isbn: '',
          copyStatus: '',
          pubDate: '',
          pageNum: '',
          format: '',
          edition: '',
          series: '',
          classify: '',
          lang: '',
          country: ''
        },
        {
          titleEn: '',
          titleCn: '',
          publisherEn: '',
          publisherCn: '',
          authorEn: '',
          authorCn: '',
          isbn: '',
          copyStatus: '',
          pubDate: '',
          pageNum: '',
          format: '',
          edition: '',
          series: '',
          classify: '',
          lang: '',
          country: ''
        },
        {
          titleEn: '',
          titleCn: '',
          publisherEn: '',
          publisherCn: '',
          authorEn: '',
          authorCn: '',
          isbn: '',
          copyStatus: '',
          pubDate: '',
          pageNum: '',
          format: '',
          edition: '',
          series: '',
          classify: '',
          lang: '',
          country: ''
        }
      ]
      this.$refs.willtables.setData(data)
      window.willtables = this.$refs.willtables
    },
    selectionChange (selection) {
      this.selectedIds = selection.map(item => item.id)
    }
  },
  mounted () {
    this.getData()
    setTimeout(() => {
      willtables.handleResize()
    }, 200)
  },
  updated () {
    this.$refs.willtables.data.length === 10 ? () => {} : this.getData()
    // debugger
  }
}
</script>
<style lang="scss"></style>
```

### 数据

this.\$refs.willtable 调用 setData 方法来更新整表数据，并会重置历史数据记录.

this.\$refs.willtable 调用 getData 方法来获取整表数据.

`v-model`进行值的绑定

### 属性

| 参数          | 说明                          | 类型                                           | 可选值 | 默认值 |
| ------------- | ----------------------------- | ---------------------------------------------- | ------ | ------ |
| columns       | 表格列的配置描述              | Array                                          | ——     | []     |
| maxHeight     | 表格最大高度                  | string / number                                | ——     | ——     |
| rowHeight     | 每行高度                      | string / number                                | ——     | ——     |
| disabled      | 是否禁止编辑                  | Boolean                                        | ——     | true   |
| showIcon      | 是否显示表头类型图标          | Boolean                                        | ——     | false  |
| requiredIcon  | 是否为必填项                  | Boolean                                        | ——     | false  |
| cellStyle     | 单元格的 style 的回调方法     | Function({row, column, rowIndex, columnIndex}) | ——     | ——     |
| cellClassName | 单元格的 className 的回调方法 | Function({row, column, rowIndex, columnIndex}) | ——     | ——     |

### 事件

| 事件名称         | 说明                           | 回调参数  |
| ---------------- | ------------------------------ | --------- |
| selection-change | 当选择项发生变化时会触发该事件 | selection |

### 方法

| 方法名        | 说明                                                                    | 参数        |
| ------------- | ----------------------------------------------------------------------- | ----------- |
| getData       | 用来获取数据，返回当前表格数据                                          | ——          |
| setData       | 用来设置数据，并重置历史记录                                            | data        |
| getChangeData | 获取变化的数据行                                                        | ——          |
| getErrorRows  | 获取校验错误的数据和索引                                                | ——          |
| addItem       | 底部添加一行数据                                                        | item        |
| removeItems   | 批量删除，参数 key 为每行的唯一标识属性如 id，values 为该标识属性的数组 | key, values |

### 列属性

| 参数     | 说明                           | 类型            | 可选值                             | 默认值 |
| -------- | ------------------------------ | --------------- | ---------------------------------- | ------ |
| key      | 对应列内容的字段名             | String          | ——                                 | ——     |
| title    | 列头显示文字                   | String          | ——                                 | ——     |
| width    | 列宽度                         | String / Number | ——                                 | ——     |
| type     | 列类型                         | String          | selection/number/date/select/month | ——     |
| format   | 千分号格式（用于 number 类型） | Boolean         | ——                                 | true   |
| options  | select 下拉选项                | Array           | { value: '值', label: '显示文字' } | ——     |
| fixed    | 是否固定在左侧                 | Boolean         | ——                                 | false  |
| action   | 是否启用筛选和排序             | Boolean         | ——                                 | false  |
| disabled | 是否禁止编辑                   | Boolean         | ——                                 | false  |
| noVerify | 是否禁用校验                   | Boolean         | ——                                 | false  |
| validate | 自定义校验                     | Function(value) | ——                                 | ——     |

### 快捷键

| 快捷键            | 说明                      |
| ----------------- | ------------------------- |
| 方向键            | 移动编辑框                |
| Ctrl + C          | 粘贴                      |
| Ctrl + V          | 复制                      |
| Ctrl + A          | 单元格全选                |
| Ctrl + Z          | 撤销                      |
| Ctrl + Y          | 重做                      |
| Enter             | 单元格编辑/完成单元格编辑 |
| Delete、Backspace | 删除                      |

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