@corbe30/fortune-excel 1.2.3 → 1.2.5

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.
@@ -21,10 +21,10 @@ jobs:
21
21
  env:
22
22
  NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
23
23
  - run: npm run build-storybook
24
- - uses: actions/upload-pages-artifact@v2
24
+ - uses: actions/upload-pages-artifact@v3
25
25
  with:
26
26
  path: storybook-static
27
27
  - id: deploy
28
- uses: actions/deploy-pages@v3
28
+ uses: actions/deploy-pages@v4
29
29
  with:
30
30
  token: ${{ github.token }}
package/README.md CHANGED
@@ -56,6 +56,16 @@ Developers of [FortuneSheetExcel](https://github.com/zenmrp/FortuneSheetExcel):
56
56
  - [@xxxDeveloper](https://github.com/xxxDeveloper)
57
57
  - [@mengshukeji](https://github.com/mengshukeji)
58
58
 
59
+ Export support:
60
+ - [Orleans9](https://blog.csdn.net/zinchliang) - [article](https://blog.csdn.net/zinchliang/article/details/120262185)
61
+
62
+ ## Contribution
63
+ 1. node v20.17.0
64
+ 2. Use npm and not yarn
65
+ 3. npm run prepare
66
+ 4. npm run build-storybook
67
+ 5. npm run storybook
68
+
59
69
  ## License
60
70
 
61
71
  [MIT](http://opensource.org/licenses/MIT)
@@ -79,14 +79,12 @@ function exportSheetExcel(luckysheetRef) {
79
79
  case 0:
80
80
  luckysheet = luckysheetRef.getAllSheets();
81
81
  workbook = new exceljs_1.default.Workbook();
82
- // 2.创建表格,第二个参数可以配置创建什么样的工作表
83
82
  luckysheet.every(function (table) {
84
83
  var _a, _b;
85
84
  if (((_a = table === null || table === void 0 ? void 0 : table.data) === null || _a === void 0 ? void 0 : _a.length) === 0)
86
85
  return true;
87
86
  var worksheet = workbook.addWorksheet(table.name);
88
- // 3.设置单元格合并,设置单元格边框,设置单元格样式,设置值
89
- (0, ExcelStyle_1.setStyleAndValue)(luckysheetRef, table, worksheet);
87
+ (0, ExcelStyle_1.setStyleAndValue)(table, worksheet);
90
88
  (0, method_1.setMerge)((_b = table === null || table === void 0 ? void 0 : table.config) === null || _b === void 0 ? void 0 : _b.merge, worksheet);
91
89
  (0, ExcelBorder_1.setBorder)(table, worksheet);
92
90
  (0, ExcelImage_1.setImages)(table, worksheet, workbook);
@@ -98,7 +96,6 @@ function exportSheetExcel(luckysheetRef) {
98
96
  case 1:
99
97
  buffer = _a.sent();
100
98
  fileData = new Blob([buffer]);
101
- // 5.保存为文件
102
99
  fileSaver.saveAs(fileData, "".concat(luckysheetRef.getSheet().name, ".xlsx"));
103
100
  return [2 /*return*/];
104
101
  }
@@ -1,3 +1,3 @@
1
1
  import ExcelJS from "exceljs";
2
- declare var setStyleAndValue: (luckysheet: any, table: any, worksheet: ExcelJS.Worksheet) => void;
2
+ declare var setStyleAndValue: (table: any, worksheet: ExcelJS.Worksheet) => void;
3
3
  export { setStyleAndValue };
@@ -13,31 +13,36 @@ var formatHyperlink = function (address) {
13
13
  var sheetCell = address.split("!");
14
14
  return "#'".concat(sheetCell[0], "'!").concat(sheetCell[1] || "A1");
15
15
  };
16
- var setStyleAndValue = function (luckysheet, table, worksheet) {
16
+ var setStyleAndValue = function (table, worksheet) {
17
17
  var cellArr = table === null || table === void 0 ? void 0 : table.data;
18
18
  if (!Array.isArray(cellArr))
19
19
  return;
20
20
  cellArr.forEach(function (row, rowid) {
21
+ var _a, _b;
21
22
  var dbrow = worksheet.getRow(rowid + 1);
22
- //设置单元格行高,默认乘以1.2
23
- dbrow.height = luckysheet.getRowHeight([rowid])[rowid] / 1.2;
23
+ dbrow.height = (((_b = (_a = table.config) === null || _a === void 0 ? void 0 : _a.rowlen) === null || _b === void 0 ? void 0 : _b[rowid]) || 19) / 1.2;
24
24
  row.every(function (cell, columnid) {
25
- var _a;
26
- if (!cell || lodash_1.default.isNil(cell.v) || lodash_1.default.isNaN(cell.v))
27
- return true;
25
+ var _a, _b, _c, _d;
28
26
  if (rowid == 0) {
29
27
  var dobCol = worksheet.getColumn(columnid + 1);
30
- //设置单元格列宽除以8
31
- dobCol.width = luckysheet.getColumnWidth([columnid])[columnid] / 8;
28
+ dobCol.width = (((_b = (_a = table.config) === null || _a === void 0 ? void 0 : _a.columnlen) === null || _b === void 0 ? void 0 : _b[columnid]) || 73) / 8;
32
29
  }
30
+ if (!cell)
31
+ return true;
33
32
  var fill = (0, ExcelConvert_1.fillConvert)(cell.bg);
34
33
  var font = (0, ExcelConvert_1.fontConvert)(cell.ff, cell.fc, cell.bl, cell.it, cell.fs, cell.cl, cell.un);
35
34
  var alignment = (0, ExcelConvert_1.alignmentConvert)(cell.vt, cell.ht, cell.tb && parseInt(cell.tb, 10), cell.tr && parseInt(cell.tr, 10));
35
+ var target = worksheet.getCell(rowid + 1, columnid + 1);
36
+ target.fill = fill;
37
+ target.font = font;
38
+ target.alignment = alignment;
39
+ if ((lodash_1.default.isNil(cell.v) || lodash_1.default.isNaN(cell.v)) && ((_c = cell === null || cell === void 0 ? void 0 : cell.ct) === null || _c === void 0 ? void 0 : _c.t) !== "inlineStr")
40
+ return true;
36
41
  var value;
37
42
  var v = "";
38
43
  var numFmt = undefined;
39
44
  if (cell.hl) {
40
- var hlData = (_a = table.hyperlink) === null || _a === void 0 ? void 0 : _a["".concat(cell.hl.r, "_").concat(cell.hl.c)];
45
+ var hlData = (_d = table.hyperlink) === null || _d === void 0 ? void 0 : _d["".concat(cell.hl.r, "_").concat(cell.hl.c)];
41
46
  if ((hlData === null || hlData === void 0 ? void 0 : hlData.linkType) === "webpage") {
42
47
  v = {
43
48
  text: cell.v,
@@ -79,10 +84,6 @@ var setStyleAndValue = function (luckysheet, table, worksheet) {
79
84
  else {
80
85
  value = v;
81
86
  }
82
- var target = worksheet.getCell(rowid + 1, columnid + 1);
83
- target.fill = fill;
84
- target.font = font;
85
- target.alignment = alignment;
86
87
  target.value = value;
87
88
  target.numFmt = numFmt;
88
89
  return true;
@@ -41,29 +41,28 @@ var FortuneFile_1 = require("../ToFortuneSheet/FortuneFile");
41
41
  var HandleZip_1 = require("../ToFortuneSheet/HandleZip");
42
42
  var ExcelFile_1 = require("../ToExcel/ExcelFile");
43
43
  var transformExcelToFortune = function (e, setSheets, setKey, sheetRef) { return __awaiter(void 0, void 0, void 0, function () {
44
- var excelFile, files, fortuneFile, lsh, config, _i, _a, sheet;
45
- return __generator(this, function (_b) {
46
- switch (_b.label) {
44
+ var excelFile, files, fortuneFile, lsh;
45
+ return __generator(this, function (_a) {
46
+ switch (_a.label) {
47
47
  case 0: return [4 /*yield*/, e.target.files[0].arrayBuffer()];
48
48
  case 1:
49
- excelFile = _b.sent();
49
+ excelFile = _a.sent();
50
50
  return [4 /*yield*/, new HandleZip_1.HandleZip(excelFile).unzipFile()];
51
51
  case 2:
52
- files = _b.sent();
52
+ files = _a.sent();
53
53
  fortuneFile = new FortuneFile_1.FortuneFile(files, excelFile.name);
54
54
  fortuneFile.Parse();
55
55
  lsh = fortuneFile.serialize();
56
- config = lsh.sheets[0].config;
57
- for (_i = 0, _a = lsh.sheets; _i < _a.length; _i++) {
58
- sheet = _a[_i];
59
- delete sheet.config;
60
- }
61
56
  setSheets(lsh.sheets);
62
57
  setKey(function (k) { return k + 1; });
63
58
  setTimeout(function () {
64
59
  var _a, _b;
65
- (_a = sheetRef.current) === null || _a === void 0 ? void 0 : _a.setColumnWidth((config === null || config === void 0 ? void 0 : config.columnlen) || {});
66
- (_b = sheetRef.current) === null || _b === void 0 ? void 0 : _b.setRowHeight((config === null || config === void 0 ? void 0 : config.rowlen) || {});
60
+ for (var _i = 0, _c = lsh.sheets; _i < _c.length; _i++) {
61
+ var sheet = _c[_i];
62
+ var config = sheet.config;
63
+ (_a = sheetRef.current) === null || _a === void 0 ? void 0 : _a.setColumnWidth((config === null || config === void 0 ? void 0 : config.columnlen) || {}, { id: sheet.id });
64
+ (_b = sheetRef.current) === null || _b === void 0 ? void 0 : _b.setRowHeight((config === null || config === void 0 ? void 0 : config.rowlen) || {}, { id: sheet.id });
65
+ }
67
66
  }, 1);
68
67
  return [2 /*return*/];
69
68
  }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "workspaces": [
4
4
  "src/*"
5
5
  ],
6
- "version": "1.2.3",
6
+ "version": "1.2.5",
7
7
  "description": "An Excel import/export import library for FortuneSheet",
8
8
  "main": "dist/main.js",
9
9
  "types": "dist/main.d.ts",