使用execl导出插件'xlsx-oc'进行页面内容导出:
注:该插件是基于xlsx插件进行的二次开发,感觉还是比较简单易用
1> 安装
yarn add @'xlsx-oc
2> 使用
import { exportExcel } from 'xlsx-oc';
private download = () => {
const { fileName } = this.state;
const { i18n } = this.props.dep;
const data = [];
// 所需导出的内容,此处以固定数组为例
const list: any[] = [{
A: 0,
B: 1
}];
// 添加导出内容数组,通过键值对进行对应
for( let i = 0; i < list.length; i++ ){
const item = list[i].furniture.product;
data.push({
key: i,
// 内容与表头对应,可自行替换别的参数名称表头
name: item.name,
count: list[i].coun