@simplysm/excel 1.0.138 → 13.0.0-beta.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 (207) hide show
  1. package/.cache/typecheck-browser.tsbuildinfo +1 -0
  2. package/.cache/typecheck-node.tsbuildinfo +1 -0
  3. package/.cache/typecheck-tests-browser.tsbuildinfo +1 -0
  4. package/.cache/typecheck-tests-node.tsbuildinfo +1 -0
  5. package/README.md +491 -0
  6. package/dist/core-common/src/common.types.d.ts +74 -0
  7. package/dist/core-common/src/common.types.d.ts.map +1 -0
  8. package/dist/core-common/src/env.d.ts +6 -0
  9. package/dist/core-common/src/env.d.ts.map +1 -0
  10. package/dist/core-common/src/errors/argument-error.d.ts +25 -0
  11. package/dist/core-common/src/errors/argument-error.d.ts.map +1 -0
  12. package/dist/core-common/src/errors/not-implemented-error.d.ts +29 -0
  13. package/dist/core-common/src/errors/not-implemented-error.d.ts.map +1 -0
  14. package/dist/core-common/src/errors/sd-error.d.ts +27 -0
  15. package/dist/core-common/src/errors/sd-error.d.ts.map +1 -0
  16. package/dist/core-common/src/errors/timeout-error.d.ts +31 -0
  17. package/dist/core-common/src/errors/timeout-error.d.ts.map +1 -0
  18. package/dist/core-common/src/extensions/arr-ext.d.ts +15 -0
  19. package/dist/core-common/src/extensions/arr-ext.d.ts.map +1 -0
  20. package/dist/core-common/src/extensions/arr-ext.helpers.d.ts +19 -0
  21. package/dist/core-common/src/extensions/arr-ext.helpers.d.ts.map +1 -0
  22. package/dist/core-common/src/extensions/arr-ext.types.d.ts +215 -0
  23. package/dist/core-common/src/extensions/arr-ext.types.d.ts.map +1 -0
  24. package/dist/core-common/src/extensions/map-ext.d.ts +57 -0
  25. package/dist/core-common/src/extensions/map-ext.d.ts.map +1 -0
  26. package/dist/core-common/src/extensions/set-ext.d.ts +36 -0
  27. package/dist/core-common/src/extensions/set-ext.d.ts.map +1 -0
  28. package/dist/core-common/src/features/debounce-queue.d.ts +53 -0
  29. package/dist/core-common/src/features/debounce-queue.d.ts.map +1 -0
  30. package/dist/core-common/src/features/event-emitter.d.ts +66 -0
  31. package/dist/core-common/src/features/event-emitter.d.ts.map +1 -0
  32. package/dist/core-common/src/features/serial-queue.d.ts +47 -0
  33. package/dist/core-common/src/features/serial-queue.d.ts.map +1 -0
  34. package/dist/core-common/src/index.d.ts +32 -0
  35. package/dist/core-common/src/index.d.ts.map +1 -0
  36. package/dist/core-common/src/types/date-only.d.ts +152 -0
  37. package/dist/core-common/src/types/date-only.d.ts.map +1 -0
  38. package/dist/core-common/src/types/date-time.d.ts +96 -0
  39. package/dist/core-common/src/types/date-time.d.ts.map +1 -0
  40. package/dist/core-common/src/types/lazy-gc-map.d.ts +80 -0
  41. package/dist/core-common/src/types/lazy-gc-map.d.ts.map +1 -0
  42. package/dist/core-common/src/types/time.d.ts +68 -0
  43. package/dist/core-common/src/types/time.d.ts.map +1 -0
  44. package/dist/core-common/src/types/uuid.d.ts +35 -0
  45. package/dist/core-common/src/types/uuid.d.ts.map +1 -0
  46. package/dist/core-common/src/utils/bytes.d.ts +51 -0
  47. package/dist/core-common/src/utils/bytes.d.ts.map +1 -0
  48. package/dist/core-common/src/utils/date-format.d.ts +90 -0
  49. package/dist/core-common/src/utils/date-format.d.ts.map +1 -0
  50. package/dist/core-common/src/utils/json.d.ts +34 -0
  51. package/dist/core-common/src/utils/json.d.ts.map +1 -0
  52. package/dist/core-common/src/utils/num.d.ts +60 -0
  53. package/dist/core-common/src/utils/num.d.ts.map +1 -0
  54. package/dist/core-common/src/utils/obj.d.ts +258 -0
  55. package/dist/core-common/src/utils/obj.d.ts.map +1 -0
  56. package/dist/core-common/src/utils/path.d.ts +23 -0
  57. package/dist/core-common/src/utils/path.d.ts.map +1 -0
  58. package/dist/core-common/src/utils/primitive.d.ts +18 -0
  59. package/dist/core-common/src/utils/primitive.d.ts.map +1 -0
  60. package/dist/core-common/src/utils/str.d.ts +103 -0
  61. package/dist/core-common/src/utils/str.d.ts.map +1 -0
  62. package/dist/core-common/src/utils/template-strings.d.ts +84 -0
  63. package/dist/core-common/src/utils/template-strings.d.ts.map +1 -0
  64. package/dist/core-common/src/utils/transferable.d.ts +47 -0
  65. package/dist/core-common/src/utils/transferable.d.ts.map +1 -0
  66. package/dist/core-common/src/utils/wait.d.ts +19 -0
  67. package/dist/core-common/src/utils/wait.d.ts.map +1 -0
  68. package/dist/core-common/src/utils/xml.d.ts +36 -0
  69. package/dist/core-common/src/utils/xml.d.ts.map +1 -0
  70. package/dist/core-common/src/zip/sd-zip.d.ts +80 -0
  71. package/dist/core-common/src/zip/sd-zip.d.ts.map +1 -0
  72. package/dist/excel/src/excel-cell.d.ts +68 -0
  73. package/dist/excel/src/excel-cell.d.ts.map +1 -0
  74. package/dist/excel/src/excel-col.d.ts +19 -0
  75. package/dist/excel/src/excel-col.d.ts.map +1 -0
  76. package/dist/excel/src/excel-row.d.ts +17 -0
  77. package/dist/excel/src/excel-row.d.ts.map +1 -0
  78. package/dist/excel/src/excel-workbook.d.ts +66 -0
  79. package/dist/excel/src/excel-workbook.d.ts.map +1 -0
  80. package/dist/excel/src/excel-worksheet.d.ts +102 -0
  81. package/dist/excel/src/excel-worksheet.d.ts.map +1 -0
  82. package/dist/excel/src/excel-wrapper.d.ts +42 -0
  83. package/dist/excel/src/excel-wrapper.d.ts.map +1 -0
  84. package/dist/excel/src/index.d.ts +9 -0
  85. package/dist/excel/src/index.d.ts.map +1 -0
  86. package/dist/excel/src/types.d.ts +445 -0
  87. package/dist/excel/src/types.d.ts.map +1 -0
  88. package/dist/excel/src/utils/excel-utils.d.ts +50 -0
  89. package/dist/excel/src/utils/excel-utils.d.ts.map +1 -0
  90. package/dist/excel/src/utils/zip-cache.d.ts +23 -0
  91. package/dist/excel/src/utils/zip-cache.d.ts.map +1 -0
  92. package/dist/excel/src/xml/excel-xml-content-type.d.ts +12 -0
  93. package/dist/excel/src/xml/excel-xml-content-type.d.ts.map +1 -0
  94. package/dist/excel/src/xml/excel-xml-drawing.d.ts +26 -0
  95. package/dist/excel/src/xml/excel-xml-drawing.d.ts.map +1 -0
  96. package/dist/excel/src/xml/excel-xml-relationship.d.ts +18 -0
  97. package/dist/excel/src/xml/excel-xml-relationship.d.ts.map +1 -0
  98. package/dist/excel/src/xml/excel-xml-shared-string.d.ts +19 -0
  99. package/dist/excel/src/xml/excel-xml-shared-string.d.ts.map +1 -0
  100. package/dist/excel/src/xml/excel-xml-style.d.ts +31 -0
  101. package/dist/excel/src/xml/excel-xml-style.d.ts.map +1 -0
  102. package/dist/excel/src/xml/excel-xml-unknown.d.ts +11 -0
  103. package/dist/excel/src/xml/excel-xml-unknown.d.ts.map +1 -0
  104. package/dist/excel/src/xml/excel-xml-workbook.d.ts +22 -0
  105. package/dist/excel/src/xml/excel-xml-workbook.d.ts.map +1 -0
  106. package/dist/excel/src/xml/excel-xml-worksheet.d.ts +103 -0
  107. package/dist/excel/src/xml/excel-xml-worksheet.d.ts.map +1 -0
  108. package/dist/excel-cell.js +261 -0
  109. package/dist/excel-cell.js.map +7 -0
  110. package/dist/excel-col.js +36 -0
  111. package/dist/excel-col.js.map +7 -0
  112. package/dist/excel-row.js +31 -0
  113. package/dist/excel-row.js.map +7 -0
  114. package/dist/excel-workbook.js +137 -0
  115. package/dist/excel-workbook.js.map +7 -0
  116. package/dist/excel-worksheet.js +279 -0
  117. package/dist/excel-worksheet.js.map +7 -0
  118. package/dist/excel-wrapper.js +220 -0
  119. package/dist/excel-wrapper.js.map +7 -0
  120. package/dist/index.js +9 -15
  121. package/dist/index.js.map +7 -1
  122. package/dist/types.js +1 -0
  123. package/dist/types.js.map +7 -0
  124. package/dist/utils/excel-utils.js +162 -0
  125. package/dist/utils/excel-utils.js.map +7 -0
  126. package/dist/utils/zip-cache.js +74 -0
  127. package/dist/utils/zip-cache.js.map +7 -0
  128. package/dist/xml/excel-xml-content-type.js +57 -0
  129. package/dist/xml/excel-xml-content-type.js.map +7 -0
  130. package/dist/xml/excel-xml-drawing.js +77 -0
  131. package/dist/xml/excel-xml-drawing.js.map +7 -0
  132. package/dist/xml/excel-xml-relationship.js +72 -0
  133. package/dist/xml/excel-xml-relationship.js.map +7 -0
  134. package/dist/xml/excel-xml-shared-string.js +61 -0
  135. package/dist/xml/excel-xml-shared-string.js.map +7 -0
  136. package/dist/xml/excel-xml-style.js +313 -0
  137. package/dist/xml/excel-xml-style.js.map +7 -0
  138. package/dist/xml/excel-xml-unknown.js +11 -0
  139. package/dist/xml/excel-xml-unknown.js.map +7 -0
  140. package/dist/xml/excel-xml-workbook.js +94 -0
  141. package/dist/xml/excel-xml-workbook.js.map +7 -0
  142. package/dist/xml/excel-xml-worksheet.js +405 -0
  143. package/dist/xml/excel-xml-worksheet.js.map +7 -0
  144. package/package.json +13 -7
  145. package/src/excel-cell.ts +326 -0
  146. package/src/excel-col.ts +43 -0
  147. package/src/excel-row.ts +37 -0
  148. package/src/excel-workbook.ts +206 -0
  149. package/src/excel-worksheet.ts +380 -0
  150. package/src/excel-wrapper.ts +219 -0
  151. package/src/index.ts +13 -9
  152. package/src/types.ts +396 -0
  153. package/src/utils/excel-utils.ts +201 -0
  154. package/src/utils/zip-cache.ts +103 -0
  155. package/src/xml/excel-xml-content-type.ts +64 -0
  156. package/src/xml/excel-xml-drawing.ts +87 -0
  157. package/src/xml/excel-xml-relationship.ts +86 -0
  158. package/src/xml/excel-xml-shared-string.ts +80 -0
  159. package/src/xml/excel-xml-style.ts +393 -0
  160. package/src/xml/excel-xml-unknown.ts +11 -0
  161. package/src/xml/excel-xml-workbook.ts +112 -0
  162. package/src/xml/excel-xml-worksheet.ts +544 -0
  163. package/tests/excel-cell.spec.ts +407 -0
  164. package/tests/excel-col.spec.ts +112 -0
  165. package/tests/excel-row.spec.ts +71 -0
  166. package/tests/excel-workbook.spec.ts +166 -0
  167. package/tests/excel-worksheet.spec.ts +389 -0
  168. package/tests/excel-wrapper.spec.ts +275 -0
  169. package/tests/fixtures/logo.png +0 -0
  170. package/tests/image-insert.spec.ts +188 -0
  171. package/tests/utils/excel-utils.spec.ts +240 -0
  172. package/dist/ExcelCell.d.ts +0 -13
  173. package/dist/ExcelCell.js +0 -161
  174. package/dist/ExcelCell.js.map +0 -1
  175. package/dist/ExcelCellStyle.d.ts +0 -31
  176. package/dist/ExcelCellStyle.js +0 -312
  177. package/dist/ExcelCellStyle.js.map +0 -1
  178. package/dist/ExcelColumn.d.ts +0 -8
  179. package/dist/ExcelColumn.js +0 -49
  180. package/dist/ExcelColumn.js.map +0 -1
  181. package/dist/ExcelRow.d.ts +0 -7
  182. package/dist/ExcelRow.js +0 -21
  183. package/dist/ExcelRow.js.map +0 -1
  184. package/dist/ExcelWorkbook.d.ts +0 -24
  185. package/dist/ExcelWorkbook.js +0 -418
  186. package/dist/ExcelWorkbook.js.map +0 -1
  187. package/dist/ExcelWorksheet.d.ts +0 -14
  188. package/dist/ExcelWorksheet.js +0 -31
  189. package/dist/ExcelWorksheet.js.map +0 -1
  190. package/dist/index.d.ts +0 -9
  191. package/dist/utils/ExcelUtils.d.ts +0 -14
  192. package/dist/utils/ExcelUtils.js +0 -66
  193. package/dist/utils/ExcelUtils.js.map +0 -1
  194. package/dist/utils/XmlConvert.d.ts +0 -4
  195. package/dist/utils/XmlConvert.js +0 -64
  196. package/dist/utils/XmlConvert.js.map +0 -1
  197. package/src/ExcelCell.ts +0 -163
  198. package/src/ExcelCellStyle.ts +0 -297
  199. package/src/ExcelColumn.ts +0 -46
  200. package/src/ExcelRow.ts +0 -17
  201. package/src/ExcelWorkbook.ts +0 -369
  202. package/src/ExcelWorksheet.ts +0 -27
  203. package/src/utils/ExcelUtils.ts +0 -68
  204. package/src/utils/XmlConvert.ts +0 -20
  205. package/tsconfig.build.json +0 -18
  206. package/tsconfig.json +0 -18
  207. package/tslint.json +0 -5
