Commit 7789cad8 authored by 李纪文's avatar 李纪文

Merge branch 'release' into 'dev'

fix: Excel表格组件 See merge request !23
parents a46d9e9a 483458b6
Pipeline #25530 failed with stages
in 1 minute 26 seconds
......@@ -71,7 +71,14 @@ export default {
},
{
title: '通用',
children: ['BasicTools', 'ImageSelect', 'QuotaSelect', 'TimeRangePicker', 'MqttView'],
children: [
'BasicTools',
'ImageSelect',
'QuotaSelect',
'TimeRangePicker',
'MqttView',
'ExportExcel',
],
},
{
title: '数据录入',
......
......@@ -144,6 +144,8 @@
"form-render": "^0.9.12",
"highcharts": "^9.0.1",
"highcharts-react-official": "^3.0.0",
"js-export-excel": "^1.1.4",
"jszip": "^3.5.0",
"mqtt-client": "^1.0.11",
"parseForm": "0.0.8"
},
......
......@@ -2,6 +2,10 @@
All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.2.1](https://g.civnet.cn:8443/ReactWeb5/wisdom-components/compare/@wisdom-components/basictools@1.2.0...@wisdom-components/basictools@1.2.1) (2021-04-06)
**Note:** Version bump only for package @wisdom-components/basictools
# 1.2.0 (2021-04-02)
### Features
......
{
"name": "@wisdom-components/basictools",
"version": "1.2.0",
"version": "1.2.1",
"description": "> TODO: description",
"author": "tuqian <webtuqian@163.com>",
"homepage": "",
......
......@@ -2,6 +2,10 @@
All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.3.1](https://g.civnet.cn:8443/ReactWeb5/wisdom-components/compare/@wisdom-components/devicetree@1.3.0...@wisdom-components/devicetree@1.3.1) (2021-04-06)
**Note:** Version bump only for package @wisdom-components/devicetree
# [1.3.0](https://g.civnet.cn:8443/ReactWeb5/wisdom-components/compare/@wisdom-components/devicetree@1.2.0...@wisdom-components/devicetree@1.3.0) (2021-04-02)
### Bug Fixes
......
{
"name": "@wisdom-components/devicetree",
"version": "1.3.0",
"version": "1.3.1",
"description": "> TODO: description",
"author": "tuqian <webtuqian@163.com>",
"homepage": "",
......
......@@ -2,6 +2,10 @@
All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.3.1](https://g.civnet.cn:8443/ReactWeb5/wisdom-components/compare/@wisdom-components/empty@1.3.0...@wisdom-components/empty@1.3.1) (2021-04-06)
**Note:** Version bump only for package @wisdom-components/empty
# [1.3.0](https://g.civnet.cn:8443/ReactWeb5/wisdom-components/compare/@wisdom-components/empty@1.2.0...@wisdom-components/empty@1.3.0) (2021-04-02)
### Features
......
{
"name": "@wisdom-components/empty",
"version": "1.3.0",
"version": "1.3.1",
"description": "@wisdom-components/empty",
"author": "tuqian <webtuqian@163.com>",
"homepage": "",
......
# Change Log
All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## 1.0.1 (2021-04-06)
### Bug Fixes
- Excel 表格组件 ([903bbe6](https://g.civnet.cn:8443/ReactWeb5/wisdom-components/commits/903bbe638982ac534f4e99c6a3cb006e90381be9))
- Excel 表格组件 ([a6789b8](https://g.civnet.cn:8443/ReactWeb5/wisdom-components/commits/a6789b859c7efd9ccb3def4587daadd1c54cd242))
# `@wisdom-components/ExportExcel`
> TODO: description
## Usage
```
const exportExcel = require('@wisdom-components/ExportExcel');
// TODO: DEMONSTRATE API
```
{
"name": "@wisdom-components/exportexcel",
"version": "1.0.1",
"description": "> TODO: description",
"author": "lijiwen <961370825@qq.com>",
"homepage": "",
"license": "ISC",
"main": "lib/ExportExcel.js",
"directories": {
"lib": "lib",
"test": "__tests__"
},
"files": [
"lib"
],
"publishConfig": {
"registry": "https://g.civnet.cn:4873/"
},
"repository": {
"type": "git",
"url": "https://g.civnet.cn:8443/ReactWeb5/wisdom-components.git"
},
"scripts": {
"test": "echo \"Error: run tests from root\" && exit 1"
},
"dependencies": {
"js-export-excel": "^1.1.4",
"jszip": "^3.5.0"
}
}
---
title: ExportExcel - Excel表格导出
nav:
title: 组件
path: /components
group:
path: /
---
# PandaExportExcel Excel 表格导出
<code src="./demos/Base.tsx">
## API
| 参数 | 说明 | 类型 | 默认值 |
| ------- | ------------------------------------- | ------ | ------- |
| name | Excel 表格名称 | string | 'excel' |
| content | Excel 表格内容,支持多个 sheet[{},{}] | array | [] |
## content 每一项内容
| 名称 | 描述 | 类型 |
| ------------ | ------------------- | ------- |
| sheetData | 数据 | array |
| sheetName | sheet 名字 | string |
| sheetFilter | 列过滤 | array[] |
| sheetHeader | 表头 | array[] |
| columnWidths | 列宽 需与列顺序对应 | array[] |
import React, { useEffect } from 'react';
import { ExportExcel, ExportExcelZip } from '../ExportExcel';
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;
import React, { useEffect } from 'react';
import PropTypes from 'prop-types';
import ExportJsonExcel from 'js-export-excel';
import JSZip from 'jszip';
// 导出Excel表格
const ExportExcel = (props) => {
var option = {};
option.fileName = props.name;
option.datas = props.content;
var toExcel = new ExportJsonExcel(option); //new
toExcel.saveExcel();
};
ExportExcel.defaultProps = {
name: 'excel',
content: [],
};
ExportExcel.propTypes = {
name: PropTypes.string, // 下载文件名称
content: PropTypes.array, // 下载文件内容
};
// 导出压缩Excel表格
const ExportExcelZip = (props) => {
var option = {};
option.fileName = props.name;
option.saveAsBlob = true;
option.datas = props.content;
var toExcel = new ExportJsonExcel(option); //new
let file = toExcel.saveExcel();
// 压缩文件
var zip = new JSZip();
// 多个excel 依次加入(fileName不能相同)
zip.file(file.name, file);
zip.generateAsync({ type: 'blob' }).then(function (content) {
// see FileSaver.js
saveAs(content, `${props.name}.zip`); // 下载文件
});
};
ExportExcelZip.defaultProps = {
name: 'excel',
content: [],
};
ExportExcelZip.propTypes = {
name: PropTypes.string, // 下载文件名称
content: PropTypes.array, // 下载文件内容
};
export { ExportExcel, ExportExcelZip };
......@@ -2,6 +2,10 @@
All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.4.1](https://g.civnet.cn:8443/ReactWeb5/wisdom-components/compare/@wisdom-components/historyinfo@1.4.0...@wisdom-components/historyinfo@1.4.1) (2021-04-06)
**Note:** Version bump only for package @wisdom-components/historyinfo
# [1.4.0](https://g.civnet.cn:8443/ReactWeb5/wisdom-components/compare/@wisdom-components/historyinfo@1.3.1...@wisdom-components/historyinfo@1.4.0) (2021-04-02)
### Bug Fixes
......
{
"name": "@wisdom-components/historyinfo",
"version": "1.4.0",
"version": "1.4.1",
"description": "> TODO: description",
"author": "tuqian <webtuqian@163.com>",
"homepage": "",
......@@ -25,7 +25,7 @@
},
"dependencies": {
"@wisdom-components/Empty": "^1.2.0",
"@wisdom-components/timerangepicker": "1.3.0",
"@wisdom-components/timerangepicker": "1.3.1",
"classnames": "^2.2.6",
"highcharts": "^9.0.1",
"highcharts-react-official": "^3.0.0",
......
......@@ -2,6 +2,10 @@
All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.3.1](https://g.civnet.cn:8443/ReactWeb5/wisdom-components/compare/@wisdom-components/imageselect@1.3.0...@wisdom-components/imageselect@1.3.1) (2021-04-06)
**Note:** Version bump only for package @wisdom-components/imageselect
# [1.3.0](https://g.civnet.cn:8443/ReactWeb5/wisdom-components/compare/@wisdom-components/imageselect@1.2.0...@wisdom-components/imageselect@1.3.0) (2021-04-02)
### Bug Fixes
......
{
"name": "@wisdom-components/imageselect",
"version": "1.3.0",
"version": "1.3.1",
"description": "> TODO: description",
"author": "tuqian <webtuqian@163.com>",
"homepage": "",
......
......@@ -2,6 +2,10 @@
All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.2.3](https://g.civnet.cn:8443/ReactWeb5/wisdom-components/compare/@wisdom-components/mqttview@1.2.2...@wisdom-components/mqttview@1.2.3) (2021-04-06)
**Note:** Version bump only for package @wisdom-components/mqttview
## [1.2.2](https://g.civnet.cn:8443/ReactWeb5/wisdom-components/compare/@wisdom-components/mqttview@1.2.1...@wisdom-components/mqttview@1.2.2) (2021-04-02)
**Note:** Version bump only for package @wisdom-components/mqttview
......
{
"name": "@wisdom-components/mqttview",
"version": "1.2.2",
"version": "1.2.3",
"description": "> TODO: description",
"author": "lijiwen <961370825@qq.com>",
"homepage": "",
......
......@@ -2,6 +2,10 @@
All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.2.1](https://g.civnet.cn:8443/ReactWeb5/wisdom-components/compare/parseform@1.2.0...parseform@1.2.1) (2021-04-06)
**Note:** Version bump only for package parseform
# 1.2.0 (2021-04-02)
### Bug Fixes
......
{
"name": "parseform",
"version": "1.2.0",
"version": "1.2.1",
"description": "> TODO: description",
"author": "lijiwen <961370825@qq.com>",
"homepage": "",
......
......@@ -2,6 +2,10 @@
All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.3.1](https://g.civnet.cn:8443/ReactWeb5/wisdom-components/compare/@wisdom-components/quotaselect@1.3.0...@wisdom-components/quotaselect@1.3.1) (2021-04-06)
**Note:** Version bump only for package @wisdom-components/quotaselect
# [1.3.0](https://g.civnet.cn:8443/ReactWeb5/wisdom-components/compare/@wisdom-components/quotaselect@1.2.1...@wisdom-components/quotaselect@1.3.0) (2021-04-02)
### Features
......
{
"name": "@wisdom-components/quotaselect",
"version": "1.3.0",
"version": "1.3.1",
"description": "> TODO: description",
"author": "tuqian <webtuqian@163.com>",
"homepage": "",
......
......@@ -2,6 +2,10 @@
All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.2.1](https://g.civnet.cn:8443/ReactWeb5/wisdom-components/compare/@wisdom-components/realtimeinfo@1.2.0...@wisdom-components/realtimeinfo@1.2.1) (2021-04-06)
**Note:** Version bump only for package @wisdom-components/realtimeinfo
# [1.2.0](https://g.civnet.cn:8443/ReactWeb5/wisdom-components/compare/@wisdom-components/realtimeinfo@1.1.1...@wisdom-components/realtimeinfo@1.2.0) (2021-04-02)
### Features
......
{
"name": "@wisdom-components/realtimeinfo",
"version": "1.2.0",
"version": "1.2.1",
"description": "> TODO: description",
"author": "tuqian <webtuqian@163.com>",
"homepage": "",
......
......@@ -2,6 +2,10 @@
All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.3.1](https://g.civnet.cn:8443/ReactWeb5/wisdom-components/compare/@wisdom-components/timerangepicker@1.3.0...@wisdom-components/timerangepicker@1.3.1) (2021-04-06)
**Note:** Version bump only for package @wisdom-components/timerangepicker
# [1.3.0](https://g.civnet.cn:8443/ReactWeb5/wisdom-components/compare/@wisdom-components/timerangepicker@1.2.1...@wisdom-components/timerangepicker@1.3.0) (2021-04-02)
### Bug Fixes
......
{
"name": "@wisdom-components/timerangepicker",
"version": "1.3.0",
"version": "1.3.1",
"description": "> TODO: description",
"author": "tuqian <webtuqian@163.com>",
"homepage": "",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment