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.
Files changed (206) hide show
  1. package/NOTICE +18 -6
  2. package/README.md +24 -15
  3. package/package.json +116 -108
  4. package/types/index.d.ts +1 -0
  5. package/xlsx-js-style/dist/xlsx.bundle.js +1 -0
  6. package/xlsx-js-style/dist/xlsx.min.js +1 -0
  7. package/xlsx.js +9 -34
  8. package/bin/xlsx.njs +0 -310
  9. package/dist/cpexcel.full.mjs +0 -1502
  10. package/dist/shim.min.js +0 -2
  11. package/dist/xlsx.core.min.js +0 -27357
  12. package/dist/xlsx.core.min.map +0 -1
  13. package/dist/xlsx.extendscript.js +0 -24643
  14. package/dist/xlsx.full.min.map +0 -1
  15. package/dist/xlsx.mini.min.js +0 -13978
  16. package/dist/xlsx.mini.min.map +0 -1
  17. package/dist/xlsx.zahl.js +0 -4
  18. package/dist/xlsx.zahl.mjs +0 -2
  19. package/types/tsconfig.json +0 -15
  20. package/xlsx-js-style/bin/xlsx.njs +0 -284
  21. package/xlsx-js-style/dist/cpexcel.full.mjs +0 -1502
  22. package/xlsx-js-style/dist/shim.min.js +0 -229
  23. package/xlsx-js-style/dist/xlsx.bundle.js.map +0 -1
  24. package/xlsx-js-style/dist/xlsx.min.js.map +0 -1
  25. package/xlsx-js-style/node_modules/.bin/adler32 +0 -12
  26. package/xlsx-js-style/node_modules/.bin/adler32.cmd +0 -17
  27. package/xlsx-js-style/node_modules/.bin/adler32.ps1 +0 -28
  28. package/xlsx-js-style/node_modules/.bin/codepage +0 -12
  29. package/xlsx-js-style/node_modules/.bin/codepage.cmd +0 -17
  30. package/xlsx-js-style/node_modules/.bin/codepage.ps1 +0 -28
  31. package/xlsx-js-style/node_modules/adler-32/README.md +0 -139
  32. package/xlsx-js-style/node_modules/adler-32/adler32.js +0 -92
  33. package/xlsx-js-style/node_modules/adler-32/bin/adler32.njs +0 -87
  34. package/xlsx-js-style/node_modules/adler-32/package.json +0 -42
  35. package/xlsx-js-style/node_modules/adler-32/types/index.d.ts +0 -14
  36. package/xlsx-js-style/node_modules/adler-32/types/tsconfig.json +0 -14
  37. package/xlsx-js-style/node_modules/adler-32/types/tslint.json +0 -11
  38. package/xlsx-js-style/node_modules/codepage/README.md +0 -347
  39. package/xlsx-js-style/node_modules/codepage/bin/codepage.njs +0 -98
  40. package/xlsx-js-style/node_modules/codepage/bits/10000.js +0 -2
  41. package/xlsx-js-style/node_modules/codepage/bits/10001.js +0 -115
  42. package/xlsx-js-style/node_modules/codepage/bits/10002.js +0 -253
  43. package/xlsx-js-style/node_modules/codepage/bits/10003.js +0 -183
  44. package/xlsx-js-style/node_modules/codepage/bits/10004.js +0 -2
  45. package/xlsx-js-style/node_modules/codepage/bits/10005.js +0 -2
  46. package/xlsx-js-style/node_modules/codepage/bits/10006.js +0 -2
  47. package/xlsx-js-style/node_modules/codepage/bits/10007.js +0 -2
  48. package/xlsx-js-style/node_modules/codepage/bits/10008.js +0 -167
  49. package/xlsx-js-style/node_modules/codepage/bits/10010.js +0 -2
  50. package/xlsx-js-style/node_modules/codepage/bits/10017.js +0 -2
  51. package/xlsx-js-style/node_modules/codepage/bits/10021.js +0 -2
  52. package/xlsx-js-style/node_modules/codepage/bits/10029.js +0 -2
  53. package/xlsx-js-style/node_modules/codepage/bits/10079.js +0 -2
  54. package/xlsx-js-style/node_modules/codepage/bits/10081.js +0 -2
  55. package/xlsx-js-style/node_modules/codepage/bits/10082.js +0 -2
  56. package/xlsx-js-style/node_modules/codepage/bits/1010.js +0 -2
  57. package/xlsx-js-style/node_modules/codepage/bits/1026.js +0 -2
  58. package/xlsx-js-style/node_modules/codepage/bits/1047.js +0 -2
  59. package/xlsx-js-style/node_modules/codepage/bits/1132.js +0 -2
  60. package/xlsx-js-style/node_modules/codepage/bits/1140.js +0 -2
  61. package/xlsx-js-style/node_modules/codepage/bits/1141.js +0 -2
  62. package/xlsx-js-style/node_modules/codepage/bits/1142.js +0 -2
  63. package/xlsx-js-style/node_modules/codepage/bits/1143.js +0 -2
  64. package/xlsx-js-style/node_modules/codepage/bits/1144.js +0 -2
  65. package/xlsx-js-style/node_modules/codepage/bits/1145.js +0 -2
  66. package/xlsx-js-style/node_modules/codepage/bits/1146.js +0 -2
  67. package/xlsx-js-style/node_modules/codepage/bits/1147.js +0 -2
  68. package/xlsx-js-style/node_modules/codepage/bits/1148.js +0 -2
  69. package/xlsx-js-style/node_modules/codepage/bits/1149.js +0 -2
  70. package/xlsx-js-style/node_modules/codepage/bits/1250.js +0 -2
  71. package/xlsx-js-style/node_modules/codepage/bits/1251.js +0 -2
  72. package/xlsx-js-style/node_modules/codepage/bits/1252.js +0 -2
  73. package/xlsx-js-style/node_modules/codepage/bits/1253.js +0 -2
  74. package/xlsx-js-style/node_modules/codepage/bits/1254.js +0 -2
  75. package/xlsx-js-style/node_modules/codepage/bits/1255.js +0 -2
  76. package/xlsx-js-style/node_modules/codepage/bits/1256.js +0 -2
  77. package/xlsx-js-style/node_modules/codepage/bits/1257.js +0 -2
  78. package/xlsx-js-style/node_modules/codepage/bits/1258.js +0 -2
  79. package/xlsx-js-style/node_modules/codepage/bits/1361.js +0 -231
  80. package/xlsx-js-style/node_modules/codepage/bits/20000.js +0 -193
  81. package/xlsx-js-style/node_modules/codepage/bits/20001.js +0 -217
  82. package/xlsx-js-style/node_modules/codepage/bits/20002.js +0 -167
  83. package/xlsx-js-style/node_modules/codepage/bits/20003.js +0 -213
  84. package/xlsx-js-style/node_modules/codepage/bits/20004.js +0 -193
  85. package/xlsx-js-style/node_modules/codepage/bits/20005.js +0 -223
  86. package/xlsx-js-style/node_modules/codepage/bits/20105.js +0 -2
  87. package/xlsx-js-style/node_modules/codepage/bits/20106.js +0 -2
  88. package/xlsx-js-style/node_modules/codepage/bits/20107.js +0 -2
  89. package/xlsx-js-style/node_modules/codepage/bits/20108.js +0 -2
  90. package/xlsx-js-style/node_modules/codepage/bits/20261.js +0 -31
  91. package/xlsx-js-style/node_modules/codepage/bits/20269.js +0 -2
  92. package/xlsx-js-style/node_modules/codepage/bits/20273.js +0 -2
  93. package/xlsx-js-style/node_modules/codepage/bits/20277.js +0 -2
  94. package/xlsx-js-style/node_modules/codepage/bits/20278.js +0 -2
  95. package/xlsx-js-style/node_modules/codepage/bits/20280.js +0 -2
  96. package/xlsx-js-style/node_modules/codepage/bits/20284.js +0 -2
  97. package/xlsx-js-style/node_modules/codepage/bits/20285.js +0 -2
  98. package/xlsx-js-style/node_modules/codepage/bits/20290.js +0 -2
  99. package/xlsx-js-style/node_modules/codepage/bits/20297.js +0 -2
  100. package/xlsx-js-style/node_modules/codepage/bits/20420.js +0 -2
  101. package/xlsx-js-style/node_modules/codepage/bits/20423.js +0 -2
  102. package/xlsx-js-style/node_modules/codepage/bits/20424.js +0 -2
  103. package/xlsx-js-style/node_modules/codepage/bits/20833.js +0 -2
  104. package/xlsx-js-style/node_modules/codepage/bits/20838.js +0 -2
  105. package/xlsx-js-style/node_modules/codepage/bits/20866.js +0 -2
  106. package/xlsx-js-style/node_modules/codepage/bits/20871.js +0 -2
  107. package/xlsx-js-style/node_modules/codepage/bits/20880.js +0 -2
  108. package/xlsx-js-style/node_modules/codepage/bits/20905.js +0 -2
  109. package/xlsx-js-style/node_modules/codepage/bits/20924.js +0 -2
  110. package/xlsx-js-style/node_modules/codepage/bits/20932.js +0 -189
  111. package/xlsx-js-style/node_modules/codepage/bits/20936.js +0 -167
  112. package/xlsx-js-style/node_modules/codepage/bits/20949.js +0 -183
  113. package/xlsx-js-style/node_modules/codepage/bits/21025.js +0 -2
  114. package/xlsx-js-style/node_modules/codepage/bits/21027.js +0 -2
  115. package/xlsx-js-style/node_modules/codepage/bits/21866.js +0 -2
  116. package/xlsx-js-style/node_modules/codepage/bits/28591.js +0 -2
  117. package/xlsx-js-style/node_modules/codepage/bits/28592.js +0 -2
  118. package/xlsx-js-style/node_modules/codepage/bits/28593.js +0 -2
  119. package/xlsx-js-style/node_modules/codepage/bits/28594.js +0 -2
  120. package/xlsx-js-style/node_modules/codepage/bits/28595.js +0 -2
  121. package/xlsx-js-style/node_modules/codepage/bits/28596.js +0 -2
  122. package/xlsx-js-style/node_modules/codepage/bits/28597.js +0 -2
  123. package/xlsx-js-style/node_modules/codepage/bits/28598.js +0 -2
  124. package/xlsx-js-style/node_modules/codepage/bits/28599.js +0 -2
  125. package/xlsx-js-style/node_modules/codepage/bits/28600.js +0 -2
  126. package/xlsx-js-style/node_modules/codepage/bits/28601.js +0 -2
  127. package/xlsx-js-style/node_modules/codepage/bits/28603.js +0 -2
  128. package/xlsx-js-style/node_modules/codepage/bits/28604.js +0 -2
  129. package/xlsx-js-style/node_modules/codepage/bits/28605.js +0 -2
  130. package/xlsx-js-style/node_modules/codepage/bits/28606.js +0 -2
  131. package/xlsx-js-style/node_modules/codepage/bits/29001.js +0 -2
  132. package/xlsx-js-style/node_modules/codepage/bits/37.js +0 -2
  133. package/xlsx-js-style/node_modules/codepage/bits/38598.js +0 -2
  134. package/xlsx-js-style/node_modules/codepage/bits/437.js +0 -2
  135. package/xlsx-js-style/node_modules/codepage/bits/47451.js +0 -2
  136. package/xlsx-js-style/node_modules/codepage/bits/500.js +0 -2
  137. package/xlsx-js-style/node_modules/codepage/bits/50220.js +0 -395
  138. package/xlsx-js-style/node_modules/codepage/bits/50221.js +0 -395
  139. package/xlsx-js-style/node_modules/codepage/bits/50222.js +0 -395
  140. package/xlsx-js-style/node_modules/codepage/bits/50225.js +0 -259
  141. package/xlsx-js-style/node_modules/codepage/bits/50227.js +0 -257
  142. package/xlsx-js-style/node_modules/codepage/bits/51932.js +0 -171
  143. package/xlsx-js-style/node_modules/codepage/bits/51936.js +0 -257
  144. package/xlsx-js-style/node_modules/codepage/bits/51949.js +0 -183
  145. package/xlsx-js-style/node_modules/codepage/bits/52936.js +0 -7
  146. package/xlsx-js-style/node_modules/codepage/bits/54936.js +0 -257
  147. package/xlsx-js-style/node_modules/codepage/bits/57002.js +0 -39
  148. package/xlsx-js-style/node_modules/codepage/bits/57003.js +0 -23
  149. package/xlsx-js-style/node_modules/codepage/bits/57004.js +0 -7
  150. package/xlsx-js-style/node_modules/codepage/bits/57005.js +0 -15
  151. package/xlsx-js-style/node_modules/codepage/bits/57006.js +0 -23
  152. package/xlsx-js-style/node_modules/codepage/bits/57007.js +0 -21
  153. package/xlsx-js-style/node_modules/codepage/bits/57008.js +0 -17
  154. package/xlsx-js-style/node_modules/codepage/bits/57009.js +0 -13
  155. package/xlsx-js-style/node_modules/codepage/bits/57010.js +0 -15
  156. package/xlsx-js-style/node_modules/codepage/bits/57011.js +0 -17
  157. package/xlsx-js-style/node_modules/codepage/bits/620.js +0 -2
  158. package/xlsx-js-style/node_modules/codepage/bits/708.js +0 -2
  159. package/xlsx-js-style/node_modules/codepage/bits/720.js +0 -2
  160. package/xlsx-js-style/node_modules/codepage/bits/737.js +0 -2
  161. package/xlsx-js-style/node_modules/codepage/bits/775.js +0 -2
  162. package/xlsx-js-style/node_modules/codepage/bits/808.js +0 -2
  163. package/xlsx-js-style/node_modules/codepage/bits/850.js +0 -2
  164. package/xlsx-js-style/node_modules/codepage/bits/852.js +0 -2
  165. package/xlsx-js-style/node_modules/codepage/bits/855.js +0 -2
  166. package/xlsx-js-style/node_modules/codepage/bits/857.js +0 -2
  167. package/xlsx-js-style/node_modules/codepage/bits/858.js +0 -2
  168. package/xlsx-js-style/node_modules/codepage/bits/860.js +0 -2
  169. package/xlsx-js-style/node_modules/codepage/bits/861.js +0 -2
  170. package/xlsx-js-style/node_modules/codepage/bits/862.js +0 -2
  171. package/xlsx-js-style/node_modules/codepage/bits/863.js +0 -2
  172. package/xlsx-js-style/node_modules/codepage/bits/864.js +0 -2
  173. package/xlsx-js-style/node_modules/codepage/bits/865.js +0 -2
  174. package/xlsx-js-style/node_modules/codepage/bits/866.js +0 -2
  175. package/xlsx-js-style/node_modules/codepage/bits/869.js +0 -2
  176. package/xlsx-js-style/node_modules/codepage/bits/870.js +0 -2
  177. package/xlsx-js-style/node_modules/codepage/bits/872.js +0 -2
  178. package/xlsx-js-style/node_modules/codepage/bits/874.js +0 -2
  179. package/xlsx-js-style/node_modules/codepage/bits/875.js +0 -2
  180. package/xlsx-js-style/node_modules/codepage/bits/895.js +0 -2
  181. package/xlsx-js-style/node_modules/codepage/bits/932.js +0 -95
  182. package/xlsx-js-style/node_modules/codepage/bits/936.js +0 -257
  183. package/xlsx-js-style/node_modules/codepage/bits/949.js +0 -253
  184. package/xlsx-js-style/node_modules/codepage/bits/950.js +0 -179
  185. package/xlsx-js-style/node_modules/codepage/cptable.js +0 -6347
  186. package/xlsx-js-style/node_modules/codepage/cputils.js +0 -528
  187. package/xlsx-js-style/node_modules/codepage/dist/LICENSE +0 -14
  188. package/xlsx-js-style/node_modules/codepage/dist/cpexcel.full.js +0 -1505
  189. package/xlsx-js-style/node_modules/codepage/dist/cputils.js +0 -528
  190. package/xlsx-js-style/node_modules/codepage/dist/sbcs.full.js +0 -639
  191. package/xlsx-js-style/node_modules/codepage/node_modules/commander/CHANGELOG.md +0 -350
  192. package/xlsx-js-style/node_modules/codepage/node_modules/commander/Readme.md +0 -408
  193. package/xlsx-js-style/node_modules/codepage/node_modules/commander/index.js +0 -1157
  194. package/xlsx-js-style/node_modules/codepage/node_modules/commander/package.json +0 -37
  195. package/xlsx-js-style/node_modules/codepage/node_modules/commander/typings/index.d.ts +0 -309
  196. package/xlsx-js-style/node_modules/codepage/package.json +0 -67
  197. package/xlsx-js-style/node_modules/codepage/types/index.d.ts +0 -39
  198. package/xlsx-js-style/node_modules/codepage/types/tsconfig.json +0 -14
  199. package/xlsx-js-style/node_modules/codepage/types/tslint.json +0 -11
  200. package/xlsx-js-style/types/index.d.ts +0 -1068
  201. package/xlsx-js-style/types/tsconfig.json +0 -15
  202. package/xlsx.mjs +0 -24600
  203. package/xlsxworker.js +0 -14
  204. /package/{xlsx-js-style/node_modules/adler-32/LICENSE → third-party-licenses/adler-32-LICENSE} +0 -0
  205. /package/{xlsx-js-style/node_modules/codepage/LICENSE → third-party-licenses/codepage-LICENSE} +0 -0
  206. /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 Shahrom
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 Shahrom):
19
- - XLSX.read / XLSX.readFile with { cellStyles: true } keep cell styles
20
- (xlsx format only), so a file can be edited and saved without losing them.
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 Shahrom" notice. The
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 with cell styles kept, and set page setup for printing.
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 cell styles from an existing `.xlsx` | no | no | yes (`cellStyles: true`) |
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 an existing styled Excel template: read it, change the data, and save it without losing the formatting.
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`). Each cell then has an `s` property. Edit values, save with `writeFile`, and the styles are written back.
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 changes, style stays
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][c] -> style object of that cell ({} if the cell has no style)
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 supported style properties are `alignment`, `border`, `fill` and `font`.
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, diagonalUp: false, diagonalDown: true },
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 not a full round trip. In testing, a solid cell fill and border colours written to a file did not come back in the cell's `s` object after `readFile`. Check your own templates and test before relying on this.
141
- - `!pageSetup` is returned as a raw XML string on read (see above).
142
- - The TypeScript definitions are inherited from SheetJS with a `getCellStyles` option added. The `s` style property and `!pageSetup` are not fully typed.
143
- - Only the write functions come from xlsx-js-style: `write`, `writeFile`, `writeFileSync`, `writeXLSX`, `writeFileXLSX`.
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 Shahrom):
150
- - Reading existing `.xlsx` files with cell styles preserved (`cellStyles: true`)
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
- "name": "style-xlsx-m",
3
- "version": "0.1.31",
4
- "author": "Shukurov Shahrom <hp.sh.shahrom@gmail.com> (https://github.com/MOR8T)",
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
- ],
29
- "bin": {
30
- "xlsx": "./bin/xlsx.njs"
31
- },
32
- "main": "xlsx.js",
33
- "module": "./xlsx-js-style/dist/xlsx.bundle.js",
34
- "unpkg": "dist/xlsx.full.min.js",
35
- "jsdelivr": "dist/xlsx.full.min.js",
36
- "types": "types/index.d.ts",
37
- "browser": {
38
- "buffer": false,
39
- "crypto": false,
40
- "stream": false,
41
- "process": false,
42
- "fs": false
43
- },
44
- "sideEffects": false,
45
- "dependencies": {
46
- "adler-32": "~1.3.0",
47
- "cfb": "~1.2.1",
48
- "codepage": "~1.15.0",
49
- "crc-32": "~1.2.1",
50
- "ssf": "~0.11.2",
51
- "wmf": "~1.0.1",
52
- "word": "~0.3.0"
53
- },
54
- "devDependencies": {
55
- "@sheetjs/uglify-js": "~2.7.3",
56
- "@types/node": "^8.5.9",
57
- "acorn": "7.4.1",
58
- "alex": "8.1.1",
59
- "blanket": "~1.2.3",
60
- "commander": "~2.17.1",
61
- "dtslint": "^0.1.2",
62
- "eslint": "7.23.0",
63
- "eslint-plugin-html": "^6.1.2",
64
- "eslint-plugin-json": "^2.1.2",
65
- "exit-on-epipe": "~1.0.1",
66
- "fflate": "^0.7.1",
67
- "jsdom": "~11.1.0",
68
- "markdown-spellcheck": "^1.3.1",
69
- "mocha": "~2.5.3",
70
- "sinon": "^1.17.7",
71
- "typescript": "2.2.0"
72
- },
73
- "repository": {
74
- "type": "git",
75
- "url": "git+https://github.com/MOR8T/STYLE-XSLX-M.git"
76
- },
77
- "scripts": {
78
- "pretest": "npm run lint",
79
- "test": "npm run tests-only",
80
- "pretest-only": "git submodule init && git submodule update",
81
- "tests-only": "make travis",
82
- "build": "make",
83
- "lint": "make fullint",
84
- "dtslint": "dtslint types"
85
- },
86
- "config": {
87
- "blanket": {
88
- "pattern": "xlsx.js"
89
- }
90
- },
91
- "alex": {
92
- "allow": [
93
- "chinese",
94
- "special",
95
- "simple",
96
- "just",
97
- "crash",
98
- "wtf",
99
- "holes"
100
- ]
101
- },
102
- "homepage": "https://github.com/MOR8T/STYLE-XSLX-M#readme",
103
- "bugs": {
104
- "url": "https://github.com/MOR8T/STYLE-XSLX-M/issues"
105
- },
106
- "license": "Apache-2.0",
107
- "engines": {
108
- "node": ">=0.8"
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 Shahrom: style reading, sheet_to_json getCellStyles, page setup, write via xlsx-js-style. See NOTICE. */
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].toString(16) + icv[1].toString(16) + icv[2].toString(16);
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
- if(y.theme && themes.themeElements && themes.themeElements.clrScheme) {
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
- else if(!color.index && color.rgb && color.theme) color = {rgb:color.rgb};
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
- // if(fillid != null) try {
14540
- // // p.s = {...styles.Fills[fillid]};
14541
- // const pss = {...styles.Fills[fillid]}
14542
- // if (pss.fgColor && pss.fgColor.theme && !pss.fgColor.rgb) {
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(opts.getCellStyles){
24288
+ if(o.getCellStyles){
24314
24289
  return {out, styles:styles}
24315
24290
  }
24316
24291
  return out;