@@ -1,64 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __generator = (this && this.__generator) || function (thisArg, body) {
11
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
- function verb(n) { return function (v) { return step([n, v]); }; }
14
- function step(op) {
15
- if (f) throw new TypeError("Generator is already executing.");
16
- while (_) try {
17
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
- if (y = 0, t) op = [op[0] & 2, t.value];
19
- switch (op[0]) {
20
- case 0: case 1: t = op; break;
21
- case 4: _.label++; return { value: op[1], done: false };
22
- case 5: _.label++; y = op[1]; op = [0]; continue;
23
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
- default:
25
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
- if (t[2]) _.ops.pop();
30
- _.trys.pop(); continue;
31
- }
32
- op = body.call(thisArg, _);
33
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
- }
36
- };
37
- Object.defineProperty(exports, "__esModule", { value: true });
38
- var xml2js = require("xml2js");
39
- var XmlConvert = (function () {
40
- function XmlConvert() {
41
- }
42
- XmlConvert.parseAsync = function (str) {
43
- return __awaiter(this, void 0, Promise, function () {
44
- return __generator(this, function (_a) {
45
- return [2, new Promise(function (resolve, reject) {
46
- xml2js.parseString(str, function (err, parsed) {
47
- if (err) {
48
- reject(err);
49
- return;
50
- }
51
- resolve(parsed);
52
- });
53
- })];
54
- });
55
- });
56
- };
57
- XmlConvert.stringify = function (obj) {
58
- var builder = new xml2js.Builder();
59
- return builder.buildObject(obj);
60
- };
61
- return XmlConvert;
62
- }());
63
- exports.XmlConvert = XmlConvert;
64
- //# sourceMappingURL=XmlConvert.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"XmlConvert.js","sourceRoot":"","sources":["../../src/utils/XmlConvert.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAAiC;AAEjC;IAAA;IAiBA,CAAC;IAhBqB,qBAAU,GAA9B,UAA+B,GAAW;uCAAG,OAAO;;gBAClD,WAAO,IAAI,OAAO,CAAM,UAAC,OAAO,EAAE,MAAM;wBACtC,MAAM,CAAC,WAAW,CAAC,GAAG,EAAE,UAAC,GAAG,EAAE,MAAM;4BAClC,IAAI,GAAG,EAAE;gCACP,MAAM,CAAC,GAAG,CAAC,CAAC;gCACZ,OAAO;6BACR;4BACD,OAAO,CAAC,MAAM,CAAC,CAAC;wBAClB,CAAC,CAAC,CAAC;oBACL,CAAC,CAAC,EAAC;;;KACJ;IAEa,oBAAS,GAAvB,UAAwB,GAAQ;QAC9B,IAAM,OAAO,GAAG,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACrC,OAAO,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAClC,CAAC;IACH,iBAAC;AAAD,CAAC,AAjBD,IAiBC;AAjBY,gCAAU"}
package/src/ExcelCell.ts DELETED
@@ -1,163 +0,0 @@
1
- import {ExcelWorksheet} from "./ExcelWorksheet";
2
- import {ExcelUtils} from "./utils/ExcelUtils";
3
- import {ExcelCellStyle} from "./ExcelCellStyle";
4
- import {DateOnly, DateTime, optional} from "@simplysm/common";
5
-
6
- export class ExcelCell {
7
- public cellData: any;
8
-
9
- public get style(): ExcelCellStyle {
10
- return new ExcelCellStyle(this);
11
- }
12
-
13
- public set value(value: any) {
14
- if (value === undefined) {
15
- delete this.cellData.$.t;
16
- delete this.cellData.v;
17
- }
18
- else if (typeof value === "string") {
19
- this.cellData.$.t = "str";
20
- this.cellData.v = this.cellData.v || {};
21
- this.cellData.v._ = value;
22
- }
23
- else if (typeof value === "boolean") {
24
- this.cellData.$.t = "b";
25
- this.cellData.v = this.cellData.v || {};
26
- this.cellData.v._ = value === true ? "1" : value === false ? "0" : undefined;
27
- }
28
- else if (typeof value === "number") {
29
- delete this.cellData.$.t;
30
- this.style.numberFormat = "number";
31
- this.cellData.v = this.cellData.v || {};
32
- this.cellData.v._ = value;
33
- }
34
- else if (value instanceof DateOnly) {
35
- delete this.cellData.$.t;
36
- this.style.numberFormat = "DateOnly";
37
- this.cellData.v = this.cellData.v || {};
38
- this.cellData.v._ = ExcelUtils.getTimeNumber(value);
39
- }
40
- else if (value instanceof DateTime) {
41
- delete this.cellData.$.t;
42
- this.style.numberFormat = "DateTime";
43
- this.cellData.v = this.cellData.v || {};
44
- this.cellData.v._ = ExcelUtils.getTimeNumber(value);
45
- }
46
- else {
47
- throw new Error("지원되지 않는 타입입니다: " + value);
48
- }
49
- }
50
-
51
- public get value(): any {
52
- if (!this.cellData.v) {
53
- return undefined;
54
- }
55
-
56
- const value = this.cellData.v[0]._ || this.cellData.v[0];
57
-
58
- if (!value) {
59
- return undefined;
60
- }
61
- else if (this.cellData.$.t === "str") {
62
- return value;
63
- }
64
- else if (this.cellData.$.t === "b") {
65
- return Number(value) === 1;
66
- }
67
- else if (this.cellData.$.t === undefined && this.style.numberFormat === "number") {
68
- return Number(value);
69
- }
70
- else if (this.cellData.$.t === undefined && this.style.numberFormat === "Currency") {
71
- return Number(value);
72
- }
73
- else if (this.cellData.$.t === undefined && this.style.numberFormat === "DateOnly") {
74
- return ExcelUtils.getDateOnly(Number(value));
75
- }
76
- else if (this.cellData.$.t === undefined && this.style.numberFormat === "DateTime") {
77
- return ExcelUtils.getDateTime(Number(value));
78
- }
79
- else if (this.cellData.$.t === "s") {
80
- const sstIndex = Number(value);
81
-
82
- if (this.excelWorkSheet.workbook.sstData.sst.si[sstIndex].t) {
83
- return this.excelWorkSheet.workbook.sstData.sst.si[sstIndex].t[0]._ || this.excelWorkSheet.workbook.sstData.sst.si[sstIndex].t[0];
84
- }
85
- else {
86
- return this.excelWorkSheet.workbook.sstData.sst.si[sstIndex].r.map((item: any) => item.t[0]).join("");
87
- }
88
- }
89
- else {
90
- throw new Error("지원되지 않는 타입입니다: " + this.cellData.$.t + ", " + this.style.numberFormat);
91
- }
92
- }
93
-
94
- public set formula(value: string | undefined) {
95
- if (this.cellData.v && ((this.cellData.v[0] && this.cellData.v[0]._) || this.cellData.v._)) {
96
- throw new Error("하나의 셀에 'value'가 지정된 상태로, 'Formula'를 지정할 수 없습니다. ('formula'를 먼저 지정하고 'value'값을 넣으세요.)");
97
- }
98
-
99
- if (value === undefined) {
100
- delete this.cellData.$.t;
101
- delete this.cellData.f;
102
- }
103
- else {
104
- this.cellData.$.t = "str";
105
- this.cellData.f = this.cellData.f || {};
106
- this.cellData.f._ = value;
107
- }
108
- }
109
-
110
- public get formula(): string | undefined {
111
- if (!this.cellData.f) {
112
- return undefined;
113
- }
114
- else {
115
- return this.cellData.f[0]._ || this.cellData.f[0];
116
- }
117
- }
118
-
119
- public constructor(public readonly excelWorkSheet: ExcelWorksheet,
120
- public readonly row: number,
121
- public readonly col: number) {
122
- this.excelWorkSheet.sheetData.worksheet.sheetData[0].row = this.excelWorkSheet.sheetData.worksheet.sheetData[0].row || [];
123
- const rowNodes = this.excelWorkSheet.sheetData.worksheet.sheetData[0].row as any[];
124
- let currRow = rowNodes.single((item: any) => Number(item.$.r) === row + 1);
125
- if (!currRow) {
126
- currRow = {$: {r: row + 1}};
127
-
128
- const beforeRow = rowNodes.orderBy(item => item.$.r).last(item => item.$.r < currRow.$.r);
129
- const beforeRowIndex = beforeRow ? rowNodes.indexOf(beforeRow) : -1;
130
-
131
- rowNodes.insert(beforeRowIndex + 1, currRow);
132
- }
133
-
134
- currRow.c = currRow.c || [];
135
- const cellNodes = currRow.c as any[];
136
- let currCell = cellNodes.single((item: any) => item.$.r === ExcelUtils.getAddress(this.row, this.col));
137
- if (!currCell) {
138
- currCell = {$: {r: ExcelUtils.getAddress(this.row, this.col)}};
139
-
140
- const colStyle = optional(() => this.excelWorkSheet.column(col).colData.$.style);
141
- if (colStyle) {
142
- currCell.$.s = colStyle;
143
- }
144
-
145
- const beforeCell = cellNodes.orderBy(item => item.$.r).last(item => item.$.r < currCell.$.r);
146
- const beforeCellIndex = beforeCell ? cellNodes.indexOf(beforeCell) : -1;
147
-
148
- cellNodes.insert(beforeCellIndex + 1, currCell);
149
- }
150
-
151
- this.cellData = currCell;
152
- }
153
-
154
- public merge(row: number, col: number): void {
155
- this.excelWorkSheet.sheetData.worksheet.mergeCells = this.excelWorkSheet.sheetData.worksheet.mergeCells || [{}];
156
- this.excelWorkSheet.sheetData.worksheet.mergeCells[0].mergeCell = this.excelWorkSheet.sheetData.worksheet.mergeCells[0].mergeCell || [];
157
- this.excelWorkSheet.sheetData.worksheet.mergeCells[0].mergeCell.push({
158
- $: {
159
- ref: ExcelUtils.getRangeAddress(this.row, this.col, row, col)
160
- }
161
- });
162
- }
163
- }
@@ -1,297 +0,0 @@
1
- import {ExcelCell} from "./ExcelCell";
2
-
3
- export class ExcelCellStyle {
4
- public set alignH(value: "center" | "left" | "right") {
5
- const newStyle = this._createNewStyle();
6
- newStyle.$ = newStyle.$ || {};
7
- newStyle.$.applyAlignment = 1;
8
- newStyle.alignment = newStyle.alignment || [{}];
9
- newStyle.alignment[0].$ = newStyle.alignment[0].$ || {};
10
- newStyle.alignment[0].$.horizontal = "center";
11
- const newIndex = this._setStyleData(newStyle);
12
-
13
- this._excelCell.cellData.$ = this._excelCell.cellData.$ || {};
14
- this._excelCell.cellData.$.s = newIndex;
15
- }
16
-
17
- public set background(value: string) {
18
- if (!/^[0-9A-F]{8}/.test(value.toUpperCase())) {
19
- throw new Error("색상 형식이 잘못되었습니다. (형식: FFFFFFFF: alpha+rgb)");
20
- }
21
-
22
- const newFill = this._createNewFill();
23
- newFill.patternFill = newFill.patternFill || [{}];
24
- newFill.patternFill[0].$ = newFill.patternFill[0].$ || {};
25
- newFill.patternFill[0].$.patternType = "solid";
26
- newFill.patternFill[0].fgColor = newFill.patternFill[0].fgColor || [{}];
27
- newFill.patternFill[0].fgColor[0].$ = newFill.patternFill[0].fgColor[0].$ || {};
28
- newFill.patternFill[0].fgColor[0].$.rgb = value.toUpperCase();
29
- const newFillIndex = this._setFillData(newFill);
30
-
31
- const newStyle = this._createNewStyle();
32
- newStyle.$ = newStyle.$ || {};
33
- newStyle.$.applyFill = 1;
34
- newStyle.$.fillId = newFillIndex;
35
- const newIndex = this._setStyleData(newStyle);
36
-
37
- this._excelCell.cellData.$ = this._excelCell.cellData.$ || {};
38
- this._excelCell.cellData.$.s = newIndex;
39
- }
40
-
41
- public set foreground(value: string) {
42
- if (!/^[0-9A-F]{8}/.test(value.toUpperCase())) {
43
- throw new Error("색상 형식이 잘못되었습니다. (형식: FFFFFFFF: alpha+rgb)");
44
- }
45
-
46
- const newFont = this._createNewFont();
47
- newFont.color = newFont.color || [{}];
48
- newFont.color[0].$ = newFont.color[0].$ || {};
49
- newFont.color[0].$.rgb = value;
50
- const newFontIndex = this._setFontData(newFont);
51
-
52
- const newStyle = this._createNewStyle();
53
- newStyle.$ = newStyle.$ || {};
54
- newStyle.$.applyFont = 1;
55
- newStyle.$.fontId = newFontIndex;
56
- const newIndex = this._setStyleData(newStyle);
57
-
58
- this._excelCell.cellData.$ = this._excelCell.cellData.$ || {};
59
- this._excelCell.cellData.$.s = newIndex;
60
- }
61
-
62
- public set bold(value: boolean) {
63
- const newFont = this._createNewFont();
64
- if (value) {
65
- newFont.b = newFont.b || [{}];
66
- }
67
- else {
68
- delete newFont.b;
69
- }
70
- const newFontIndex = this._setFontData(newFont);
71
-
72
- const newStyle = this._createNewStyle();
73
- newStyle.$ = newStyle.$ || {};
74
- newStyle.$.applyFont = 1;
75
- newStyle.$.fontId = newFontIndex;
76
- const newIndex = this._setStyleData(newStyle);
77
-
78
- this._excelCell.cellData.$ = this._excelCell.cellData.$ || {};
79
- this._excelCell.cellData.$.s = newIndex;
80
- }
81
-
82
- public get numberFormat(): "DateTime" | "DateOnly" | "number" | "Currency" {
83
- const styleData = this._getStyleData();
84
- if (!styleData || !styleData.$ || !styleData.$.numFmtId) {
85
- return "number";
86
- }
87
- /*else if (styleData.$.numFmtId === "176" || styleData.$.numFmtId === "3") {
88
- return "number";
89
- }*/
90
- else if (styleData.$.numFmtId === "14") {
91
- return "DateOnly";
92
- }
93
- else if (styleData.$.numFmtId === "22") {
94
- return "DateTime";
95
- }
96
- else if (styleData.$.numFmtId === "42") {
97
- return "Currency";
98
- }
99
- else {
100
- return "number";
101
- }
102
- /*else {
103
- throw new Error("지원되지 않는 숫자포맷 입니다.");
104
- }*/
105
- }
106
-
107
- public set numberFormat(value: "DateTime" | "DateOnly" | "number" | "Currency") {
108
- const newStyle = this._createNewStyle();
109
- newStyle.$ = newStyle.$ || {};
110
- newStyle.$.applyFont = 1;
111
- if (value === "number") {
112
- delete newStyle.$.numFmtId;
113
- }
114
- else if (value === "DateOnly") {
115
- newStyle.$.numFmtId = 14;
116
- }
117
- else if (value === "DateTime") {
118
- newStyle.$.numFmtId = 22;
119
- }
120
- else if (value === "Currency") {
121
- newStyle.$.numFmtId = 42;
122
- }
123
- else {
124
- throw new Error("지원되지 않는 숫자포맷 입니다.");
125
- }
126
-
127
- const newIndex = this._setStyleData(newStyle);
128
-
129
- this._excelCell.cellData.$ = this._excelCell.cellData.$ || {};
130
- this._excelCell.cellData.$.s = newIndex;
131
- }
132
-
133
- public set borderLeftWidth(value: "thin" | "medium") {
134
- this._setBorderWidth("left", value);
135
- }
136
-
137
- public set borderLeftColor(value: string) {
138
- this._setBorderColor("left", value);
139
- }
140
-
141
- public set borderRightWidth(value: "thin" | "medium") {
142
- this._setBorderWidth("right", value);
143
- }
144
-
145
- public set borderRightColor(value: string) {
146
- this._setBorderColor("right", value);
147
- }
148
-
149
- public set borderTopWidth(value: "thin" | "medium") {
150
- this._setBorderWidth("top", value);
151
- }
152
-
153
- public set borderTopColor(value: string) {
154
- this._setBorderColor("top", value);
155
- }
156
-
157
- public set borderBottomWidth(value: "thin" | "medium") {
158
- this._setBorderWidth("bottom", value);
159
- }
160
-
161
- public set borderBottomColor(value: string) {
162
- this._setBorderColor("bottom", value);
163
- }
164
-
165
- public set borderWidth(value: "thin" | "medium") {
166
- this.borderLeftWidth = value;
167
- this.borderRightWidth = value;
168
- this.borderTopWidth = value;
169
- this.borderBottomWidth = value;
170
- }
171
-
172
- public set borderColor(value: string) {
173
- this.borderLeftColor = value;
174
- this.borderRightColor = value;
175
- this.borderTopColor = value;
176
- this.borderBottomColor = value;
177
- }
178
-
179
- private _createNewFill(): any {
180
- const styleData = this._getStyleData();
181
- const fillId = (styleData && styleData.$) ? Number(styleData.$.fillId) : undefined;
182
- if (fillId) {
183
- return Object.clone(this._excelCell.excelWorkSheet.workbook.stylesData.styleSheet.fills[0].fill[fillId]);
184
- }
185
- else {
186
- return {};
187
- }
188
- }
189
-
190
- private _createNewStyle(): any {
191
- const styleData = this._getStyleData();
192
- return (styleData && styleData.$) ? Object.clone(styleData) : {};
193
- }
194
-
195
- private _createNewFont(): any {
196
- const styleData = this._getStyleData();
197
- const fontId = (styleData && styleData.$) ? Number(styleData.$.fontId) : undefined;
198
-
199
- if (fontId) {
200
- return Object.clone(this._excelCell.excelWorkSheet.workbook.stylesData.styleSheet.fonts[0].font[fontId]);
201
- }
202
- else {
203
- return {};
204
- }
205
- }
206
-
207
- private _createNewBorder(): any {
208
- const styleData = this._getStyleData();
209
- const borderId = (styleData && styleData.$) ? Number(styleData.$.borderId) : undefined;
210
-
211
- if (borderId) {
212
- return Object.clone(this._excelCell.excelWorkSheet.workbook.stylesData.styleSheet.borders[0].border[borderId]);
213
- }
214
- else {
215
- return {};
216
- }
217
- }
218
-
219
- private _setBorderWidth(direction: "left" | "right" | "bottom" | "top", width: "thin" | "medium"): void {
220
- const newBorder = this._createNewBorder();
221
- newBorder[direction] = newBorder[direction] || [{}];
222
- newBorder[direction][0].$ = newBorder[direction][0].$ || {};
223
- newBorder[direction][0].$.style = width;
224
- const newBorderIndex = this._setBorderData(newBorder);
225
-
226
- const newStyle = this._createNewStyle();
227
- newStyle.$ = newStyle.$ || {};
228
- newStyle.$.applyBorder = 1;
229
- newStyle.$.borderId = newBorderIndex;
230
- const newIndex = this._setStyleData(newStyle);
231
-
232
- this._excelCell.cellData.$ = this._excelCell.cellData.$ || {};
233
- this._excelCell.cellData.$.s = newIndex;
234
- }
235
-
236
- private _setBorderColor(direction: "left" | "right" | "bottom" | "top", color: string): void {
237
- if (!/^[0-9A-F]{8}/.test(color.toUpperCase())) {
238
- throw new Error("색상 형식이 잘못되었습니다. (형식: FFFFFFFF: alpha+rgb)");
239
- }
240
-
241
- const newBorder = this._createNewBorder();
242
- newBorder[direction] = newBorder[direction] || [{}];
243
- newBorder[direction][0].color = newBorder[direction][0].color || [{}];
244
- newBorder[direction][0].color[0].$ = newBorder[direction][0].color[0].$ || {};
245
- newBorder[direction][0].color[0].$.rgb = color;
246
- const newBorderIndex = this._setBorderData(newBorder);
247
-
248
- const newStyle = this._createNewStyle();
249
- newStyle.$ = newStyle.$ || {};
250
- newStyle.$.applyBorder = 1;
251
- newStyle.$.borderId = newBorderIndex;
252
- const newIndex = this._setStyleData(newStyle);
253
-
254
- this._excelCell.cellData.$ = this._excelCell.cellData.$ || {};
255
- this._excelCell.cellData.$.s = newIndex;
256
- }
257
-
258
- private _setFillData(data: any): number {
259
- const index = this._excelCell.excelWorkSheet.workbook.stylesData.styleSheet.fills[0].fill.findIndex((item: any) => Object.equal(item, data));
260
- if (index >= 0) return index;
261
- return this._excelCell.excelWorkSheet.workbook.stylesData.styleSheet.fills[0].fill.push(data) - 1;
262
- }
263
-
264
- private _setFontData(data: any): number {
265
- const index = this._excelCell.excelWorkSheet.workbook.stylesData.styleSheet.fonts[0].font.findIndex((item: any) => Object.equal(item, data));
266
- if (index >= 0) return index;
267
- return this._excelCell.excelWorkSheet.workbook.stylesData.styleSheet.fonts[0].font.push(data) - 1;
268
- }
269
-
270
- private _setStyleData(data: any): number {
271
- const index = this._excelCell.excelWorkSheet.workbook.stylesData.styleSheet.cellXfs[0].xf.findIndex((item: any) => Object.equal(item, data));
272
- if (index >= 0) return index;
273
- return this._excelCell.excelWorkSheet.workbook.stylesData.styleSheet.cellXfs[0].xf.push(data) - 1;
274
- }
275
-
276
- private _getStyleData(): any {
277
- if (this._excelCell.cellData.$ && this._excelCell.cellData.$.s) {
278
- return this._excelCell.excelWorkSheet.workbook.stylesData.styleSheet.cellXfs[0].xf[Number(this._excelCell.cellData.$.s)];
279
- }
280
-
281
- const colData = this._excelCell.excelWorkSheet.column(this._excelCell.col).colData;
282
- if (colData.$ && colData.$.style) {
283
- return this._excelCell.excelWorkSheet.workbook.stylesData.styleSheet.cellXfs[0].xf[Number(colData.$.style)];
284
- }
285
-
286
- return undefined;
287
- }
288
-
289
- private _setBorderData(data: any): number {
290
- const index = this._excelCell.excelWorkSheet.workbook.stylesData.styleSheet.borders[0].border.findIndex((item: any) => Object.equal(item, data));
291
- if (index >= 0) return index;
292
- return this._excelCell.excelWorkSheet.workbook.stylesData.styleSheet.borders[0].border.push(data) - 1;
293
- }
294
-
295
- public constructor(private readonly _excelCell: ExcelCell) {
296
- }
297
- }
@@ -1,46 +0,0 @@
1
- import {ExcelWorksheet} from "./ExcelWorksheet";
2
-
3
- export class ExcelColumn {
4
- public colData: any;
5
-
6
- public constructor(private readonly _ews: ExcelWorksheet,
7
- private readonly _col: number) {
8
- this._ews.sheetData.worksheet.cols[0] = this._ews.sheetData.worksheet.cols[0] || {};
9
- this._ews.sheetData.worksheet.cols[0].col = this._ews.sheetData.worksheet.cols[0].col || [];
10
- const colDataList = this._ews.sheetData.worksheet.cols[0].col as any[];
11
-
12
- for (const colData of colDataList) {
13
- const min = Number(colData.$.min);
14
- const max = Number(colData.$.max);
15
- if (min !== max) {
16
- colDataList.remove(colData);
17
-
18
- for (let i = min; i <= max; i++) {
19
- const newColData = Object.clone(colData);
20
- newColData.$.min = i;
21
- newColData.$.max = i;
22
- colDataList.push(newColData);
23
- }
24
- }
25
- }
26
-
27
- this.colData = colDataList.single(item => Number(item.$.min) === _col + 1);
28
- if (!this.colData) {
29
- this.colData = {
30
- $: {
31
- min: (_col + 1).toString(),
32
- max: (_col + 1).toString(),
33
- bestFit: "1",
34
- customWidth: "1",
35
- width: "9.5"
36
- }
37
- };
38
- colDataList.push(this.colData);
39
- }
40
- }
41
-
42
- public set width(value: number) {
43
- this.colData.$ = this.colData.$ || {min: this._col + 1, max: this._col + 1};
44
- this.colData.$.width = value;
45
- }
46
- }
package/src/ExcelRow.ts DELETED
@@ -1,17 +0,0 @@
1
- import {ExcelWorksheet} from "./ExcelWorksheet";
2
- import {ExcelUtils} from "./utils/ExcelUtils";
3
-
4
- export class ExcelRow {
5
- public rowData: any;
6
-
7
- public constructor(private readonly _ews: ExcelWorksheet,
8
- row: number) {
9
- this.rowData = this._ews.sheetData.worksheet.sheetData[0].row.single((item: any) => Number(item.$.r) === row);
10
- }
11
-
12
- public get columnLength(): number {
13
- const lastAddr = this.rowData.c.last().$.r;
14
- const rowCol = ExcelUtils.getAddressRowCol(lastAddr);
15
- return rowCol.col + 1;
16
- }
17
- }