export-to-exceljs-util 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/ReadMe.md ADDED
@@ -0,0 +1,58 @@
1
+ # export-to-exceljs-util
2
+
3
+ ## 简介
4
+
5
+ `export-to-exceljs-util` 是一个基于 `exceljs` 的前端库,用于实现多表头的 Excel 文件导出功能。
6
+
7
+ ## 安装指南
8
+
9
+ ### 安装命令
10
+
11
+ 您可以通过 npm 或 yarn 来安装`export-to-exceljs-util`。
12
+
13
+ 使用 npm 安装:
14
+
15
+ ```bash
16
+ npm i export-to-exceljs-util
17
+ ```
18
+
19
+ ```javascript
20
+ import ExcelExporter from "export-to-exceljs-util";
21
+
22
+ // 列数据
23
+ const columns = [
24
+ {
25
+ title: "姓名",
26
+ key: "name",
27
+ },
28
+ {
29
+ title: "年龄",
30
+ key: "age",
31
+ },
32
+ {
33
+ title: "地址",
34
+ key: "address",
35
+ },
36
+ ];
37
+
38
+ // 数据列表
39
+ const data = [
40
+ {
41
+ name: "张三",
42
+ age: 25,
43
+ address: "北京市",
44
+ },
45
+ ];
46
+
47
+ // 文件名称
48
+ const fileName = "测试数据.xlsx";
49
+
50
+ // 其他信息(可选)
51
+ const otherInfo = [];
52
+
53
+ // 创建 Excel 导出实例
54
+ const excelExporter = new ExcelExporter(columns, data, fileName, otherInfo);
55
+
56
+ // 执行导出操作
57
+ excelExporter.exportToExcel();
58
+ ```
package/defaultExport.js CHANGED
@@ -20,7 +20,7 @@ const borderStyle = {
20
20
  right: { style: "thin" },
21
21
  };
22
22
  export default class DefaultExport {
23
- constructor(columns, data, filename = "export.xlsx", describe) {
23
+ constructor(columns, data, filename = "export.xlsx", describe = []) {
24
24
  this.columns = columns;
25
25
  this.data = data;
26
26
  this.filename = filename;
package/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { saveAs } from "file-saver";
2
- import { retainTitleAndKey } from './utils/index';
2
+ import { retainTitleAndKey } from "./utils/index";
3
3
  import DefaultExport from "./defaultExport.js";
4
4
 
5
5
  class ExcelExporter {
6
- constructor(columns, data, filename = "export.xlsx", describe) {
6
+ constructor(columns, data, filename = "export.xlsx", describe = []) {
7
7
  this.columns = columns;
8
8
  this.data = data;
9
9
  this.filename = filename;
@@ -23,7 +23,7 @@ class ExcelExporter {
23
23
  }
24
24
 
25
25
  async exportLargeDataSet() {
26
- const formatColumns= retainTitleAndKey(this.columns);
26
+ const formatColumns = retainTitleAndKey(this.columns);
27
27
  const writeBufferWorker = new Worker("/writeBufferWorker.js");
28
28
  writeBufferWorker.postMessage({
29
29
  columns: formatColumns,
@@ -54,4 +54,4 @@ class ExcelExporter {
54
54
  }
55
55
  }
56
56
 
57
- export default ExcelExporter;
57
+ export default ExcelExporter;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "export-to-exceljs-util",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "使用exceljs导出excel文件",
5
5
  "main": "index.js",
6
6
  "scripts": {