1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import React, { useEffect } from 'react';
import { ExportExcel, ExportExcelZip } from '../index';
import { Button } from 'antd';
const ExportExcelDemo = (props) => {
const exportExcelBtn = () => {
ExportExcel({
name: '下载Excel',
content: [
{
sheetData: [
{ one: '一行一列', two: '一行二列' },
{ one: '二行一列', two: '二行二列' },
],
sheetName: 'sheet1',
sheetFilter: ['two', 'one'],
sheetHeader: ['第一列', '第二列'],
columnWidths: [20, 20],
},
{
sheetData: [
{ one: '一行一列', two: '一行二列' },
{ one: '二行一列', two: '二行二列' },
],
sheetName: 'sheet2',
sheetFilter: ['one', 'two'],
sheetHeader: ['第一列', '第二列'],
columnWidths: [20, 20],
},
],
});
};
const exportExcelZipBtn = () => {
ExportExcelZip({
name: '下载Excel',
content: [
{
sheetData: [
{ one: '一行一列', two: '一行二列' },
{ one: '二行一列', two: '二行二列' },
],
sheetName: 'sheet1',
sheetFilter: ['two', 'one'],
sheetHeader: ['第一列', '第二列'],
columnWidths: [20, 20],
},
{
sheetData: [
{ one: '一行一列', two: '一行二列' },
{ one: '二行一列', two: '二行二列' },
],
sheetName: 'sheet2',
sheetFilter: ['one', 'two'],
sheetHeader: ['第一列', '第二列'],
columnWidths: [20, 20],
},
],
});
};
return (
<>
<Button onClick={exportExcelBtn} style={{ marginRight: '10px' }}>
下载Excel
</Button>
<Button onClick={exportExcelZipBtn}>下载压缩Excel</Button>
</>
);
};
export default ExportExcelDemo;