From 6ac789f1bff2b4fe029eb67d014228b93f68fd4f Mon Sep 17 00:00:00 2001 From: yatessss <897969073@qq.com> Date: Tue, 15 Aug 2023 19:29:01 +0800 Subject: [PATCH 01/10] =?UTF-8?q?fix:=20=E9=BB=98=E8=AE=A4=E6=94=B9?= =?UTF-8?q?=E4=B8=BAn=20=20d=E4=B8=BA=E6=97=A5=E6=9C=9F=20n=E4=B8=BA?= =?UTF-8?q?=E6=95=B0=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ToLuckySheet/LuckyCell.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ToLuckySheet/LuckyCell.ts b/src/ToLuckySheet/LuckyCell.ts index 786b5c1..8cb0dbd 100644 --- a/src/ToLuckySheet/LuckyCell.ts +++ b/src/ToLuckySheet/LuckyCell.ts @@ -201,7 +201,7 @@ export class LuckySheetCelldata extends LuckySheetCelldataBase{ let cellFormat = new LuckySheetCellFormat(); cellFormat.fa = escapeCharacter(numf); // console.log(numf, numFmtId, this.v); - cellFormat.t = t || 'd'; + cellFormat.t = t || 'n'; cellValue.ct = cellFormat; } From b4ddd44ddc9d4431f63a253f062730653d86a35c Mon Sep 17 00:00:00 2001 From: yatessss <897969073@qq.com> Date: Tue, 15 Aug 2023 19:50:45 +0800 Subject: [PATCH 02/10] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0luckysheet?= =?UTF-8?q?=E5=AF=BC=E5=87=BA=E4=B8=BAexcel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 264 +++++++++++++++++++++++++++++++++++- package.json | 3 +- src/ICommon.ts | 3 + src/common/constant.ts | 52 +++++++- src/common/method.ts | 25 +++- src/index.html | 274 +++++++++++++++++++++++--------------- src/main.ts | 79 ++++++----- src/toExcel/BorderInfo.ts | 132 ++++++++++++++++++ src/toExcel/ExcelFile.ts | 27 ++++ src/toExcel/Workcell.ts | 83 ++++++++++++ src/toExcel/Worksheet.ts | 101 ++++++++++++++ 11 files changed, 902 insertions(+), 141 deletions(-) create mode 100644 src/toExcel/BorderInfo.ts create mode 100644 src/toExcel/Workcell.ts diff --git a/package-lock.json b/package-lock.json index 20164eb..d3cbb11 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,8 @@ "license": "MIT", "dependencies": { "dayjs": "^1.10.6", - "jszip": "^3.5.0" + "jszip": "^3.5.0", + "xlsx-js-style": "^1.2.0" }, "devDependencies": { "@babel/core": "^7.10.5", @@ -1443,6 +1444,21 @@ "node": ">=0.4.0" } }, + "node_modules/adler-32": { + "version": "1.2.0", + "resolved": "https://mirrors.tencent.com/npm/adler-32/-/adler-32-1.2.0.tgz", + "integrity": "sha1-aj5r8KY5ALoVZSgIyxXGgT0aXyU=", + "dependencies": { + "exit-on-epipe": "~1.0.1", + "printj": "~1.1.0" + }, + "bin": { + "adler32": "bin/adler32.njs" + }, + "engines": { + "node": ">=0.8" + } + }, "node_modules/after": { "version": "0.8.2", "resolved": "https://registry.npmjs.org/after/-/after-0.8.2.tgz", @@ -2985,6 +3001,26 @@ "integrity": "sha512-pkpCg7dmI/a7WcqM2yfdOiT4Xx5tzyoHAXWsX5/HxZ3TemwDZs0QXdqbE0UPLPVy/7BeK7693YfzfRYfu1YVpg==", "dev": true }, + "node_modules/cfb": { + "version": "1.2.2", + "resolved": "https://mirrors.tencent.com/npm/cfb/-/cfb-1.2.2.tgz", + "integrity": "sha512-KfdUZsSOw19/ObEWasvBP/Ac4reZvAGauZhs6S/gqNhXhI7cKwvlH7ulj+dOEYnca4bm4SGo8C1bTAQvnTjgQA==", + "dependencies": { + "adler-32": "~1.3.0", + "crc-32": "~1.2.0" + }, + "engines": { + "node": ">=0.8" + } + }, + "node_modules/cfb/node_modules/adler-32": { + "version": "1.3.1", + "resolved": "https://mirrors.tencent.com/npm/adler-32/-/adler-32-1.3.1.tgz", + "integrity": "sha512-ynZ4w/nUUv5rrsR8UUGoe1VC9hZj6V5hU9Qw1HlMDJGEJw5S7TfTErWTjMys6M7vr0YWcPqs3qAr4ss0nDfP+A==", + "engines": { + "node": ">=0.8" + } + }, "node_modules/chalk": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", @@ -3125,6 +3161,26 @@ "node": ">=0.10.0" } }, + "node_modules/codepage": { + "version": "1.14.0", + "resolved": "https://mirrors.tencent.com/npm/codepage/-/codepage-1.14.0.tgz", + "integrity": "sha1-jL4lSBMjVZ19MHVxsP/5HnodL5k=", + "dependencies": { + "commander": "~2.14.1", + "exit-on-epipe": "~1.0.1" + }, + "bin": { + "codepage": "bin/codepage.njs" + }, + "engines": { + "node": ">=0.8" + } + }, + "node_modules/codepage/node_modules/commander": { + "version": "2.14.1", + "resolved": "https://mirrors.tencent.com/npm/commander/-/commander-2.14.1.tgz", + "integrity": "sha512-+YR16o3rK53SmWHU3rEM3tPAh2rwb1yPcQX5irVn7mb0gXbwuCCrnkbV5+PBfETdfg1vui07nM6PCG1zndcjQw==" + }, "node_modules/collection-map": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/collection-map/-/collection-map-1.0.0.tgz", @@ -3346,6 +3402,17 @@ "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" }, + "node_modules/crc-32": { + "version": "1.2.2", + "resolved": "https://mirrors.tencent.com/npm/crc-32/-/crc-32-1.2.2.tgz", + "integrity": "sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==", + "bin": { + "crc32": "bin/crc32.njs" + }, + "engines": { + "node": ">=0.8" + } + }, "node_modules/create-ecdh": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.3.tgz", @@ -4104,6 +4171,14 @@ "safe-buffer": "^5.1.1" } }, + "node_modules/exit-on-epipe": { + "version": "1.0.1", + "resolved": "https://mirrors.tencent.com/npm/exit-on-epipe/-/exit-on-epipe-1.0.1.tgz", + "integrity": "sha512-h2z5mrROTxce56S+pnvAV890uu7ls7f1kEvVGJbw1OlFH3/mlJ5bkXu0KRyW94v37zzHPiUd55iLn3DA7TjWpw==", + "engines": { + "node": ">=0.8" + } + }, "node_modules/expand-brackets": { "version": "2.1.4", "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", @@ -4306,6 +4381,11 @@ "integrity": "sha512-Utm6CdzT+6xsDk2m8S6uL8VHxNwI6Jub+e9NYTcAms28T84pTa25GJQV9j0CY0N1rM8hK4x6grpF2BQf+2qwVA==", "dev": true }, + "node_modules/fflate": { + "version": "0.3.11", + "resolved": "https://mirrors.tencent.com/npm/fflate/-/fflate-0.3.11.tgz", + "integrity": "sha512-Rr5QlUeGN1mbOHlaqcSYMKVpPbgLy0AWT/W0EHxA6NGI12yO1jpoui2zBBvU2G824ltM6Ut8BFgfHSBGfkmS0A==" + }, "node_modules/file-uri-to-path": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", @@ -4474,6 +4554,14 @@ "node": ">=0.10.0" } }, + "node_modules/frac": { + "version": "1.1.2", + "resolved": "https://mirrors.tencent.com/npm/frac/-/frac-1.1.2.tgz", + "integrity": "sha512-w/XBfkibaTl3YDqASwfDUqkna4Z2p9cFSr1aHDt0WoMTECnRfBOv2WArlZILlqgWlmdIlALXGpM2AOhEk5W3IA==", + "engines": { + "node": ">=0.8" + } + }, "node_modules/fragment-cache": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", @@ -7450,6 +7538,17 @@ "node": ">= 0.8" } }, + "node_modules/printj": { + "version": "1.1.2", + "resolved": "https://mirrors.tencent.com/npm/printj/-/printj-1.1.2.tgz", + "integrity": "sha512-zA2SmoLaxZyArQTOPj5LXecR+RagfPSU5Kw1qP+jkWeNlrq+eJZyY2oS68SU1Z/7/myXM4lo9716laOFAVStCQ==", + "bin": { + "printj": "bin/printj.njs" + }, + "engines": { + "node": ">=0.8" + } + }, "node_modules/process": { "version": "0.11.10", "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", @@ -8719,6 +8818,17 @@ "node": ">=0.10.0" } }, + "node_modules/ssf": { + "version": "0.11.2", + "resolved": "https://mirrors.tencent.com/npm/ssf/-/ssf-0.11.2.tgz", + "integrity": "sha512-+idbmIXoYET47hH+d7dfm2epdOMUDjqcB4648sTZ+t2JwoyBFL/insLfB/racrDmsKB3diwsDA696pZMieAC5g==", + "dependencies": { + "frac": "~1.1.2" + }, + "engines": { + "node": ">=0.8" + } + }, "node_modules/stack-trace": { "version": "0.0.10", "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz", @@ -9867,6 +9977,22 @@ "integrity": "sha1-u6Y8qGGUiZT/MHc2CJ47lgJsKk8=", "dev": true }, + "node_modules/wmf": { + "version": "1.0.2", + "resolved": "https://mirrors.tencent.com/npm/wmf/-/wmf-1.0.2.tgz", + "integrity": "sha512-/p9K7bEh0Dj6WbXg4JG0xvLQmIadrner1bi45VMJTfnbVHsc7yIajZyoSoK60/dtVBs12Fm6WkUI5/3WAVsNMw==", + "engines": { + "node": ">=0.8" + } + }, + "node_modules/word": { + "version": "0.3.0", + "resolved": "https://mirrors.tencent.com/npm/word/-/word-0.3.0.tgz", + "integrity": "sha512-OELeY0Q61OXpdUfTp+oweA/vtLVg5VDOXh+3he3PNzLGG/y0oylSOC1xRVj0+l4vQ3tj/bB1HVHv1ocXkQceFA==", + "engines": { + "node": ">=0.8" + } + }, "node_modules/wrap-ansi": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", @@ -9895,6 +10021,34 @@ "async-limiter": "~1.0.0" } }, + "node_modules/xlsx-js-style": { + "version": "1.2.0", + "resolved": "https://mirrors.tencent.com/npm/xlsx-js-style/-/xlsx-js-style-1.2.0.tgz", + "integrity": "sha512-DDT4FXFSWfT4DXMSok/m3TvmP1gvO3dn0Eu/c+eXHW5Kzmp7IczNkxg/iEPnImbG9X0Vb8QhROda5eatSR/97Q==", + "dependencies": { + "adler-32": "~1.2.0", + "cfb": "^1.1.4", + "codepage": "~1.14.0", + "commander": "~2.17.1", + "crc-32": "~1.2.0", + "exit-on-epipe": "~1.0.1", + "fflate": "^0.3.8", + "ssf": "~0.11.2", + "wmf": "~1.0.1", + "word": "~0.3.0" + }, + "bin": { + "xlsx": "bin/xlsx.njs" + }, + "engines": { + "node": ">=0.8" + } + }, + "node_modules/xlsx-js-style/node_modules/commander": { + "version": "2.17.1", + "resolved": "https://mirrors.tencent.com/npm/commander/-/commander-2.17.1.tgz", + "integrity": "sha512-wPMUt6FnH2yzG95SA6mzjQOEKUU3aLaDEmzs1ti+1E9h+CsrZghRlqEM/EJ4KscsQVG8uNN4uVreUeT8+drlgg==" + }, "node_modules/xmlhttprequest-ssl": { "version": "1.5.5", "resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.5.tgz", @@ -11120,6 +11274,15 @@ "integrity": "sha512-OPdCF6GsMIP+Az+aWfAAOEt2/+iVDKE7oy6lJ098aoe59oAmK76qV6Gw60SbZ8jHuG2wH058GF4pLFbYamYrVA==", "dev": true }, + "adler-32": { + "version": "1.2.0", + "resolved": "https://mirrors.tencent.com/npm/adler-32/-/adler-32-1.2.0.tgz", + "integrity": "sha1-aj5r8KY5ALoVZSgIyxXGgT0aXyU=", + "requires": { + "exit-on-epipe": "~1.0.1", + "printj": "~1.1.0" + } + }, "after": { "version": "0.8.2", "resolved": "https://registry.npmjs.org/after/-/after-0.8.2.tgz", @@ -12384,6 +12547,22 @@ "integrity": "sha512-pkpCg7dmI/a7WcqM2yfdOiT4Xx5tzyoHAXWsX5/HxZ3TemwDZs0QXdqbE0UPLPVy/7BeK7693YfzfRYfu1YVpg==", "dev": true }, + "cfb": { + "version": "1.2.2", + "resolved": "https://mirrors.tencent.com/npm/cfb/-/cfb-1.2.2.tgz", + "integrity": "sha512-KfdUZsSOw19/ObEWasvBP/Ac4reZvAGauZhs6S/gqNhXhI7cKwvlH7ulj+dOEYnca4bm4SGo8C1bTAQvnTjgQA==", + "requires": { + "adler-32": "~1.3.0", + "crc-32": "~1.2.0" + }, + "dependencies": { + "adler-32": { + "version": "1.3.1", + "resolved": "https://mirrors.tencent.com/npm/adler-32/-/adler-32-1.3.1.tgz", + "integrity": "sha512-ynZ4w/nUUv5rrsR8UUGoe1VC9hZj6V5hU9Qw1HlMDJGEJw5S7TfTErWTjMys6M7vr0YWcPqs3qAr4ss0nDfP+A==" + } + } + }, "chalk": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", @@ -12504,6 +12683,22 @@ "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", "dev": true }, + "codepage": { + "version": "1.14.0", + "resolved": "https://mirrors.tencent.com/npm/codepage/-/codepage-1.14.0.tgz", + "integrity": "sha1-jL4lSBMjVZ19MHVxsP/5HnodL5k=", + "requires": { + "commander": "~2.14.1", + "exit-on-epipe": "~1.0.1" + }, + "dependencies": { + "commander": { + "version": "2.14.1", + "resolved": "https://mirrors.tencent.com/npm/commander/-/commander-2.14.1.tgz", + "integrity": "sha512-+YR16o3rK53SmWHU3rEM3tPAh2rwb1yPcQX5irVn7mb0gXbwuCCrnkbV5+PBfETdfg1vui07nM6PCG1zndcjQw==" + } + } + }, "collection-map": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/collection-map/-/collection-map-1.0.0.tgz", @@ -12698,6 +12893,11 @@ "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" }, + "crc-32": { + "version": "1.2.2", + "resolved": "https://mirrors.tencent.com/npm/crc-32/-/crc-32-1.2.2.tgz", + "integrity": "sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==" + }, "create-ecdh": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.3.tgz", @@ -13379,6 +13579,11 @@ "safe-buffer": "^5.1.1" } }, + "exit-on-epipe": { + "version": "1.0.1", + "resolved": "https://mirrors.tencent.com/npm/exit-on-epipe/-/exit-on-epipe-1.0.1.tgz", + "integrity": "sha512-h2z5mrROTxce56S+pnvAV890uu7ls7f1kEvVGJbw1OlFH3/mlJ5bkXu0KRyW94v37zzHPiUd55iLn3DA7TjWpw==" + }, "expand-brackets": { "version": "2.1.4", "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", @@ -13550,6 +13755,11 @@ "integrity": "sha512-Utm6CdzT+6xsDk2m8S6uL8VHxNwI6Jub+e9NYTcAms28T84pTa25GJQV9j0CY0N1rM8hK4x6grpF2BQf+2qwVA==", "dev": true }, + "fflate": { + "version": "0.3.11", + "resolved": "https://mirrors.tencent.com/npm/fflate/-/fflate-0.3.11.tgz", + "integrity": "sha512-Rr5QlUeGN1mbOHlaqcSYMKVpPbgLy0AWT/W0EHxA6NGI12yO1jpoui2zBBvU2G824ltM6Ut8BFgfHSBGfkmS0A==" + }, "file-uri-to-path": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", @@ -13678,6 +13888,11 @@ "for-in": "^1.0.1" } }, + "frac": { + "version": "1.1.2", + "resolved": "https://mirrors.tencent.com/npm/frac/-/frac-1.1.2.tgz", + "integrity": "sha512-w/XBfkibaTl3YDqASwfDUqkna4Z2p9cFSr1aHDt0WoMTECnRfBOv2WArlZILlqgWlmdIlALXGpM2AOhEk5W3IA==" + }, "fragment-cache": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", @@ -16126,6 +16341,11 @@ "integrity": "sha1-t+PqQkNaTJsnWdmeDyAesZWALuE=", "dev": true }, + "printj": { + "version": "1.1.2", + "resolved": "https://mirrors.tencent.com/npm/printj/-/printj-1.1.2.tgz", + "integrity": "sha512-zA2SmoLaxZyArQTOPj5LXecR+RagfPSU5Kw1qP+jkWeNlrq+eJZyY2oS68SU1Z/7/myXM4lo9716laOFAVStCQ==" + }, "process": { "version": "0.11.10", "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", @@ -17218,6 +17438,14 @@ "extend-shallow": "^3.0.0" } }, + "ssf": { + "version": "0.11.2", + "resolved": "https://mirrors.tencent.com/npm/ssf/-/ssf-0.11.2.tgz", + "integrity": "sha512-+idbmIXoYET47hH+d7dfm2epdOMUDjqcB4648sTZ+t2JwoyBFL/insLfB/racrDmsKB3diwsDA696pZMieAC5g==", + "requires": { + "frac": "~1.1.2" + } + }, "stack-trace": { "version": "0.0.10", "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz", @@ -18185,6 +18413,16 @@ "integrity": "sha1-u6Y8qGGUiZT/MHc2CJ47lgJsKk8=", "dev": true }, + "wmf": { + "version": "1.0.2", + "resolved": "https://mirrors.tencent.com/npm/wmf/-/wmf-1.0.2.tgz", + "integrity": "sha512-/p9K7bEh0Dj6WbXg4JG0xvLQmIadrner1bi45VMJTfnbVHsc7yIajZyoSoK60/dtVBs12Fm6WkUI5/3WAVsNMw==" + }, + "word": { + "version": "0.3.0", + "resolved": "https://mirrors.tencent.com/npm/word/-/word-0.3.0.tgz", + "integrity": "sha512-OELeY0Q61OXpdUfTp+oweA/vtLVg5VDOXh+3he3PNzLGG/y0oylSOC1xRVj0+l4vQ3tj/bB1HVHv1ocXkQceFA==" + }, "wrap-ansi": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", @@ -18210,6 +18448,30 @@ "async-limiter": "~1.0.0" } }, + "xlsx-js-style": { + "version": "1.2.0", + "resolved": "https://mirrors.tencent.com/npm/xlsx-js-style/-/xlsx-js-style-1.2.0.tgz", + "integrity": "sha512-DDT4FXFSWfT4DXMSok/m3TvmP1gvO3dn0Eu/c+eXHW5Kzmp7IczNkxg/iEPnImbG9X0Vb8QhROda5eatSR/97Q==", + "requires": { + "adler-32": "~1.2.0", + "cfb": "^1.1.4", + "codepage": "~1.14.0", + "commander": "~2.17.1", + "crc-32": "~1.2.0", + "exit-on-epipe": "~1.0.1", + "fflate": "^0.3.8", + "ssf": "~0.11.2", + "wmf": "~1.0.1", + "word": "~0.3.0" + }, + "dependencies": { + "commander": { + "version": "2.17.1", + "resolved": "https://mirrors.tencent.com/npm/commander/-/commander-2.17.1.tgz", + "integrity": "sha512-wPMUt6FnH2yzG95SA6mzjQOEKUU3aLaDEmzs1ti+1E9h+CsrZghRlqEM/EJ4KscsQVG8uNN4uVreUeT8+drlgg==" + } + } + }, "xmlhttprequest-ssl": { "version": "1.5.5", "resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.5.tgz", diff --git a/package.json b/package.json index 23f337b..62c3235 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,7 @@ }, "dependencies": { "dayjs": "^1.10.6", - "jszip": "^3.5.0" + "jszip": "^3.5.0", + "xlsx-js-style": "^1.2.0" } } diff --git a/src/ICommon.ts b/src/ICommon.ts index db2ff4b..4bd9073 100644 --- a/src/ICommon.ts +++ b/src/ICommon.ts @@ -8,6 +8,9 @@ export interface IuploadfileList { export interface stringToNum { [index:string] : number } +export interface stringToBoolean { + [index:string] : boolean +} export interface numTostring { [index:number] : string diff --git a/src/common/constant.ts b/src/common/constant.ts index 9687532..1071c43 100644 --- a/src/common/constant.ts +++ b/src/common/constant.ts @@ -1,4 +1,4 @@ -import {stringToNum, IattributeList, numTostring, IDataVerificationMap, IDataVerificationType2Map} from "../ICommon"; +import {stringToNum, IattributeList, numTostring, stringToBoolean, IDataVerificationMap, IDataVerificationType2Map} from "../ICommon"; export const columeHeader_word:string[] = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']; @@ -176,6 +176,56 @@ export const borderTypes:stringToNum = { "thick":13 } +// 对齐文档 BORDER_STYLE https://github.com/gitbrent/xlsx-js-style#border_style-string-properties +export const excelBorderStyles: IattributeList = { + '1': 'thin', + '2': 'hair', + '3': 'dotted', + '4': 'dashed', + '5': 'dashDot', + '6': 'dashDotDot', + '8': 'medium', + '9': 'mediumDashed', + '10': 'mediumDashDot', + '11': 'mediumDashDotDot', + '12': 'slantDashDot', + '13': 'thick', +} + +export const excelBorderPositions: IattributeList = { + t: "top", + b: "bottom", + l: "left", + r: "right", +} + +export const verticalMap: IattributeList = { + '0': 'center', + '1': 'top', + '2': 'bottom', +} + +export const horizontalMap: IattributeList = { + '0': 'center', + '1': 'left', + '2': 'right', +} + +export const wrapTextMap: stringToBoolean = { + '0': false, + '1': false, + '2': true, +} + +export const textRotationMap: stringToNum = { + '0': 0, + '1': 45, + '2': 135, + '3': 255, + '4': 90, + '5': 180, +} + export let numFmtDefaultMap: IattributeList = { "yyyy/m/d;@": "yyyy/MM/dd", diff --git a/src/common/method.ts b/src/common/method.ts index 79d6035..ad931f9 100644 --- a/src/common/method.ts +++ b/src/common/method.ts @@ -236,7 +236,7 @@ export function LightenDarkenColor(sixColor:string, tint:number){ } -function rgbToHex(rgb:string){ +export function rgbToHex(rgb:string){ //十六进制颜色值的正则表达式 var reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/; // 如果是rgb颜色表示 @@ -1163,4 +1163,27 @@ export function getMultiFormulaValue(value: string): string[] { retArr.push(escapeCharacter(_value.replace(/"|^\"|\"$/g, ""))); } return retArr; +} + +/** + * 检查某一单元格是否在指定区域内 + * @param {Number} r 单元格所在行 + * @param {Number} c 单元格所在列 + * @param {Array} specifiedRange 指定区域 + */ +export function checkCellWithinSpecifiedRange(r: number, c: number, specifiedRange: {row: number[], column: number[]}[]) { + let within = false + if (!specifiedRange || specifiedRange.length === 0) { + return false + } + for(let item of specifiedRange){ + let r1 = item.row[0], r2 = item.row[1]; + let c1 = item.column[0], c2 = item.column[1]; + + if(r>=r1 && r<=r2 && c>=c1 && c<=c2){ + within = true; + break; + } + } + return within } \ No newline at end of file diff --git a/src/index.html b/src/index.html index 1e8eae2..e62a7c2 100644 --- a/src/index.html +++ b/src/index.html @@ -1,31 +1,62 @@ -
- -Or Load remote xlsx file: Download source xlsx file
- - - - - + } + demoHandler(); + + +