@visactor/vtable-export 0.16.4-alpha.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.
Files changed (52) hide show
  1. package/README.md +97 -0
  2. package/cjs/csv/index.d.ts +4 -0
  3. package/cjs/csv/index.js +33 -0
  4. package/cjs/csv/index.js.map +1 -0
  5. package/cjs/excel/index.d.ts +3 -0
  6. package/cjs/excel/index.js +92 -0
  7. package/cjs/excel/index.js.map +1 -0
  8. package/cjs/excel/style.d.ts +6 -0
  9. package/cjs/excel/style.js +84 -0
  10. package/cjs/excel/style.js.map +1 -0
  11. package/cjs/index.d.ts +4 -0
  12. package/cjs/index.js +41 -0
  13. package/cjs/index.js.map +1 -0
  14. package/cjs/util/color.d.ts +152 -0
  15. package/cjs/util/color.js +193 -0
  16. package/cjs/util/color.js.map +1 -0
  17. package/cjs/util/download.d.ts +2 -0
  18. package/cjs/util/download.js +30 -0
  19. package/cjs/util/download.js.map +1 -0
  20. package/cjs/util/encode.d.ts +3 -0
  21. package/cjs/util/encode.js +17 -0
  22. package/cjs/util/encode.js.map +1 -0
  23. package/cjs/util/type.d.ts +6 -0
  24. package/cjs/util/type.js +6 -0
  25. package/cjs/util/type.js.map +1 -0
  26. package/dist/vtable-export.js +76258 -0
  27. package/dist/vtable-export.min.js +92 -0
  28. package/es/csv/index.d.ts +4 -0
  29. package/es/csv/index.js +25 -0
  30. package/es/csv/index.js.map +1 -0
  31. package/es/excel/index.d.ts +3 -0
  32. package/es/excel/index.js +82 -0
  33. package/es/excel/index.js.map +1 -0
  34. package/es/excel/style.d.ts +6 -0
  35. package/es/excel/style.js +75 -0
  36. package/es/excel/style.js.map +1 -0
  37. package/es/index.d.ts +4 -0
  38. package/es/index.js +7 -0
  39. package/es/index.js.map +1 -0
  40. package/es/util/color.d.ts +152 -0
  41. package/es/util/color.js +186 -0
  42. package/es/util/color.js.map +1 -0
  43. package/es/util/download.d.ts +2 -0
  44. package/es/util/download.js +22 -0
  45. package/es/util/download.js.map +1 -0
  46. package/es/util/encode.d.ts +3 -0
  47. package/es/util/encode.js +10 -0
  48. package/es/util/encode.js.map +1 -0
  49. package/es/util/type.d.ts +6 -0
  50. package/es/util/type.js +2 -0
  51. package/es/util/type.js.map +1 -0
  52. package/package.json +87 -0
