style-xlsx-m 0.1.31 → 0.1.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE +18 -6
- package/README.md +24 -15
- package/package.json +116 -108
- package/types/index.d.ts +1 -0
- package/xlsx-js-style/dist/xlsx.bundle.js +1 -0
- package/xlsx-js-style/dist/xlsx.min.js +1 -0
- package/xlsx.js +9 -34
- package/bin/xlsx.njs +0 -310
- package/dist/cpexcel.full.mjs +0 -1502
- package/dist/shim.min.js +0 -2
- package/dist/xlsx.core.min.js +0 -27357
- package/dist/xlsx.core.min.map +0 -1
- package/dist/xlsx.extendscript.js +0 -24643
- package/dist/xlsx.full.min.map +0 -1
- package/dist/xlsx.mini.min.js +0 -13978
- package/dist/xlsx.mini.min.map +0 -1
- package/dist/xlsx.zahl.js +0 -4
- package/dist/xlsx.zahl.mjs +0 -2
- package/types/tsconfig.json +0 -15
- package/xlsx-js-style/bin/xlsx.njs +0 -284
- package/xlsx-js-style/dist/cpexcel.full.mjs +0 -1502
- package/xlsx-js-style/dist/shim.min.js +0 -229
- package/xlsx-js-style/dist/xlsx.bundle.js.map +0 -1
- package/xlsx-js-style/dist/xlsx.min.js.map +0 -1
- package/xlsx-js-style/node_modules/.bin/adler32 +0 -12
- package/xlsx-js-style/node_modules/.bin/adler32.cmd +0 -17
- package/xlsx-js-style/node_modules/.bin/adler32.ps1 +0 -28
- package/xlsx-js-style/node_modules/.bin/codepage +0 -12
- package/xlsx-js-style/node_modules/.bin/codepage.cmd +0 -17
- package/xlsx-js-style/node_modules/.bin/codepage.ps1 +0 -28
- package/xlsx-js-style/node_modules/adler-32/README.md +0 -139
- package/xlsx-js-style/node_modules/adler-32/adler32.js +0 -92
- package/xlsx-js-style/node_modules/adler-32/bin/adler32.njs +0 -87
- package/xlsx-js-style/node_modules/adler-32/package.json +0 -42
- package/xlsx-js-style/node_modules/adler-32/types/index.d.ts +0 -14
- package/xlsx-js-style/node_modules/adler-32/types/tsconfig.json +0 -14
- package/xlsx-js-style/node_modules/adler-32/types/tslint.json +0 -11
- package/xlsx-js-style/node_modules/codepage/README.md +0 -347
- package/xlsx-js-style/node_modules/codepage/bin/codepage.njs +0 -98
- package/xlsx-js-style/node_modules/codepage/bits/10000.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/10001.js +0 -115
- package/xlsx-js-style/node_modules/codepage/bits/10002.js +0 -253
- package/xlsx-js-style/node_modules/codepage/bits/10003.js +0 -183
- package/xlsx-js-style/node_modules/codepage/bits/10004.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/10005.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/10006.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/10007.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/10008.js +0 -167
- package/xlsx-js-style/node_modules/codepage/bits/10010.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/10017.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/10021.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/10029.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/10079.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/10081.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/10082.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/1010.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/1026.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/1047.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/1132.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/1140.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/1141.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/1142.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/1143.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/1144.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/1145.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/1146.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/1147.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/1148.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/1149.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/1250.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/1251.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/1252.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/1253.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/1254.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/1255.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/1256.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/1257.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/1258.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/1361.js +0 -231
- package/xlsx-js-style/node_modules/codepage/bits/20000.js +0 -193
- package/xlsx-js-style/node_modules/codepage/bits/20001.js +0 -217
- package/xlsx-js-style/node_modules/codepage/bits/20002.js +0 -167
- package/xlsx-js-style/node_modules/codepage/bits/20003.js +0 -213
- package/xlsx-js-style/node_modules/codepage/bits/20004.js +0 -193
- package/xlsx-js-style/node_modules/codepage/bits/20005.js +0 -223
- package/xlsx-js-style/node_modules/codepage/bits/20105.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/20106.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/20107.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/20108.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/20261.js +0 -31
- package/xlsx-js-style/node_modules/codepage/bits/20269.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/20273.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/20277.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/20278.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/20280.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/20284.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/20285.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/20290.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/20297.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/20420.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/20423.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/20424.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/20833.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/20838.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/20866.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/20871.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/20880.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/20905.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/20924.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/20932.js +0 -189
- package/xlsx-js-style/node_modules/codepage/bits/20936.js +0 -167
- package/xlsx-js-style/node_modules/codepage/bits/20949.js +0 -183
- package/xlsx-js-style/node_modules/codepage/bits/21025.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/21027.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/21866.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/28591.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/28592.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/28593.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/28594.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/28595.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/28596.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/28597.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/28598.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/28599.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/28600.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/28601.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/28603.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/28604.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/28605.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/28606.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/29001.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/37.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/38598.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/437.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/47451.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/500.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/50220.js +0 -395
- package/xlsx-js-style/node_modules/codepage/bits/50221.js +0 -395
- package/xlsx-js-style/node_modules/codepage/bits/50222.js +0 -395
- package/xlsx-js-style/node_modules/codepage/bits/50225.js +0 -259
- package/xlsx-js-style/node_modules/codepage/bits/50227.js +0 -257
- package/xlsx-js-style/node_modules/codepage/bits/51932.js +0 -171
- package/xlsx-js-style/node_modules/codepage/bits/51936.js +0 -257
- package/xlsx-js-style/node_modules/codepage/bits/51949.js +0 -183
- package/xlsx-js-style/node_modules/codepage/bits/52936.js +0 -7
- package/xlsx-js-style/node_modules/codepage/bits/54936.js +0 -257
- package/xlsx-js-style/node_modules/codepage/bits/57002.js +0 -39
- package/xlsx-js-style/node_modules/codepage/bits/57003.js +0 -23
- package/xlsx-js-style/node_modules/codepage/bits/57004.js +0 -7
- package/xlsx-js-style/node_modules/codepage/bits/57005.js +0 -15
- package/xlsx-js-style/node_modules/codepage/bits/57006.js +0 -23
- package/xlsx-js-style/node_modules/codepage/bits/57007.js +0 -21
- package/xlsx-js-style/node_modules/codepage/bits/57008.js +0 -17
- package/xlsx-js-style/node_modules/codepage/bits/57009.js +0 -13
- package/xlsx-js-style/node_modules/codepage/bits/57010.js +0 -15
- package/xlsx-js-style/node_modules/codepage/bits/57011.js +0 -17
- package/xlsx-js-style/node_modules/codepage/bits/620.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/708.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/720.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/737.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/775.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/808.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/850.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/852.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/855.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/857.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/858.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/860.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/861.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/862.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/863.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/864.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/865.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/866.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/869.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/870.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/872.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/874.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/875.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/895.js +0 -2
- package/xlsx-js-style/node_modules/codepage/bits/932.js +0 -95
- package/xlsx-js-style/node_modules/codepage/bits/936.js +0 -257
- package/xlsx-js-style/node_modules/codepage/bits/949.js +0 -253
- package/xlsx-js-style/node_modules/codepage/bits/950.js +0 -179
- package/xlsx-js-style/node_modules/codepage/cptable.js +0 -6347
- package/xlsx-js-style/node_modules/codepage/cputils.js +0 -528
- package/xlsx-js-style/node_modules/codepage/dist/LICENSE +0 -14
- package/xlsx-js-style/node_modules/codepage/dist/cpexcel.full.js +0 -1505
- package/xlsx-js-style/node_modules/codepage/dist/cputils.js +0 -528
- package/xlsx-js-style/node_modules/codepage/dist/sbcs.full.js +0 -639
- package/xlsx-js-style/node_modules/codepage/node_modules/commander/CHANGELOG.md +0 -350
- package/xlsx-js-style/node_modules/codepage/node_modules/commander/Readme.md +0 -408
- package/xlsx-js-style/node_modules/codepage/node_modules/commander/index.js +0 -1157
- package/xlsx-js-style/node_modules/codepage/node_modules/commander/package.json +0 -37
- package/xlsx-js-style/node_modules/codepage/node_modules/commander/typings/index.d.ts +0 -309
- package/xlsx-js-style/node_modules/codepage/package.json +0 -67
- package/xlsx-js-style/node_modules/codepage/types/index.d.ts +0 -39
- package/xlsx-js-style/node_modules/codepage/types/tsconfig.json +0 -14
- package/xlsx-js-style/node_modules/codepage/types/tslint.json +0 -11
- package/xlsx-js-style/types/index.d.ts +0 -1068
- package/xlsx-js-style/types/tsconfig.json +0 -15
- package/xlsx.mjs +0 -24600
- package/xlsxworker.js +0 -14
- /package/{xlsx-js-style/node_modules/adler-32/LICENSE → third-party-licenses/adler-32-LICENSE} +0 -0
- /package/{xlsx-js-style/node_modules/codepage/LICENSE → third-party-licenses/codepage-LICENSE} +0 -0
- /package/{xlsx-js-style/node_modules/codepage/node_modules/commander/LICENSE → third-party-licenses/commander-LICENSE} +0 -0
package/NOTICE
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
style-xlsx-m
|
|
2
|
-
Copyright 2022-present Shukurov
|
|
2
|
+
Copyright 2022-present Shahrom Shukurov
|
|
3
3
|
|
|
4
4
|
This product is a derivative work and includes software developed by others:
|
|
5
5
|
|
|
@@ -8,16 +8,16 @@ This product is a derivative work and includes software developed by others:
|
|
|
8
8
|
https://github.com/SheetJS/sheetjs
|
|
9
9
|
Licensed under the Apache License, Version 2.0.
|
|
10
10
|
|
|
11
|
-
2. xlsx-js-style
|
|
11
|
+
2. xlsx-js-style 1.2.0
|
|
12
12
|
https://github.com/gitbrent/xlsx-js-style
|
|
13
13
|
A fork of SheetJS Community Edition that adds cell styling on write.
|
|
14
14
|
Licensed under the Apache License, Version 2.0.
|
|
15
15
|
Its compiled output is bundled in ./xlsx-js-style/ and is used by this
|
|
16
16
|
package for XLSX.write / XLSX.writeFile.
|
|
17
17
|
|
|
18
|
-
Changes made in style-xlsx-m (by Shukurov
|
|
19
|
-
- XLSX.read / XLSX.readFile with { cellStyles: true }
|
|
20
|
-
(xlsx format only),
|
|
18
|
+
Changes made in style-xlsx-m (by Shahrom Shukurov):
|
|
19
|
+
- XLSX.read / XLSX.readFile with { cellStyles: true } expose selected cell styles
|
|
20
|
+
(xlsx format only), with round-trip limitations documented in README.md.
|
|
21
21
|
- XLSX.utils.sheet_to_json accepts { getCellStyles: true } and returns
|
|
22
22
|
{ out, styles }.
|
|
23
23
|
- Worksheet page setup (paperSize, scale, fitToWidth, orientation) is read
|
|
@@ -25,9 +25,21 @@ Changes made in style-xlsx-m (by Shukurov Shahrom):
|
|
|
25
25
|
- XLSX.write / writeFile / writeFileSync / writeXLSX / writeFileXLSX are
|
|
26
26
|
delegated to the bundled xlsx-js-style build.
|
|
27
27
|
|
|
28
|
-
Modified source files carry a "Modified by Shukurov
|
|
28
|
+
Modified source files carry a "Modified by Shahrom Shukurov" notice. The
|
|
29
29
|
original copyright headers have been kept.
|
|
30
30
|
|
|
31
31
|
This project is not affiliated with or endorsed by SheetJS LLC.
|
|
32
32
|
"SheetJS" is a trademark of its owner and is used here only to describe the
|
|
33
33
|
origin of the code.
|
|
34
|
+
|
|
35
|
+
Neither upstream npm tarball (xlsx 0.18.5, xlsx-js-style 1.2.0) ships a NOTICE
|
|
36
|
+
file. Their Apache 2.0 LICENSE texts and distributed copyright headers remain
|
|
37
|
+
intact. Bundled codepage and adler-32 notices, and the vendored commander
|
|
38
|
+
license, are also retained in third-party-licenses/. External npm dependencies
|
|
39
|
+
retain their own license files when installed.
|
|
40
|
+
|
|
41
|
+
Additional locally modified sources: xlsx.mjs, types/index.d.ts,
|
|
42
|
+
dist/xlsx.core.min.js, dist/xlsx.mini.min.js, dist/xlsx.extendscript.js,
|
|
43
|
+
xlsx-js-style/dist/xlsx.min.js, xlsx-js-style/dist/xlsx.bundle.js,
|
|
44
|
+
xlsx-js-style/dist/shim.min.js, xlsx-js-style/types/index.d.ts. These include
|
|
45
|
+
legacy source builds that are not shipped in the release tarball.
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# style-xlsx-m
|
|
2
2
|
|
|
3
|
-
Read and write `.xlsx` files in Node.js
|
|
3
|
+
Read and write `.xlsx` files with selected cell styles in Node.js or bundled browser code, and set page setup for printing.
|
|
4
4
|
|
|
5
5
|
Based on [SheetJS Community Edition](https://github.com/SheetJS/sheetjs) (`xlsx` 0.18.5) and [xlsx-js-style](https://github.com/gitbrent/xlsx-js-style).
|
|
6
6
|
|
|
@@ -11,11 +11,11 @@ Based on [SheetJS Community Edition](https://github.com/SheetJS/sheetjs) (`xlsx`
|
|
|
11
11
|
| | SheetJS (npm `xlsx`) | xlsx-js-style | style-xlsx-m |
|
|
12
12
|
| :-- | :-- | :-- | :-- |
|
|
13
13
|
| Write cell styles | no | yes | yes |
|
|
14
|
-
| Read
|
|
14
|
+
| Read styles ready for styled writing | fill metadata only | fill metadata only | selected styles (`cellStyles: true`; see limitations) |
|
|
15
15
|
| `sheet_to_json` returns styles | no | no | yes (`getCellStyles: true`) |
|
|
16
16
|
| Page setup (`!pageSetup`) | no | no | yes |
|
|
17
17
|
|
|
18
|
-
The use case is editing
|
|
18
|
+
The use case is editing a tested Excel template: read it, change the data, and save it with the supported formatting. Test your own templates before relying on a round trip.
|
|
19
19
|
|
|
20
20
|
## Installation
|
|
21
21
|
|
|
@@ -50,7 +50,7 @@ For everything else (`utils`, `read` options, other formats) see the [SheetJS do
|
|
|
50
50
|
|
|
51
51
|
## Reading a file with styles
|
|
52
52
|
|
|
53
|
-
Pass `{ cellStyles: true }` to `readFile` (or `read`).
|
|
53
|
+
Pass `{ cellStyles: true }` to `readFile` (or `read`). Styled cells expose an `s` object for the writer. The independent openpyxl fixture confirms RGB solid fills, a theme-4 fill with tint, RGB/theme borders, font name/size/colour, bold/italic/single underline, and alignment. Number/date formats, merges, column widths, row heights, and A4 landscape page setup with scale 91 also survive that fixture. This is a partial round trip; see the limitations below.
|
|
54
54
|
|
|
55
55
|
```js
|
|
56
56
|
const XLSX = require('style-xlsx-m');
|
|
@@ -58,7 +58,7 @@ const XLSX = require('style-xlsx-m');
|
|
|
58
58
|
const wb = XLSX.readFile('./demo.xlsx', { cellStyles: true });
|
|
59
59
|
const ws = wb.Sheets['demo'];
|
|
60
60
|
|
|
61
|
-
ws.A1.v = 'changed'; // value
|
|
61
|
+
ws.A1.v = 'changed'; // change the value; supported styles are written back
|
|
62
62
|
XLSX.writeFile(wb, 'demo-edited.xlsx');
|
|
63
63
|
```
|
|
64
64
|
|
|
@@ -67,16 +67,18 @@ Styles are also available per row from `sheet_to_json`:
|
|
|
67
67
|
```js
|
|
68
68
|
const { out, styles } = XLSX.utils.sheet_to_json(ws, { header: 1, getCellStyles: true });
|
|
69
69
|
// out[r][c] -> cell value
|
|
70
|
-
// styles[r][
|
|
70
|
+
// styles[r][i] -> style of the i-th visited cell ({} without a style)
|
|
71
71
|
```
|
|
72
72
|
|
|
73
73
|
Note: `styles[r]` lists the cells that `sheet_to_json` visits in that row, in order. It can be shorter than the sheet's width.
|
|
74
74
|
|
|
75
75
|
Reading styles works for `.xlsx` only, not `.xls`.
|
|
76
76
|
|
|
77
|
+
The `main` and `module` entries use the same style-reading build. In bundled browser code, use `import XLSX from 'style-xlsx-m'` and `XLSX.read(bytes, { type: 'array', cellStyles: true })` with a `Uint8Array` or `ArrayBuffer`. `readFile` requires the Node.js filesystem. Importing, editing and saving a styled template is tested with webpack for browser and Node.js targets.
|
|
78
|
+
|
|
77
79
|
## Cell styles reference
|
|
78
80
|
|
|
79
|
-
A cell is `{ v: value, t: type, s: style }`. The
|
|
81
|
+
A cell is `{ v: value, t: type, s: style }`. The example below writes `alignment`, `border`, `fill` and `font`. Set the cell's `z` property for a number format.
|
|
80
82
|
|
|
81
83
|
```js
|
|
82
84
|
const COLOR = { rgb: 'FF0000' }; // hex value, no leading "#"
|
|
@@ -97,7 +99,9 @@ const style = {
|
|
|
97
99
|
bottom: border,
|
|
98
100
|
left: border,
|
|
99
101
|
right: border,
|
|
100
|
-
diagonal: { style: 'thin', color: COLOR
|
|
102
|
+
diagonal: { style: 'thin', color: COLOR },
|
|
103
|
+
diagonalUp: false,
|
|
104
|
+
diagonalDown: true,
|
|
101
105
|
},
|
|
102
106
|
font: {
|
|
103
107
|
name: 'Calibri',
|
|
@@ -137,19 +141,24 @@ When a file is **read**, `ws['!pageSetup']` is the raw `<pageSetup .../>` XML ta
|
|
|
137
141
|
|
|
138
142
|
- Based on SheetJS 0.18.5 (see the security note above). Do not parse untrusted files.
|
|
139
143
|
- Cell styles are read from `.xlsx` only, not `.xls`.
|
|
140
|
-
- Reading is
|
|
141
|
-
-
|
|
142
|
-
-
|
|
143
|
-
-
|
|
144
|
+
- Reading is a partial round trip. A theme-4 solid fill with tint is preserved, but a theme-index-0 fill loses its colour. Its `s.fill.fgColor` contains `{ theme: 0 }`; the bundled upstream writer drops that colour.
|
|
145
|
+
- An empty sheet returns `[]` even when `getCellStyles: true` is requested.
|
|
146
|
+
- Indexed border colours are exposed and saved as RGB. The tested indexed red keeps its RGB colour, but loses the indexed palette reference. Theme border colours keep their theme and tint. Custom theme palettes have not been tested.
|
|
147
|
+
- Single underline is confirmed. Other underline variants, gradient fills, conditional formatting, and diagonal border reading are not verified. Do not assume they are preserved.
|
|
148
|
+
- Number formats are preserved in the tested numeric and date cells, but are not part of `s`; use `cellNF: true` to expose them in `cell.z`. Merges, column widths and row heights are worksheet metadata (`!merges`, `!cols`, `!rows`), not cell styles.
|
|
149
|
+
- `!pageSetup` is returned as a raw XML string on read. The original A4/landscape/scale tag is preserved on save. To change it, assign the object shown above with string values. Numeric object values and other print settings are not verified.
|
|
150
|
+
- The TypeScript definitions are inherited from SheetJS with a `getCellStyles` option added. `s` and `!pageSetup` are not fully typed, and the `sheet_to_json` return types do not describe `{ out, styles }`.
|
|
151
|
+
- The `main` and `module` entries share the tested style reader. The separate CDN entries (`unpkg` and `jsdelivr`) remain upstream SheetJS builds and do not provide the same style-reading guarantees. Full Vite and Next.js applications have not been tested.
|
|
152
|
+
- Only these synchronous write functions are delegated to xlsx-js-style: `write`, `writeFile`, `writeFileSync`, `writeXLSX`, `writeFileXLSX`. `writeFileAsync` uses the inherited SheetJS writer and is outside these style guarantees.
|
|
144
153
|
|
|
145
154
|
## Credits & License
|
|
146
155
|
|
|
147
156
|
This package is a fork of [SheetJS Community Edition](https://github.com/SheetJS/sheetjs) and includes code from [xlsx-js-style](https://github.com/gitbrent/xlsx-js-style). Both are licensed under the Apache License 2.0.
|
|
148
157
|
|
|
149
|
-
Changes in this fork (by Shukurov
|
|
150
|
-
- Reading existing `.xlsx` files
|
|
158
|
+
Changes in this fork (by Shahrom Shukurov):
|
|
159
|
+
- Reading selected cell styles from existing `.xlsx` files (`cellStyles: true`)
|
|
151
160
|
- `getCellStyles` option for `sheet_to_json`
|
|
152
161
|
- Page setup for printing (paper size, orientation, scale)
|
|
153
162
|
|
|
154
163
|
This project is not affiliated with or endorsed by SheetJS LLC.
|
|
155
|
-
Licensed under the Apache License 2.0. See [LICENSE](LICENSE) and [NOTICE](NOTICE).
|
|
164
|
+
Licensed under the Apache License 2.0. See [LICENSE](https://github.com/MOR8T/style-xlsx-m/blob/main/LICENSE) and [NOTICE](https://github.com/MOR8T/style-xlsx-m/blob/main/NOTICE).
|
package/package.json
CHANGED
|
@@ -1,110 +1,118 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
2
|
+
"name": "style-xlsx-m",
|
|
3
|
+
"version": "0.1.34",
|
|
4
|
+
"author": "Shahrom Shukurov",
|
|
5
|
+
"description": "Fork of SheetJS (xlsx 0.18.5) and xlsx-js-style: read .xlsx files with cell styles, write styled cells, and set page setup for printing.",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"excel",
|
|
8
|
+
"xls",
|
|
9
|
+
"xlsx",
|
|
10
|
+
"xlsm",
|
|
11
|
+
"xlsb",
|
|
12
|
+
"ods",
|
|
13
|
+
"csv",
|
|
14
|
+
"dbf",
|
|
15
|
+
"dif",
|
|
16
|
+
"sylk",
|
|
17
|
+
"office",
|
|
18
|
+
"spreadsheet",
|
|
19
|
+
"style",
|
|
20
|
+
"print",
|
|
21
|
+
"format",
|
|
22
|
+
"workbook",
|
|
23
|
+
"worksheet",
|
|
24
|
+
"styles",
|
|
25
|
+
"export",
|
|
26
|
+
"sheetjs",
|
|
27
|
+
"xlsx-js-style",
|
|
28
|
+
"page-setup"
|
|
29
|
+
],
|
|
30
|
+
"main": "xlsx.js",
|
|
31
|
+
"module": "./xlsx.js",
|
|
32
|
+
"unpkg": "dist/xlsx.full.min.js",
|
|
33
|
+
"jsdelivr": "dist/xlsx.full.min.js",
|
|
34
|
+
"types": "types/index.d.ts",
|
|
35
|
+
"browser": {
|
|
36
|
+
"buffer": false,
|
|
37
|
+
"crypto": false,
|
|
38
|
+
"stream": false,
|
|
39
|
+
"process": false,
|
|
40
|
+
"fs": false
|
|
41
|
+
},
|
|
42
|
+
"sideEffects": false,
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"adler-32": "~1.3.0",
|
|
45
|
+
"cfb": "~1.2.1",
|
|
46
|
+
"codepage": "~1.15.0",
|
|
47
|
+
"crc-32": "~1.2.1",
|
|
48
|
+
"ssf": "~0.11.2",
|
|
49
|
+
"wmf": "~1.0.1",
|
|
50
|
+
"word": "~0.3.0"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@sheetjs/uglify-js": "~2.7.3",
|
|
54
|
+
"@types/node": "^8.5.9",
|
|
55
|
+
"acorn": "7.4.1",
|
|
56
|
+
"alex": "8.1.1",
|
|
57
|
+
"blanket": "~1.2.3",
|
|
58
|
+
"commander": "~2.17.1",
|
|
59
|
+
"dtslint": "^0.1.2",
|
|
60
|
+
"eslint": "7.23.0",
|
|
61
|
+
"eslint-plugin-html": "^6.1.2",
|
|
62
|
+
"eslint-plugin-json": "^2.1.2",
|
|
63
|
+
"exit-on-epipe": "~1.0.1",
|
|
64
|
+
"fflate": "^0.7.1",
|
|
65
|
+
"jsdom": "~11.1.0",
|
|
66
|
+
"markdown-spellcheck": "^1.3.1",
|
|
67
|
+
"mocha": "~2.5.3",
|
|
68
|
+
"sinon": "^1.17.7",
|
|
69
|
+
"typescript": "2.2.0",
|
|
70
|
+
"webpack": "5.111.1"
|
|
71
|
+
},
|
|
72
|
+
"repository": {
|
|
73
|
+
"type": "git",
|
|
74
|
+
"url": "git+https://github.com/MOR8T/style-xlsx-m.git"
|
|
75
|
+
},
|
|
76
|
+
"scripts": {
|
|
77
|
+
"test": "node test/run.js"
|
|
78
|
+
},
|
|
79
|
+
"config": {
|
|
80
|
+
"blanket": {
|
|
81
|
+
"pattern": "xlsx.js"
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
"alex": {
|
|
85
|
+
"allow": [
|
|
86
|
+
"chinese",
|
|
87
|
+
"special",
|
|
88
|
+
"simple",
|
|
89
|
+
"just",
|
|
90
|
+
"crash",
|
|
91
|
+
"wtf",
|
|
92
|
+
"holes"
|
|
93
|
+
]
|
|
94
|
+
},
|
|
95
|
+
"homepage": "https://github.com/MOR8T/style-xlsx-m#readme",
|
|
96
|
+
"bugs": {
|
|
97
|
+
"url": "https://github.com/MOR8T/style-xlsx-m/issues"
|
|
98
|
+
},
|
|
99
|
+
"license": "Apache-2.0",
|
|
100
|
+
"engines": {
|
|
101
|
+
"node": ">=0.8"
|
|
102
|
+
},
|
|
103
|
+
"files": [
|
|
104
|
+
"LICENSE",
|
|
105
|
+
"NOTICE",
|
|
106
|
+
"README.md",
|
|
107
|
+
"xlsx.js",
|
|
108
|
+
"types/index.d.ts",
|
|
109
|
+
"dist/LICENSE",
|
|
110
|
+
"dist/cpexcel.js",
|
|
111
|
+
"dist/xlsx.full.min.js",
|
|
112
|
+
"xlsx-js-style/dist/LICENSE",
|
|
113
|
+
"xlsx-js-style/dist/xlsx.min.js",
|
|
114
|
+
"xlsx-js-style/dist/xlsx.bundle.js",
|
|
115
|
+
"xlsx-js-style/dist/cpexcel.js",
|
|
116
|
+
"third-party-licenses/"
|
|
117
|
+
]
|
|
110
118
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/* index.d.ts (C) 2015-present SheetJS and contributors */
|
|
2
|
+
/* Modified by Shahrom Shukurov: getCellStyles option and worksheet naming declaration in the inherited definitions. See NOTICE. */
|
|
2
3
|
// TypeScript Version: 2.2
|
|
3
4
|
// import * as CFB from "cfb";
|
|
4
5
|
// import * as SSF from "ssf";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/* xlsx-js-style 1.2.0-beta @ 2022-04-05T01:40:40.843Z */
|
|
2
|
+
/* Modified by Shahrom Shukurov: page setup and sheet_to_json style collection in the bundled writer; local formatting. See NOTICE. */
|
|
2
3
|
var XLSX = {};
|
|
3
4
|
function make_xlsx_lib(a) {
|
|
4
5
|
(a.version = "0.18.5"), (a.style_version = "1.2.0");
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/* xlsx-js-style 1.2.0-beta @ 2022-04-05T01:40:40.843Z */
|
|
2
|
+
/* Modified by Shahrom Shukurov: page setup and sheet_to_json style collection in the bundled writer; local formatting. See NOTICE. */
|
|
2
3
|
var XLSX = {};
|
|
3
4
|
function make_xlsx_lib(a) {
|
|
4
5
|
(a.version = "0.18.5"), (a.style_version = "1.2.0");
|
package/xlsx.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*! xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */
|
|
2
|
-
/* Modified by Shukurov
|
|
2
|
+
/* Modified by Shahrom Shukurov: style reading, sheet_to_json getCellStyles, page setup, and synchronous style writes; corrected fills and border colours. See NOTICE. */
|
|
3
3
|
/* vim: set ts=2: */
|
|
4
4
|
/*exported XLSX */
|
|
5
5
|
/*global exports, module, require:false, process:false, Buffer:false, ArrayBuffer:false, DataView:false, Deno:false */
|
|
@@ -10169,21 +10169,14 @@ function parse_borders(t, styles, themes, opts) {
|
|
|
10169
10169
|
var icv = XLSIcv[color.index];
|
|
10170
10170
|
if(color.index == 81) icv = XLSIcv[1];
|
|
10171
10171
|
if(!icv) icv = XLSIcv[1]; //throw new Error(x); // note: 206 is valid
|
|
10172
|
-
color.rgb = icv[0]
|
|
10172
|
+
color.rgb = [icv[0], icv[1], icv[2]].map(function(c) { return ('0' + c.toString(16)).slice(-2); }).join('').toUpperCase();
|
|
10173
10173
|
} else if(y.theme) {
|
|
10174
10174
|
color = {}
|
|
10175
10175
|
color.theme = parseInt(y.theme, 10);
|
|
10176
10176
|
if(y.tint) color.tint = parseFloat(y.tint);
|
|
10177
|
-
|
|
10178
|
-
color.rgb = rgb_tint(themes.themeElements.clrScheme[color.theme].rgb, color.tint || 0);
|
|
10179
|
-
}
|
|
10180
|
-
}
|
|
10181
|
-
if(color.index && color.rgb && !color.theme){
|
|
10182
|
-
if(color.index == 64) color = {rgb:'000'}
|
|
10183
|
-
else color = {rgb:color.rgb}
|
|
10177
|
+
/* Keep the theme reference and tint for the style writer. */
|
|
10184
10178
|
}
|
|
10185
|
-
|
|
10186
|
-
else color = {index:color.index};
|
|
10179
|
+
if(color.index != null) color = {rgb:color.rgb};
|
|
10187
10180
|
break;
|
|
10188
10181
|
case '<color/>': case '</color>': break;
|
|
10189
10182
|
|
|
@@ -14536,28 +14529,10 @@ function safe_format(p, fmtid, fillid, opts, themes, styles, fontid, borderid,cf
|
|
|
14536
14529
|
else p.w = SSF_format(fmtid,p.v,_ssfopts);
|
|
14537
14530
|
} catch(e) { if(opts.WTF) throw e; }
|
|
14538
14531
|
if(!opts.cellStyles) return;
|
|
14539
|
-
|
|
14540
|
-
|
|
14541
|
-
|
|
14542
|
-
|
|
14543
|
-
// p.s.fgColor.rgb = rgb_tint(themes.themeElements.clrScheme[pss.fgColor.theme].rgb, pss.fgColor.tint || 0);
|
|
14544
|
-
// if(opts.WTF) p.s.fgColor.raw_rgb = themes.themeElements.clrScheme[pss.fgColor.theme].rgb;
|
|
14545
|
-
// }
|
|
14546
|
-
// if (pss.bgColor && (pss.bgColor.theme || pss.bgColor.theme == 0)) {
|
|
14547
|
-
// p.s.Fills[fillid].bgColor.rgb = rgb_tint(themes.themeElements.clrScheme[pss.bgColor.theme].rgb, pss.bgColor.tint || 0);
|
|
14548
|
-
// if(opts.WTF) p.s.bgColor.raw_rgb = themes.themeElements.clrScheme[pss.bgColor.theme].rgb;
|
|
14549
|
-
// }
|
|
14550
|
-
// if(pss.patternType){
|
|
14551
|
-
// if(pss.fgColor.rgb){
|
|
14552
|
-
// const bg = { rgb: pss.fgColor.rgb };
|
|
14553
|
-
// p.s.fill = {fgColor: bg, bgColor: bg ,
|
|
14554
|
-
// patternType: pss.patternType == 'solid' ? 'solid' : 'none',
|
|
14555
|
-
// }
|
|
14556
|
-
// }else {
|
|
14557
|
-
// p.s.fill = {patternType: pss.patternType == 'solid' ? 'solid' : 'none',}
|
|
14558
|
-
// }
|
|
14559
|
-
// }
|
|
14560
|
-
// } catch(e) { if(opts.WTF && styles.Fills) throw e; }
|
|
14532
|
+
/* Map the parsed fill to the nested shape accepted by xlsx-js-style. */
|
|
14533
|
+
if(fillid != null && styles.Fills && styles.Fills[fillid]) {
|
|
14534
|
+
p.s = {...p.s, fill: {...styles.Fills[fillid]}};
|
|
14535
|
+
}
|
|
14561
14536
|
if(fontid != null){
|
|
14562
14537
|
p.s = {...p.s,...styles.Fonts[fontid],}
|
|
14563
14538
|
if (p.s.sz) p.s.font = { ...p.s.font, sz: p.s.sz };
|
|
@@ -24310,7 +24285,7 @@ function sheet_to_json(sheet, opts) {
|
|
|
24310
24285
|
if((row.isempty === false) || (header === 1 ? o.blankrows !== false : !!o.blankrows)) styles[stylesi++] = row.styles;
|
|
24311
24286
|
}
|
|
24312
24287
|
out.length = outi;
|
|
24313
|
-
if(
|
|
24288
|
+
if(o.getCellStyles){
|
|
24314
24289
|
return {out, styles:styles}
|
|
24315
24290
|
}
|
|
24316
24291
|
return out;
|