package/README.md ADDED
@@ -0,0 +1,97 @@
1
+ <div align="center">
2
+ <a href="" target="_blank">
3
+ <img alt="VisActor Logo" width="200" src="https://github.com/VisActor/.github/blob/main/profile/500_200.svg"/>
4
+ </a>
5
+ </div>
6
+
7
+ <div align="center">
8
+ <h1>VTable</h1>
9
+ </div>
10
+
11
+ <div align="center">
12
+
13
+ VTable is not just a high-performance multidimensional data analysis table, but also a grid artist that creates art between rows and columns.React-VTable is a React wrapper of VTable.
14
+
15
+ [![npm Version](https://img.shields.io/npm/v/@visactor/vtable.svg)](https://www.npmjs.com/package/@visactor/react-vtable)
16
+ [![npm Download](https://img.shields.io/npm/dm/@visactor/vtable.svg)](https://www.npmjs.com/package/@visactor/react-vvtable)
17
+ [![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/visactor/vtable/blob/main/LICENSE)
18
+
19
+ </div>
20
+
21
+ # Usage
22
+
23
+ ## Installation
24
+
25
+ [npm package](https://www.npmjs.com/package/@visactor/vtable-export)
26
+
27
+ ```bash
28
+ // npm
29
+ npm install @visactor/vtable-export
30
+
31
+ // yarn
32
+ yarn add @visactor/vtable-export
33
+ ```
34
+
35
+ ## Quick Start
36
+
37
+ ```jsx
38
+ import * as VTable from '@visactor/vtable';
39
+ import { downloadCsv, exportVTableToCsv, downloadExcel, exportVTableToExcel } from '@visactor/vtable-export';
40
+
41
+ const option = {
42
+ header: [
43
+ {
44
+ field: "0",
45
+ caption: "name",
46
+ },
47
+ {
48
+ field: "1",
49
+ caption: "age",
50
+ },
51
+ {
52
+ field: "2",
53
+ caption: "gender",
54
+ },
55
+ {
56
+ field: "3",
57
+ caption: "hobby",
58
+ },
59
+ ],
60
+ records: new Array(1000).fill(["John", 18, "male", "🏀"]),
61
+ };
62
+
63
+ const tableInstance = new VTable.ListTable(option);
64
+
65
+ // donload csv file
66
+ downloadCsv(exportVTableToCsv(tableInstance), 'export-csv');
67
+
68
+ // donload excel file
69
+ downloadExcel(await exportVTableToExcel(tableInstance), 'export-excel');
70
+
71
+ ```
72
+
73
+ ##
74
+
75
+ [More demos and detailed tutorials](https://visactor.io/vtable)
76
+
77
+ # Related Links
78
+
79
+ - [Official website](https://visactor.io/vtable)
80
+
81
+ # Ecosystem
82
+
83
+ | Project | Description |
84
+ | ----------------------------------------------------------- | -------------------------------------------------------------------------------------- |
85
+ | [AI-generated Components](https://visactor.io/ai-vtable) | AI-generated table component. |
86
+
87
+ # Contribution
88
+
89
+ If you would like to contribute, please read the [Code of Conduct ](./CODE_OF_CONDUCT.md) 和 [ Guide](./CONTRIBUTING.zh-CN.md) first。
90
+
91
+ Small streams converge to make great rivers and seas!
92
+
93
+ <a href="https://github.com/visactor/vtable/graphs/contributors"><img src="https://contrib.rocks/image?repo=visactor/vtable" /></a>
94
+
95
+ # License
96
+
97
+ [MIT License](./LICENSE)
@@ -0,0 +1,4 @@
1
+ import type * as VTable from '@visactor/vtable';
2
+ type IVTable = VTable.ListTable | VTable.PivotTable | VTable.PivotChart;
3
+ export declare function exportVTableToCsv(tableInstance: IVTable): string;
4
+ export {};
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.exportVTableToCsv = void 0;
6
+
7
+ const newLine = "\r\n", separator = ",";
8
+
9
+ function exportVTableToCsv(tableInstance) {
10
+ const maxRow = tableInstance.rowCount - 1, maxCol = tableInstance.colCount - 1;
11
+ let copyValue = "";
12
+ for (let row = 0; row <= maxRow; row++) {
13
+ for (let col = 0; col <= maxCol; col++) {
14
+ const copyCellValue = getCopyCellValue(col, row, tableInstance);
15
+ if ("undefined" != typeof Promise && copyCellValue instanceof Promise) ; else {
16
+ const strCellValue = `${copyCellValue}`;
17
+ /^\[object .*\]$/.exec(strCellValue) || (copyValue += strCellValue);
18
+ }
19
+ copyValue += ",";
20
+ }
21
+ copyValue += "\r\n";
22
+ }
23
+ return copyValue;
24
+ }
25
+
26
+ function getCopyCellValue(col, row, tableInstance) {
27
+ const cellRange = tableInstance.getCellRange(col, row), copyStartCol = cellRange.start.col, copyStartRow = cellRange.start.row;
28
+ if (copyStartCol !== col || copyStartRow !== row) return "";
29
+ return tableInstance.getCellValue(col, row);
30
+ }
31
+
32
+ //# sourceMappingURL=index.js.map
33
+ exports.exportVTableToCsv = exportVTableToCsv;
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["csv/index.ts"],"names":[],"mappings":";;;AAKA,MAAM,OAAO,GAAG,MAAM,CAAC;AACvB,MAAM,SAAS,GAAG,GAAG,CAAC;AAEtB,SAAgB,iBAAiB,CAAC,aAAsB;IACtD,MAAM,MAAM,GAAG,CAAC,CAAC;IACjB,MAAM,MAAM,GAAG,aAAa,CAAC,QAAQ,GAAG,CAAC,CAAC;IAC1C,MAAM,MAAM,GAAG,CAAC,CAAC;IACjB,MAAM,MAAM,GAAG,aAAa,CAAC,QAAQ,GAAG,CAAC,CAAC;IAE1C,IAAI,SAAS,GAAG,EAAE,CAAC;IACnB,KAAK,IAAI,GAAG,GAAG,MAAM,EAAE,GAAG,IAAI,MAAM,EAAE,GAAG,EAAE,EAAE;QAC3C,KAAK,IAAI,GAAG,GAAG,MAAM,EAAE,GAAG,IAAI,MAAM,EAAE,GAAG,EAAE,EAAE;YAC3C,MAAM,aAAa,GAAG,gBAAgB,CAAC,GAAG,EAAE,GAAG,EAAE,aAAa,CAAC,CAAC;YAChE,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,aAAa,YAAY,OAAO,EAAE;aAEvE;iBAAM;gBACL,MAAM,YAAY,GAAG,GAAG,aAAa,EAAE,CAAC;gBACxC,IAAI,iBAAiB,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE;iBAEzC;qBAAM;oBACL,SAAS,IAAI,YAAY,CAAC;iBAC3B;aACF;YACD,SAAS,IAAI,SAAS,CAAC;SACxB;QACD,SAAS,IAAI,OAAO,CAAC;KACtB;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAzBD,8CAyBC;AAED,SAAS,gBAAgB,CAAC,GAAW,EAAE,GAAW,EAAE,aAAsB;IACxE,MAAM,SAAS,GAAc,aAAa,CAAC,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAClE,MAAM,YAAY,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC;IACzC,MAAM,YAAY,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC;IAEzC,IAAI,YAAY,KAAK,GAAG,IAAI,YAAY,KAAK,GAAG,EAAE;QAChD,OAAO,EAAE,CAAC;KACX;IAED,MAAM,KAAK,GAAG,aAAa,CAAC,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACnD,OAAO,KAAK,CAAC;AACf,CAAC","file":"index.js","sourcesContent":["import type * as VTable from '@visactor/vtable';\n\ntype IVTable = VTable.ListTable | VTable.PivotTable | VTable.PivotChart;\ntype CellRange = VTable.TYPES.CellRange;\n\nconst newLine = '\\r\\n';\nconst separator = ',';\n\nexport function exportVTableToCsv(tableInstance: IVTable): string {\n const minRow = 0;\n const maxRow = tableInstance.rowCount - 1;\n const minCol = 0;\n const maxCol = tableInstance.colCount - 1;\n\n let copyValue = '';\n for (let row = minRow; row <= maxRow; row++) {\n for (let col = minCol; col <= maxCol; col++) {\n const copyCellValue = getCopyCellValue(col, row, tableInstance);\n if (typeof Promise !== 'undefined' && copyCellValue instanceof Promise) {\n // not support async\n } else {\n const strCellValue = `${copyCellValue}`;\n if (/^\\[object .*\\]$/.exec(strCellValue)) {\n // ignore object\n } else {\n copyValue += strCellValue;\n }\n }\n copyValue += separator;\n }\n copyValue += newLine;\n }\n return copyValue;\n}\n\nfunction getCopyCellValue(col: number, row: number, tableInstance: IVTable): string | Promise<string> | void {\n const cellRange: CellRange = tableInstance.getCellRange(col, row);\n const copyStartCol = cellRange.start.col;\n const copyStartRow = cellRange.start.row;\n\n if (copyStartCol !== col || copyStartRow !== row) {\n return '';\n }\n\n const value = tableInstance.getCellValue(col, row);\n return value;\n}\n"]}
@@ -0,0 +1,3 @@
1
+ import ExcelJS from 'exceljs';
2
+ import type { IVTable } from '../util/type';
3
+ export declare function exportVTableToExcel(tableInstance: IVTable): Promise<ExcelJS.Buffer>;
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+
3
+ var __awaiter = this && this.__awaiter || function(thisArg, _arguments, P, generator) {
4
+ return new (P || (P = Promise))((function(resolve, reject) {
5
+ function fulfilled(value) {
6
+ try {
7
+ step(generator.next(value));
8
+ } catch (e) {
9
+ reject(e);
10
+ }
11
+ }
12
+ function rejected(value) {
13
+ try {
14
+ step(generator.throw(value));
15
+ } catch (e) {
16
+ reject(e);
17
+ }
18
+ }
19
+ function step(result) {
20
+ var value;
21
+ result.done ? resolve(result.value) : (value = result.value, value instanceof P ? value : new P((function(resolve) {
22
+ resolve(value);
23
+ }))).then(fulfilled, rejected);
24
+ }
25
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
26
+ }));
27
+ }, __importDefault = this && this.__importDefault || function(mod) {
28
+ return mod && mod.__esModule ? mod : {
29
+ default: mod
30
+ };
31
+ };
32
+
33
+ Object.defineProperty(exports, "__esModule", {
34
+ value: !0
35
+ }), exports.exportVTableToExcel = void 0;
36
+
37
+ const exceljs_1 = __importDefault(require("exceljs")), encode_1 = require("../util/encode"), style_1 = require("./style");
38
+
39
+ function exportVTableToExcel(tableInstance) {
40
+ return __awaiter(this, void 0, void 0, (function*() {
41
+ const workbook = new exceljs_1.default.Workbook, worksheet = workbook.addWorksheet("sheet1");
42
+ worksheet.properties.defaultRowHeight = 40;
43
+ const columns = [], maxRow = tableInstance.rowCount - 1, maxCol = tableInstance.colCount - 1, mergeCells = [], mergeCellSet = new Set;
44
+ for (let col = 0; col <= maxCol; col++) {
45
+ const colWith = tableInstance.getColWidth(col);
46
+ columns[col] = {
47
+ width: colWith / 6
48
+ };
49
+ for (let row = 0; row <= maxRow; row++) {
50
+ if (0 === col) {
51
+ const rowHeight = tableInstance.getRowHeight(row);
52
+ worksheet.getRow(row + 1).height = rowHeight;
53
+ }
54
+ const cellValue = tableInstance.getCellValue(col, row), cellStyle = tableInstance.getCellStyle(col, row), cellType = tableInstance.getCellType(col, row), cell = worksheet.getCell((0,
55
+ encode_1.encodeCellAddress)(col, row));
56
+ cell.value = getCellValue(cellValue, cellType), cell.font = (0, style_1.getCellFont)(cellStyle, cellType),
57
+ cell.fill = (0, style_1.getCellFill)(cellStyle), cell.border = (0, style_1.getCellBorder)(cellStyle),
58
+ cell.alignment = (0, style_1.getCellAlignment)(cellStyle);
59
+ const cellRange = tableInstance.getCellRange(col, row);
60
+ if (cellRange.start.col !== cellRange.end.col || cellRange.start.row !== cellRange.end.row) {
61
+ const key = `${cellRange.start.col},${cellRange.start.row}:${cellRange.end.col},${cellRange.end.row}}`;
62
+ mergeCellSet.has(key) || (mergeCellSet.add(key), mergeCells.push(cellRange));
63
+ }
64
+ }
65
+ }
66
+ worksheet.columns = columns, mergeCells.forEach((mergeCell => {
67
+ worksheet.mergeCells(mergeCell.start.row + 1, mergeCell.start.col + 1, mergeCell.end.row + 1, mergeCell.end.col + 1);
68
+ }));
69
+ const frozenView = [];
70
+ tableInstance.frozenRowCount > 0 && frozenView.push({
71
+ state: "frozen",
72
+ ySplit: tableInstance.frozenRowCount,
73
+ topLeftCell: (0, encode_1.encodeCellAddress)(0, tableInstance.frozenRowCount)
74
+ }), tableInstance.frozenColCount > 0 && frozenView.push({
75
+ state: "frozen",
76
+ xSplit: tableInstance.frozenColCount,
77
+ topLeftCell: (0, encode_1.encodeCellAddress)(tableInstance.frozenColCount, 0)
78
+ }), worksheet.views = frozenView;
79
+ return yield workbook.xlsx.writeBuffer();
80
+ }));
81
+ }
82
+
83
+ function getCellValue(cellValue, cellType) {
84
+ return "link" === cellType ? {
85
+ text: cellValue,
86
+ hyperlink: cellValue,
87
+ tooltip: cellValue
88
+ } : cellValue;
89
+ }
90
+
91
+ //# sourceMappingURL=index.js.map
92
+ exports.exportVTableToExcel = exportVTableToExcel;
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["excel/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,sDAA8B;AAC9B,2CAAmD;AAEnD,mCAAoF;AAEpF,SAAsB,mBAAmB,CAAC,aAAsB;;QAC9D,MAAM,QAAQ,GAAG,IAAI,iBAAO,CAAC,QAAQ,EAAE,CAAC;QACxC,MAAM,SAAS,GAAG,QAAQ,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QAClD,SAAS,CAAC,UAAU,CAAC,gBAAgB,GAAG,EAAE,CAAC;QAE3C,MAAM,OAAO,GAAG,EAAE,CAAC;QACnB,MAAM,MAAM,GAAG,CAAC,CAAC;QACjB,MAAM,MAAM,GAAG,aAAa,CAAC,QAAQ,GAAG,CAAC,CAAC;QAC1C,MAAM,MAAM,GAAG,CAAC,CAAC;QACjB,MAAM,MAAM,GAAG,aAAa,CAAC,QAAQ,GAAG,CAAC,CAAC;QAC1C,MAAM,UAAU,GAAG,EAAE,CAAC;QACtB,MAAM,YAAY,GAAG,IAAI,GAAG,EAAE,CAAC;QAE/B,KAAK,IAAI,GAAG,GAAG,MAAM,EAAE,GAAG,IAAI,MAAM,EAAE,GAAG,EAAE,EAAE;YAC3C,MAAM,OAAO,GAAG,aAAa,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;YAC/C,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,OAAO,GAAG,CAAC,EAAE,CAAC;YACtC,KAAK,IAAI,GAAG,GAAG,MAAM,EAAE,GAAG,IAAI,MAAM,EAAE,GAAG,EAAE,EAAE;gBAC3C,IAAI,GAAG,KAAK,MAAM,EAAE;oBAClB,MAAM,SAAS,GAAG,aAAa,CAAC,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AO,MAAM,CAAC;IAChB,CAAC;CAAA;AAjFD,kDAiFC;AAED,SAAS,YAAY,CAAC,SAAiB,EAAE,QAAkB;IACzD,IAAI,QAAQ,KAAK,MAAM,EAAE;QACvB,OAAO;YACL,IAAI,EAAE,SAAS;YACf,SAAS,EAAE,SAAS;YACpB,OAAO,EAAE,SAAS;SACnB,CAAC;KACH;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","file":"index.js","sourcesContent":["import ExcelJS from 'exceljs';\nimport { encodeCellAddress } from '../util/encode';\nimport type { CellType, IVTable } from '../util/type';\nimport { getCellAlignment, getCellBorder, getCellFill, getCellFont } from './style';\n\nexport async function exportVTableToExcel(tableInstance: IVTable) {\n const workbook = new ExcelJS.Workbook();\n const worksheet = workbook.addWorksheet('sheet1');\n worksheet.properties.defaultRowHeight = 40;\n\n const columns = [];\n const minRow = 0;\n const maxRow = tableInstance.rowCount - 1;\n const minCol = 0;\n const maxCol = tableInstance.colCount - 1;\n const mergeCells = [];\n const mergeCellSet = new Set();\n\n for (let col = minCol; col <= maxCol; col++) {\n const colWith = tableInstance.getColWidth(col);\n columns[col] = { width: colWith / 6 };\n for (let row = minRow; row <= maxRow; row++) {\n if (col === minCol) {\n const rowHeight = tableInstance.getRowHeight(row);\n const worksheetRow = worksheet.getRow(row + 1);\n // worksheetRow.height = rowHeight * 0.75;\n worksheetRow.height = rowHeight;\n }\n\n const cellValue = tableInstance.getCellValue(col, row);\n const cellStyle = tableInstance.getCellStyle(col, row);\n const cellType = tableInstance.getCellType(col, row);\n\n const cell = worksheet.getCell(encodeCellAddress(col, row));\n cell.value = getCellValue(cellValue, cellType);\n cell.font = getCellFont(cellStyle, cellType);\n cell.fill = getCellFill(cellStyle);\n cell.border = getCellBorder(cellStyle);\n cell.alignment = getCellAlignment(cellStyle);\n\n const cellRange = tableInstance.getCellRange(col, row);\n if (cellRange.start.col !== cellRange.end.col || cellRange.start.row !== cellRange.end.row) {\n const key = `${cellRange.start.col},${cellRange.start.row}:${cellRange.end.col},${cellRange.end.row}}`;\n if (!mergeCellSet.has(key)) {\n mergeCellSet.add(key);\n mergeCells.push(cellRange);\n }\n }\n }\n }\n\n worksheet.columns = columns;\n mergeCells.forEach(mergeCell => {\n worksheet.mergeCells(\n mergeCell.start.row + 1,\n mergeCell.start.col + 1,\n mergeCell.end.row + 1,\n mergeCell.end.col + 1\n );\n });\n\n // frozen\n const frozenView: ExcelJS.WorksheetViewFrozen[] = [];\n // top frozen\n if (tableInstance.frozenRowCount > 0) {\n frozenView.push({\n state: 'frozen',\n ySplit: tableInstance.frozenRowCount,\n // activeCell: 'A1',\n topLeftCell: encodeCellAddress(0, tableInstance.frozenRowCount)\n });\n }\n // left frozen\n if (tableInstance.frozenColCount > 0) {\n frozenView.push({\n state: 'frozen',\n xSplit: tableInstance.frozenColCount,\n // activeCell: 'A1',\n topLeftCell: encodeCellAddress(tableInstance.frozenColCount, 0)\n });\n }\n // not support bottom&right frozen\n worksheet.views = frozenView;\n\n const buffer = await workbook.xlsx.writeBuffer();\n return buffer;\n}\n\nfunction getCellValue(cellValue: string, cellType: CellType) {\n if (cellType === 'link') {\n return {\n text: cellValue,\n hyperlink: cellValue,\n tooltip: cellValue\n };\n }\n return cellValue;\n}\n"]}
@@ -0,0 +1,6 @@
1
+ import type ExcelJS from 'exceljs';
2
+ import type { CellStyle, CellType } from '../util/type';
3
+ export declare function getCellFont(cellStyle: CellStyle, cellType: CellType): Partial<ExcelJS.Font>;
4
+ export declare function getCellFill(cellStyle: CellStyle): ExcelJS.Fill;
5
+ export declare function getCellBorder(cellStyle: CellStyle): Partial<ExcelJS.Borders>;
6
+ export declare function getCellAlignment(cellStyle: CellStyle): Partial<ExcelJS.Alignment>;
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.getCellAlignment = exports.getCellBorder = exports.getCellFill = exports.getCellFont = void 0;
6
+
7
+ const color_1 = require("../util/color");
8
+
9
+ function getCellFont(cellStyle, cellType) {
10
+ return {
11
+ name: getFirstFontFromFontFamily(cellStyle.fontFamily) || "Arial",
12
+ size: cellStyle.fontSize || 10,
13
+ bold: "bold" === cellStyle.fontWeight,
14
+ italic: "italic" === cellStyle.fontStyle,
15
+ color: getColor("link" === cellType ? cellStyle._linkColor : cellStyle.color),
16
+ underline: cellStyle.underline
17
+ };
18
+ }
19
+
20
+ function getFirstFontFromFontFamily(fontFamily) {
21
+ return fontFamily.split(",").map((font => font.trim()))[0];
22
+ }
23
+
24
+ function getCellFill(cellStyle) {
25
+ return {
26
+ type: "pattern",
27
+ pattern: "solid",
28
+ fgColor: getColor(cellStyle.bgColor)
29
+ };
30
+ }
31
+
32
+ function getCellBorder(cellStyle) {
33
+ var _a, _b, _c, _d, _e;
34
+ const {borderColor: borderColor, borderLineWidth: borderLineWidth, borderLineDash: borderLineDash, _strokeArrayWidth: _strokeArrayWidth, _strokeArrayColor: _strokeArrayColor} = cellStyle;
35
+ if (_strokeArrayColor || _strokeArrayWidth) {
36
+ const border = {};
37
+ return _strokeArrayColor && !_strokeArrayColor[0] || _strokeArrayWidth && !_strokeArrayWidth[0] || (border.top = {
38
+ style: getBorderStyle(null !== (_a = null == _strokeArrayWidth ? void 0 : _strokeArrayWidth[0]) && void 0 !== _a ? _a : borderLineWidth, borderLineDash),
39
+ color: getColor(null !== (_b = null == _strokeArrayColor ? void 0 : _strokeArrayColor[0]) && void 0 !== _b ? _b : borderColor)
40
+ }), _strokeArrayColor && !_strokeArrayColor[1] || _strokeArrayWidth && !_strokeArrayWidth[1] || (border.right = {
41
+ style: getBorderStyle(null !== (_c = null == _strokeArrayWidth ? void 0 : _strokeArrayWidth[1]) && void 0 !== _c ? _c : borderLineWidth, borderLineDash),
42
+ color: getColor(null == _strokeArrayColor ? void 0 : _strokeArrayColor[1])
43
+ }), _strokeArrayColor && !_strokeArrayColor[2] || _strokeArrayWidth && !_strokeArrayWidth[2] || (border.bottom = {
44
+ style: getBorderStyle(null !== (_d = null == _strokeArrayWidth ? void 0 : _strokeArrayWidth[2]) && void 0 !== _d ? _d : borderLineWidth, borderLineDash),
45
+ color: getColor(null == _strokeArrayColor ? void 0 : _strokeArrayColor[2])
46
+ }), _strokeArrayColor && !_strokeArrayColor[3] || _strokeArrayWidth && !_strokeArrayWidth[3] || (border.left = {
47
+ style: getBorderStyle(null !== (_e = null == _strokeArrayWidth ? void 0 : _strokeArrayWidth[3]) && void 0 !== _e ? _e : borderLineWidth, borderLineDash),
48
+ color: getColor(null == _strokeArrayColor ? void 0 : _strokeArrayColor[3])
49
+ }), border;
50
+ }
51
+ if (0 === borderLineWidth) return {};
52
+ const border = {
53
+ style: getBorderStyle(borderLineWidth, borderLineDash),
54
+ color: getColor(borderColor)
55
+ };
56
+ return {
57
+ top: border,
58
+ left: border,
59
+ bottom: border,
60
+ right: border
61
+ };
62
+ }
63
+
64
+ function getBorderStyle(lineWidth, borderLineDash) {
65
+ return borderLineDash && borderLineDash.length ? lineWidth <= 2 ? "dashed" : "mediumDashed" : lineWidth <= .5 ? "hair" : lineWidth <= 1 ? "thin" : lineWidth <= 2 ? "medium" : "thick";
66
+ }
67
+
68
+ function getCellAlignment(cellStyle) {
69
+ return {
70
+ horizontal: cellStyle.textAlign || "left",
71
+ vertical: cellStyle.textBaseline || "middle",
72
+ wrapText: cellStyle.autoWrapText || !1
73
+ };
74
+ }
75
+
76
+ function getColor(color) {
77
+ return {
78
+ argb: (0, color_1.rgbaToHex)((0, color_1.colorStringToRGB)(color))
79
+ };
80
+ }
81
+
82
+ //# sourceMappingURL=style.js.map
83
+ exports.getCellFont = getCellFont, exports.getCellFill = getCellFill, exports.getCellBorder = getCellBorder,
84
+ exports.getCellAlignment = getCellAlignment;
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["excel/style.ts"],"names":[],"mappings":";;;AACA,yCAA4D;AAG5D,SAAgB,WAAW,CAAC,SAAoB,EAAE,QAAkB;IAClE,OAAO;QACL,IAAI,EAAE,0BAA0B,CAAC,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5C,QAAQ,EAAE,SAAS,CAAC,YAAY,IAAI,KAAK;KACnC,CAAC;AACX,CAAC;AAND,4CAMC;AAED,SAAS,QAAQ,CAAC,KAAa;IAE7B,OAAO;QACL,IAAI,EAAE,IAAA,iBAAS,EAAC,IAAA,wBAAgB,EAAC,KAAK,CAAC,CAAC;KACzC,CAAC;AACJ,CAAC","file":"style.js","sourcesContent":["import type ExcelJS from 'exceljs';\nimport { colorStringToRGB, rgbaToHex } from '../util/color';\nimport type { CellStyle, CellType, LineDashsDef } from '../util/type';\n\nexport function getCellFont(cellStyle: CellStyle, cellType: CellType): Partial<ExcelJS.Font> {\n return {\n name: getFirstFontFromFontFamily(cellStyle.fontFamily as string) || 'Arial', // only one font family name\n size: cellStyle.fontSize || 10,\n bold: cellStyle.fontWeight === 'bold', // only bold or not\n italic: cellStyle.fontStyle === 'italic', // only italic or not\n color: getColor(cellType === 'link' ? (cellStyle._linkColor as string) : (cellStyle.color as string)),\n underline: cellStyle.underline\n };\n}\n\nfunction getFirstFontFromFontFamily(fontFamily: string) {\n const fonts = fontFamily.split(',').map(font => font.trim());\n return fonts[0];\n}\n\nexport function getCellFill(cellStyle: CellStyle): ExcelJS.Fill {\n return {\n type: 'pattern',\n pattern: 'solid',\n fgColor: getColor(cellStyle.bgColor as string)\n };\n}\n\nexport function getCellBorder(cellStyle: CellStyle): Partial<ExcelJS.Borders> {\n const { borderColor, borderLineWidth, borderLineDash, _strokeArrayWidth, _strokeArrayColor } = cellStyle;\n if (_strokeArrayColor || _strokeArrayWidth) {\n const border: Partial<ExcelJS.Borders> = {};\n if (!((_strokeArrayColor && !_strokeArrayColor[0]) || (_strokeArrayWidth && !_strokeArrayWidth[0]))) {\n border.top = {\n style: getBorderStyle((_strokeArrayWidth?.[0] as number) ?? (borderLineWidth as number), borderLineDash),\n color: getColor((_strokeArrayColor?.[0] as string) ?? (borderColor as string))\n };\n }\n if (!((_strokeArrayColor && !_strokeArrayColor[1]) || (_strokeArrayWidth && !_strokeArrayWidth[1]))) {\n border.right = {\n style: getBorderStyle((_strokeArrayWidth?.[1] as number) ?? (borderLineWidth as number), borderLineDash),\n color: getColor(_strokeArrayColor?.[1] as string)\n };\n }\n if (!((_strokeArrayColor && !_strokeArrayColor[2]) || (_strokeArrayWidth && !_strokeArrayWidth[2]))) {\n border.bottom = {\n style: getBorderStyle((_strokeArrayWidth?.[2] as number) ?? (borderLineWidth as number), borderLineDash),\n color: getColor(_strokeArrayColor?.[2] as string)\n };\n }\n if (!((_strokeArrayColor && !_strokeArrayColor[3]) || (_strokeArrayWidth && !_strokeArrayWidth[3]))) {\n border.left = {\n style: getBorderStyle((_strokeArrayWidth?.[3] as number) ?? (borderLineWidth as number), borderLineDash),\n color: getColor(_strokeArrayColor?.[3] as string)\n };\n }\n return border;\n }\n\n if (borderLineWidth === 0) {\n return {};\n }\n const border = {\n style: getBorderStyle(borderLineWidth as number, borderLineDash),\n color: getColor(borderColor as string)\n };\n return {\n top: border,\n left: border,\n bottom: border,\n right: border\n };\n}\n\nfunction getBorderStyle(lineWidth: number, borderLineDash: LineDashsDef): ExcelJS.BorderStyle {\n // hair:0.5\n // thin:1\n // medium:2.0\n // thick:3.0\n if (borderLineDash && borderLineDash.length) {\n if (lineWidth <= 2) {\n return 'dashed';\n }\n return 'mediumDashed';\n }\n if (lineWidth <= 0.5) {\n return 'hair';\n } else if (lineWidth <= 1) {\n return 'thin';\n } else if (lineWidth <= 2) {\n return 'medium';\n }\n return 'thick';\n}\n\nexport function getCellAlignment(cellStyle: CellStyle): Partial<ExcelJS.Alignment> {\n return {\n horizontal: cellStyle.textAlign || 'left',\n vertical: cellStyle.textBaseline || 'middle',\n wrapText: cellStyle.autoWrapText || false\n } as any;\n}\n\nfunction getColor(color: string) {\n // to do: support gradient color\n return {\n argb: rgbaToHex(colorStringToRGB(color))\n };\n}\n"]}
package/cjs/index.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export { exportVTableToCsv } from './csv';
2
+ export { downloadCsv } from './util/download';
3
+ export { exportVTableToExcel } from './excel';
4
+ export { downloadExcel } from './util/download';
package/cjs/index.js ADDED
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.downloadExcel = exports.exportVTableToExcel = exports.downloadCsv = exports.exportVTableToCsv = void 0;
6
+
7
+ var csv_1 = require("./csv");
8
+
9
+ Object.defineProperty(exports, "exportVTableToCsv", {
10
+ enumerable: !0,
11
+ get: function() {
12
+ return csv_1.exportVTableToCsv;
13
+ }
14
+ });
15
+
16
+ var download_1 = require("./util/download");
17
+
18
+ Object.defineProperty(exports, "downloadCsv", {
19
+ enumerable: !0,
20
+ get: function() {
21
+ return download_1.downloadCsv;
22
+ }
23
+ });
24
+
25
+ var excel_1 = require("./excel");
26
+
27
+ Object.defineProperty(exports, "exportVTableToExcel", {
28
+ enumerable: !0,
29
+ get: function() {
30
+ return excel_1.exportVTableToExcel;
31
+ }
32
+ });
33
+
34
+ var download_2 = require("./util/download");
35
+
36
+ Object.defineProperty(exports, "downloadExcel", {
37
+ enumerable: !0,
38
+ get: function() {
39
+ return download_2.downloadExcel;
40
+ }
41
+ });
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.ts"],"names":[],"mappings":";;;AAAA,6BAA0C;AAAjC,wGAAA,iBAAiB,OAAA;AAC1B,4CAA8C;AAArC,uGAAA,WAAW,OAAA;AAEpB,iCAA8C;AAArC,4GAAA,mBAAmB,OAAA;AAC5B,4CAAgD;AAAvC,yGAAA,aAAa,OAAA","file":"index.js","sourcesContent":["export { exportVTableToCsv } from './csv';\nexport { downloadCsv } from './util/download';\n\nexport { exportVTableToExcel } from './excel';\nexport { downloadExcel } from './util/download';\n"]}
@@ -0,0 +1,152 @@
1
+ export declare function colorStringToRGB(colorString: string): number[];
2
+ export declare function rgbaToHex(rgbaArray: number[]): string;
3
+ export declare const DEFAULT_COLORS: {
4
+ aliceblue: number;
5
+ antiquewhite: number;
6
+ aqua: number;
7
+ aquamarine: number;
8
+ azure: number;
9
+ beige: number;
10
+ bisque: number;
11
+ black: number;
12
+ blanchedalmond: number;
13
+ blue: number;
14
+ blueviolet: number;
15
+ brown: number;
16
+ burlywood: number;
17
+ cadetblue: number;
18
+ chartreuse: number;
19
+ chocolate: number;
20
+ coral: number;
21
+ cornflowerblue: number;
22
+ cornsilk: number;
23
+ crimson: number;
24
+ cyan: number;
25
+ darkblue: number;
26
+ darkcyan: number;
27
+ darkgoldenrod: number;
28
+ darkgray: number;
29
+ darkgreen: number;
30
+ darkgrey: number;
31
+ darkkhaki: number;
32
+ darkmagenta: number;
33
+ darkolivegreen: number;
34
+ darkorange: number;
35
+ darkorchid: number;
36
+ darkred: number;
37
+ darksalmon: number;
38
+ darkseagreen: number;
39
+ darkslateblue: number;
40
+ darkslategray: number;
41
+ darkslategrey: number;
42
+ darkturquoise: number;
43
+ darkviolet: number;
44
+ deeppink: number;
45
+ deepskyblue: number;
46
+ dimgray: number;
47
+ dimgrey: number;
48
+ dodgerblue: number;
49
+ firebrick: number;
50
+ floralwhite: number;
51
+ forestgreen: number;
52
+ fuchsia: number;
53
+ gainsboro: number;
54
+ ghostwhite: number;
55
+ gold: number;
56
+ goldenrod: number;
57
+ gray: number;
58
+ green: number;
59
+ greenyellow: number;
60
+ grey: number;
61
+ honeydew: number;
62
+ hotpink: number;
63
+ indianred: number;
64
+ indigo: number;
65
+ ivory: number;
66
+ khaki: number;
67
+ lavender: number;
68
+ lavenderblush: number;
69
+ lawngreen: number;
70
+ lemonchiffon: number;
71
+ lightblue: number;
72
+ lightcoral: number;
73
+ lightcyan: number;
74
+ lightgoldenrodyellow: number;
75
+ lightgray: number;
76
+ lightgreen: number;
77
+ lightgrey: number;
78
+ lightpink: number;
79
+ lightsalmon: number;
80
+ lightseagreen: number;
81
+ lightskyblue: number;
82
+ lightslategray: number;
83
+ lightslategrey: number;
84
+ lightsteelblue: number;
85
+ lightyellow: number;
86
+ lime: number;
87
+ limegreen: number;
88
+ linen: number;
89
+ magenta: number;
90
+ maroon: number;
91
+ mediumaquamarine: number;
92
+ mediumblue: number;
93
+ mediumorchid: number;
94
+ mediumpurple: number;
95
+ mediumseagreen: number;
96
+ mediumslateblue: number;
97
+ mediumspringgreen: number;
98
+ mediumturquoise: number;
99
+ mediumvioletred: number;
100
+ midnightblue: number;
101
+ mintcream: number;
102
+ mistyrose: number;
103
+ moccasin: number;
104
+ navajowhite: number;
105
+ navy: number;
106
+ oldlace: number;
107
+ olive: number;
108
+ olivedrab: number;
109
+ orange: number;
110
+ orangered: number;
111
+ orchid: number;
112
+ palegoldenrod: number;
113
+ palegreen: number;
114
+ paleturquoise: number;
115
+ palevioletred: number;
116
+ papayawhip: number;
117
+ peachpuff: number;
118
+ peru: number;
119
+ pink: number;
120
+ plum: number;
121
+ powderblue: number;
122
+ purple: number;
123
+ rebeccapurple: number;
124
+ red: number;
125
+ rosybrown: number;
126
+ royalblue: number;
127
+ saddlebrown: number;
128
+ salmon: number;
129
+ sandybrown: number;
130
+ seagreen: number;
131
+ seashell: number;
132
+ sienna: number;
133
+ silver: number;
134
+ skyblue: number;
135
+ slateblue: number;
136
+ slategray: number;
137
+ slategrey: number;
138
+ snow: number;
139
+ springgreen: number;
140
+ steelblue: number;
141
+ tan: number;
142
+ teal: number;
143
+ thistle: number;
144
+ tomato: number;
145
+ turquoise: number;
146
+ violet: number;
147
+ wheat: number;
148
+ white: number;
149
+ whitesmoke: number;
150
+ yellow: number;
151
+ yellowgreen: number;
152
+ };