@quirekit/xlsx 0.0.0-stage → 0.3.0

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 (336) hide show
  1. package/LICENSE.md +21 -0
  2. package/THIRD_PARTY_NOTICES.md +150 -0
  3. package/dist/index.d.mts +122 -0
  4. package/dist/index.d.mts.map +1 -0
  5. package/dist/index.mjs +19167 -0
  6. package/dist/index.mjs.map +1 -0
  7. package/licenses/saxes.LICENSE +64 -0
  8. package/licenses/xmlchars.LICENSE +18 -0
  9. package/package.json +52 -3
  10. package/src/bundle.ts +17 -0
  11. package/src/comments/legacy/read.ts +68 -0
  12. package/src/comments/legacy/write.ts +64 -0
  13. package/src/comments/package/ranges.ts +78 -0
  14. package/src/comments/package/read.ts +95 -0
  15. package/src/comments/package/roundtrip.test.ts +106 -0
  16. package/src/comments/package/write.ts +130 -0
  17. package/src/comments/thread/read.ts +69 -0
  18. package/src/comments/thread/write.ts +61 -0
  19. package/src/comments/types.ts +43 -0
  20. package/src/comments/xml.ts +50 -0
  21. package/src/create.ts +13 -0
  22. package/src/drawing/cache.ts +48 -0
  23. package/src/drawing/chart.test.ts +96 -0
  24. package/src/drawing/chart.ts +87 -0
  25. package/src/drawing/definition/plots.ts +76 -0
  26. package/src/drawing/definition/read.ts +65 -0
  27. package/src/drawing/definition/shape.ts +40 -0
  28. package/src/drawing/definition/types.ts +24 -0
  29. package/src/drawing/editable-picture.ts +80 -0
  30. package/src/drawing/graph.ts +148 -0
  31. package/src/drawing/identity.ts +22 -0
  32. package/src/drawing/import.ts +133 -0
  33. package/src/drawing/namespaces.ts +11 -0
  34. package/src/drawing/picture.test.ts +98 -0
  35. package/src/drawing/picture.ts +54 -0
  36. package/src/drawing/placement/anchor.ts +71 -0
  37. package/src/drawing/placement/axes.ts +113 -0
  38. package/src/drawing/placement/marker.ts +16 -0
  39. package/src/drawing/placement/transform.ts +132 -0
  40. package/src/drawing/placement/types.ts +20 -0
  41. package/src/drawing/presentation/cartesian/axes.ts +103 -0
  42. package/src/drawing/presentation/cartesian/plot.ts +109 -0
  43. package/src/drawing/presentation/cartesian/types.ts +9 -0
  44. package/src/drawing/presentation/layout.ts +29 -0
  45. package/src/drawing/presentation/paint.ts +56 -0
  46. package/src/drawing/presentation/properties.ts +31 -0
  47. package/src/drawing/read.ts +85 -0
  48. package/src/drawing/shapes/connector.ts +55 -0
  49. package/src/drawing/shapes/paint.ts +108 -0
  50. package/src/drawing/shapes/read.ts +89 -0
  51. package/src/drawing/shapes/text.ts +89 -0
  52. package/src/drawing/shapes/types.ts +13 -0
  53. package/src/drawing/sources.test.ts +27 -0
  54. package/src/drawing/sources.ts +43 -0
  55. package/src/drawing/types.ts +54 -0
  56. package/src/drawing/worksheet-connector.test.ts +135 -0
  57. package/src/drawing/worksheet-shape.test.ts +61 -0
  58. package/src/drawing/write/anchor.ts +17 -0
  59. package/src/drawing/write/axes.ts +23 -0
  60. package/src/drawing/write/chart.ts +56 -0
  61. package/src/drawing/write/drawing.ts +61 -0
  62. package/src/drawing/write/pictures.ts +68 -0
  63. package/src/drawing/write/series.ts +43 -0
  64. package/src/drawing/write/shapes.ts +113 -0
  65. package/src/drawing/write/text.ts +26 -0
  66. package/src/drawing/write/workbook.test.ts +199 -0
  67. package/src/drawing/write/workbook.ts +217 -0
  68. package/src/external-links/formulas.ts +21 -0
  69. package/src/external-links/read.test.ts +93 -0
  70. package/src/external-links/read.ts +104 -0
  71. package/src/external-links/types.ts +9 -0
  72. package/src/external-links/write.ts +120 -0
  73. package/src/image/excel.ts +122 -0
  74. package/src/image/native.ts +21 -0
  75. package/src/image/ownership.ts +77 -0
  76. package/src/image/parts.ts +45 -0
  77. package/src/image/raster.ts +25 -0
  78. package/src/image/read.test.ts +95 -0
  79. package/src/image/read.ts +66 -0
  80. package/src/image/relationships.ts +26 -0
  81. package/src/image/types.ts +48 -0
  82. package/src/image/wps.ts +43 -0
  83. package/src/image/write.test.ts +53 -0
  84. package/src/image/write.ts +118 -0
  85. package/src/index.ts +6 -0
  86. package/src/metadata/dynamic-array.ts +105 -0
  87. package/src/metadata/package.ts +75 -0
  88. package/src/metadata/types.ts +7 -0
  89. package/src/opc/archive.ts +26 -0
  90. package/src/opc/ownership.ts +40 -0
  91. package/src/opc/relationships.ts +98 -0
  92. package/src/opc/revision.ts +28 -0
  93. package/src/opc/shape.ts +23 -0
  94. package/src/opc/types.ts +13 -0
  95. package/src/opc/xml.test.ts +49 -0
  96. package/src/opc/xml.ts +128 -0
  97. package/src/optimization/blanks.ts +53 -0
  98. package/src/optimization/optimize.test.ts +117 -0
  99. package/src/optimization/optimize.ts +41 -0
  100. package/src/optimization/package.ts +65 -0
  101. package/src/optimization/rules.ts +46 -0
  102. package/src/optimization/styles.ts +76 -0
  103. package/src/optimization/types.ts +33 -0
  104. package/src/package/assembly.test.ts +117 -0
  105. package/src/package/calculation-metadata.test.ts +85 -0
  106. package/src/package/calculation-metadata.ts +88 -0
  107. package/src/package/checkboxes.ts +37 -0
  108. package/src/package/cleanup.test.ts +61 -0
  109. package/src/package/dashboard.test.ts +53 -0
  110. package/src/package/dashboard.ts +84 -0
  111. package/src/package/extensions.ts +16 -0
  112. package/src/package/merge-recipes.ts +84 -0
  113. package/src/package/names/conditional.ts +64 -0
  114. package/src/package/names/defined.test.ts +52 -0
  115. package/src/package/names/defined.ts +75 -0
  116. package/src/package/names/filter.ts +68 -0
  117. package/src/package/names/print-layout.ts +62 -0
  118. package/src/package/names/print.ts +62 -0
  119. package/src/package/new.ts +46 -0
  120. package/src/package/open/appearance.ts +46 -0
  121. package/src/package/open/directory.ts +61 -0
  122. package/src/package/open/restrictions.ts +27 -0
  123. package/src/package/open/snapshot.test.ts +48 -0
  124. package/src/package/open/snapshot.ts +34 -0
  125. package/src/package/open/source-write.ts +130 -0
  126. package/src/package/open/types.ts +73 -0
  127. package/src/package/open/worksheets.ts +149 -0
  128. package/src/package/positions.ts +40 -0
  129. package/src/package/read.ts +143 -0
  130. package/src/package/save/types.ts +57 -0
  131. package/src/package/save/worksheets.ts +126 -0
  132. package/src/package/selection-copy.test.ts +70 -0
  133. package/src/package/styles.ts +39 -0
  134. package/src/package/types.ts +52 -0
  135. package/src/package/workbook-views.ts +34 -0
  136. package/src/package/worksheets.test.ts +190 -0
  137. package/src/package/worksheets.ts +162 -0
  138. package/src/package/write.ts +175 -0
  139. package/src/pivot/cache/calculated.ts +34 -0
  140. package/src/pivot/cache/dates.ts +124 -0
  141. package/src/pivot/cache/groups.ts +11 -0
  142. package/src/pivot/cache/members.ts +99 -0
  143. package/src/pivot/cache/numbers.ts +63 -0
  144. package/src/pivot/cache/read.ts +131 -0
  145. package/src/pivot/cache/time.ts +20 -0
  146. package/src/pivot/cache/values.ts +43 -0
  147. package/src/pivot/cache/write.ts +117 -0
  148. package/src/pivot/definition/axes.ts +35 -0
  149. package/src/pivot/definition/dates.ts +87 -0
  150. package/src/pivot/definition/display.ts +86 -0
  151. package/src/pivot/definition/extension.ts +57 -0
  152. package/src/pivot/definition/field-settings/caption.ts +38 -0
  153. package/src/pivot/definition/field-settings/comparison.ts +47 -0
  154. package/src/pivot/definition/field-settings/field.ts +66 -0
  155. package/src/pivot/definition/field-settings/filters.ts +86 -0
  156. package/src/pivot/definition/field-settings/measure.ts +79 -0
  157. package/src/pivot/definition/field-settings/types.ts +19 -0
  158. package/src/pivot/definition/functions.ts +21 -0
  159. package/src/pivot/definition/items.ts +144 -0
  160. package/src/pivot/definition/members.ts +98 -0
  161. package/src/pivot/definition/numbers.ts +19 -0
  162. package/src/pivot/definition/presentation.ts +52 -0
  163. package/src/pivot/definition/read.ts +143 -0
  164. package/src/pivot/definition/report-layout.ts +39 -0
  165. package/src/pivot/definition/write.ts +157 -0
  166. package/src/pivot/package/calculated.test.ts +103 -0
  167. package/src/pivot/package/dates.test.ts +266 -0
  168. package/src/pivot/package/display.test.ts +133 -0
  169. package/src/pivot/package/field-settings.test.ts +59 -0
  170. package/src/pivot/package/layout.test.ts +148 -0
  171. package/src/pivot/package/measure-settings.test.ts +85 -0
  172. package/src/pivot/package/members.test.ts +167 -0
  173. package/src/pivot/package/numbers.test.ts +120 -0
  174. package/src/pivot/package/read.ts +93 -0
  175. package/src/pivot/package/roundtrip.test.ts +244 -0
  176. package/src/pivot/package/write.ts +103 -0
  177. package/src/pivot/types.ts +36 -0
  178. package/src/pivot/xml.ts +50 -0
  179. package/src/presentation.test.ts +186 -0
  180. package/src/roundtrip.test.ts +72 -0
  181. package/src/styles/checkbox/bags.ts +85 -0
  182. package/src/styles/checkbox/style.ts +45 -0
  183. package/src/styles/checkbox/types.ts +7 -0
  184. package/src/styles/color.ts +64 -0
  185. package/src/styles/differential-preview.ts +60 -0
  186. package/src/styles/differential.ts +119 -0
  187. package/src/styles/numbers.ts +9 -0
  188. package/src/styles/parts.ts +107 -0
  189. package/src/styles/read.ts +95 -0
  190. package/src/styles/reference.ts +14 -0
  191. package/src/styles/types.ts +9 -0
  192. package/src/styles/write.test.ts +88 -0
  193. package/src/styles/write.ts +162 -0
  194. package/src/table/conversion.test.ts +73 -0
  195. package/src/table/definition.ts +89 -0
  196. package/src/table/filter.ts +42 -0
  197. package/src/table/ownership.ts +112 -0
  198. package/src/table/read.test.ts +274 -0
  199. package/src/table/read.ts +117 -0
  200. package/src/table/remove.ts +55 -0
  201. package/src/table/sort.test.ts +79 -0
  202. package/src/table/styles/builtin.ts +40 -0
  203. package/src/table/styles/differential.ts +55 -0
  204. package/src/table/styles/preset-data.ts +17 -0
  205. package/src/table/styles/presets/dark.ts +104 -0
  206. package/src/table/styles/presets/light-grid.ts +68 -0
  207. package/src/table/styles/presets/light.ts +145 -0
  208. package/src/table/styles/presets/medium-edges.ts +131 -0
  209. package/src/table/styles/presets/medium.ts +131 -0
  210. package/src/table/styles/read.ts +70 -0
  211. package/src/table/styles/types.ts +27 -0
  212. package/src/table/totals.test.ts +77 -0
  213. package/src/table/totals.ts +79 -0
  214. package/src/table/types.ts +21 -0
  215. package/src/table/write.ts +189 -0
  216. package/src/types.ts +74 -0
  217. package/src/value/date.ts +21 -0
  218. package/src/worksheet/appearance.ts +55 -0
  219. package/src/worksheet/axis.test.ts +185 -0
  220. package/src/worksheet/axis.ts +131 -0
  221. package/src/worksheet/background/read.ts +41 -0
  222. package/src/worksheet/background/roundtrip.test.ts +77 -0
  223. package/src/worksheet/background/write.ts +96 -0
  224. package/src/worksheet/cell-shift.ts +44 -0
  225. package/src/worksheet/cells.ts +75 -0
  226. package/src/worksheet/checkbox/formats.ts +53 -0
  227. package/src/worksheet/checkbox/ranges.ts +112 -0
  228. package/src/worksheet/checkbox/write.test.ts +62 -0
  229. package/src/worksheet/conditional/color-scale.ts +61 -0
  230. package/src/worksheet/conditional/data-bar.ts +76 -0
  231. package/src/worksheet/conditional/extensions.ts +95 -0
  232. package/src/worksheet/conditional/icon-reference.ts +69 -0
  233. package/src/worksheet/conditional/icon-set.test.ts +60 -0
  234. package/src/worksheet/conditional/icon-set.ts +79 -0
  235. package/src/worksheet/conditional/preview.ts +44 -0
  236. package/src/worksheet/conditional/read.ts +185 -0
  237. package/src/worksheet/conditional/text.test.ts +71 -0
  238. package/src/worksheet/conditional/text.ts +122 -0
  239. package/src/worksheet/conditional/threshold.ts +47 -0
  240. package/src/worksheet/conditional/types.ts +20 -0
  241. package/src/worksheet/conditional/write-bar.ts +66 -0
  242. package/src/worksheet/conditional/write.test.ts +218 -0
  243. package/src/worksheet/conditional/write.ts +103 -0
  244. package/src/worksheet/copied-axis.ts +70 -0
  245. package/src/worksheet/data/rows.ts +59 -0
  246. package/src/worksheet/data/source.test.ts +68 -0
  247. package/src/worksheet/data/source.ts +31 -0
  248. package/src/worksheet/data/types.ts +9 -0
  249. package/src/worksheet/data.test.ts +314 -0
  250. package/src/worksheet/dimensions/columns.ts +87 -0
  251. package/src/worksheet/dimensions/write.test.ts +110 -0
  252. package/src/worksheet/dimensions/write.ts +36 -0
  253. package/src/worksheet/filters/advanced.test.ts +57 -0
  254. package/src/worksheet/filters/color.ts +105 -0
  255. package/src/worksheet/filters/icon.test.ts +83 -0
  256. package/src/worksheet/filters/icon.ts +39 -0
  257. package/src/worksheet/filters/read.ts +114 -0
  258. package/src/worksheet/filters/relative-dates.ts +47 -0
  259. package/src/worksheet/filters/restore-icons.ts +33 -0
  260. package/src/worksheet/filters/restore.ts +169 -0
  261. package/src/worksheet/filters/rules.ts +23 -0
  262. package/src/worksheet/filters/types.ts +23 -0
  263. package/src/worksheet/filters/visibility.ts +188 -0
  264. package/src/worksheet/filters/write.ts +121 -0
  265. package/src/worksheet/formula/cache.ts +29 -0
  266. package/src/worksheet/formula/external-results.test.ts +39 -0
  267. package/src/worksheet/formula/functions.ts +29 -0
  268. package/src/worksheet/formula/prefix.ts +27 -0
  269. package/src/worksheet/formula/shared/read.test.ts +121 -0
  270. package/src/worksheet/formula/shared/read.ts +94 -0
  271. package/src/worksheet/formula/shared/references.ts +100 -0
  272. package/src/worksheet/formula/shared/types.ts +21 -0
  273. package/src/worksheet/formula/spill-read.ts +54 -0
  274. package/src/worksheet/formula/spill-write.ts +32 -0
  275. package/src/worksheet/formula/spill.test.ts +101 -0
  276. package/src/worksheet/formula/write.test.ts +26 -0
  277. package/src/worksheet/hyperlinks/location.ts +59 -0
  278. package/src/worksheet/hyperlinks/model.ts +22 -0
  279. package/src/worksheet/hyperlinks/read.ts +70 -0
  280. package/src/worksheet/hyperlinks/types.ts +21 -0
  281. package/src/worksheet/hyperlinks/write.test.ts +203 -0
  282. package/src/worksheet/hyperlinks/write.ts +51 -0
  283. package/src/worksheet/merge.test.ts +58 -0
  284. package/src/worksheet/merge.ts +61 -0
  285. package/src/worksheet/outline/columns.ts +46 -0
  286. package/src/worksheet/outline/metadata.ts +68 -0
  287. package/src/worksheet/outline/native.ts +81 -0
  288. package/src/worksheet/outline/read.ts +50 -0
  289. package/src/worksheet/outline/roundtrip.test.ts +73 -0
  290. package/src/worksheet/outline/types.ts +37 -0
  291. package/src/worksheet/outline/write.ts +110 -0
  292. package/src/worksheet/positions.test.ts +46 -0
  293. package/src/worksheet/positions.ts +48 -0
  294. package/src/worksheet/print/breaks.ts +72 -0
  295. package/src/worksheet/print/elements.ts +16 -0
  296. package/src/worksheet/print/page-text.ts +139 -0
  297. package/src/worksheet/print/setup.test.ts +141 -0
  298. package/src/worksheet/print/setup.ts +116 -0
  299. package/src/worksheet/progress/read.ts +73 -0
  300. package/src/worksheet/progress/solid.ts +26 -0
  301. package/src/worksheet/progress/types.ts +11 -0
  302. package/src/worksheet/progress/write.test.ts +63 -0
  303. package/src/worksheet/progress/write.ts +46 -0
  304. package/src/worksheet/read.ts +197 -0
  305. package/src/worksheet/rich-text.test.ts +41 -0
  306. package/src/worksheet/rich-text.ts +76 -0
  307. package/src/worksheet/sort/read.ts +115 -0
  308. package/src/worksheet/sort/relocate.ts +62 -0
  309. package/src/worksheet/sort/roundtrip.test.ts +116 -0
  310. package/src/worksheet/sort/types.ts +11 -0
  311. package/src/worksheet/sort/write.ts +77 -0
  312. package/src/worksheet/template.ts +9 -0
  313. package/src/worksheet/text.ts +33 -0
  314. package/src/worksheet/validation/extended.ts +36 -0
  315. package/src/worksheet/validation/image.ts +7 -0
  316. package/src/worksheet/validation/list-options/portable.ts +90 -0
  317. package/src/worksheet/validation/list-options/types.ts +14 -0
  318. package/src/worksheet/validation/list-options/wps.ts +51 -0
  319. package/src/worksheet/validation/read.ts +162 -0
  320. package/src/worksheet/validation/text.ts +13 -0
  321. package/src/worksheet/validation/write.test.ts +259 -0
  322. package/src/worksheet/validation/write.ts +99 -0
  323. package/src/worksheet/view/coordinates.ts +39 -0
  324. package/src/worksheet/view/named/read.ts +116 -0
  325. package/src/worksheet/view/named/roundtrip.test.ts +136 -0
  326. package/src/worksheet/view/named/sort.ts +57 -0
  327. package/src/worksheet/view/named/types.ts +15 -0
  328. package/src/worksheet/view/named/write.ts +107 -0
  329. package/src/worksheet/view/named/xml.ts +33 -0
  330. package/src/worksheet/view/panes.ts +75 -0
  331. package/src/worksheet/view/read.ts +61 -0
  332. package/src/worksheet/view/relocate.ts +57 -0
  333. package/src/worksheet/view/write.test.ts +91 -0
  334. package/src/worksheet/view/write.ts +57 -0
  335. package/src/worksheet/write.ts +86 -0
  336. package/README.md +0 -3
@@ -0,0 +1,79 @@
1
+ import { strFromU8, strToU8, unzipSync, zipSync } from "fflate";
2
+ import { expect, it } from "vitest";
3
+ import { openWorkbook, parseWorkbookRange, type WorkbookSnapshot } from "@quirekit/workbook";
4
+ import { createXlsx, openXlsx } from "../index";
5
+
6
+ const sheetId = "sales";
7
+ const tablePath = "xl/tables/table1.xml";
8
+ const sheetPath = "xl/worksheets/sheet1.xml";
9
+ const range = parseWorkbookRange(sheetId, "A1:C6");
10
+ const body = parseWorkbookRange(sheetId, "A2:C5");
11
+ const keys = [{ column: "B", direction: "asc" }] as const;
12
+ const filterKeys = [{ column: "A", source: "font", color: "#A23050", position: "first" }] as const;
13
+ const seed: WorkbookSnapshot = { id: "sales", name: "Sales", version: 1, revision: 0, sheets: [{ id: sheetId, name: "Sales",
14
+ cells: [["Item", "Net", "Group"], ["Beta", 50, "East"], ["Hidden", 200, "West"], ["Gamma", 75, "East"],
15
+ ["Alpha", 125, "East"], ["Total", 450, ""]].flatMap((line, row) => line.map((value, column) => ({ row, column, input: { kind: "value", value } }))),
16
+ formats: [{ row: 4, column: 0, format: { color: "#A23050" } }]
17
+ }], structuredTables: [{ id: "ledger", name: "Ledger", columns: ["Item", "Net", "Group"], range, header: true, totals: true, showFilter: true,
18
+ filter: { range: parseWorkbookRange(sheetId, "A1:C5"), columns: [{ column: 2, rule: { kind: "values", values: ["East"], blanks: false } }], hiddenRows: [2] },
19
+ sorts: { table: { range: body, keys, caseSensitive: true }, filter: { range: body, keys: filterKeys } } }] };
20
+
21
+ /** @param modify - XML transformation for a producer variation. @returns Bytes with the other package parts preserved. */
22
+ function tableFile(modify: (xml: string) => string): Uint8Array {
23
+ const parts = unzipSync(createXlsx(seed));
24
+ parts[tablePath] = strToU8(modify(strFromU8(parts[tablePath]!)));
25
+ return zipSync(parts);
26
+ }
27
+
28
+ it("keeps direct WPS and nested font criteria as distinct native owners through a filter rewrite", async () => {
29
+ const bytes = tableFile(xml => xml.replace('<autoFilter ref="A1:C5">', '<autoFilter ref="A1:C5"'
30
+ + ' xmlns:et="http://www.wps.cn/officeDocument/2017/etCustomData" et:filterBottomFollowUsedRange="0">')
31
+ .replace('<sortCondition ref="B2:B5"/>', '<sortCondition ref="B1"/>')
32
+ .replace('<tableColumn id="2"', '<tableColumn id="12"'));
33
+ const file = openXlsx("WPS table", bytes);
34
+ expect(file.restrictions).toEqual([]);
35
+ const table = file.snapshot.structuredTables![0]!;
36
+ const id = table.range.sheetId;
37
+ const data = parseWorkbookRange(id, "A2:C5");
38
+ expect(table.sorts).toEqual({ table: { range: data, keys, caseSensitive: true }, filter: { range: data, keys: filterKeys } });
39
+ expect(file.write(file.snapshot)).toEqual(bytes);
40
+ const book = await openWorkbook(file.snapshot, { appearance: file.appearance });
41
+ /** @param name - Native action. @param target - Exact command scope. @param params - Registry arguments. @returns Committed change. */
42
+ async function run(name: string, target: typeof range, params: unknown) {
43
+ return book.commit(book.prepare({ operationId: String(book.revision) + name, baseRevision: book.revision, commands: [{ name, target, params }] }).id);
44
+ }
45
+ try {
46
+ const criteriaOnly = await run("sortRows", data, { keys, header: false });
47
+ expect(criteriaOnly.changedCells).toBe(0);
48
+ const metadata = unzipSync(file.write(book.snapshot()));
49
+ expect(metadata[sheetPath]).toEqual(unzipSync(bytes)[sheetPath]);
50
+ expect(strFromU8(metadata[tablePath]!)).toContain('<sortCondition ref="B2:B5"/>');
51
+ await book.undo("undo-sort-metadata");
52
+ expect(file.write(book.snapshot())).toEqual(bytes);
53
+
54
+ await run("reapplyStructuredTableSort", data, { tableId: table.id, scope: "filter" });
55
+ expect([...book.readInputCells(parseWorkbookRange(id, "B2:B6"))].map(({ input }) => input)).toEqual(
56
+ [125, 200, 50, 75, 450].map(value => ({ kind: "value", value })));
57
+ expect(book.filteredRows(id)).toEqual([2]);
58
+ await run("clearStructuredTableFilter", parseWorkbookRange(id, "A1:C5"), { id: table.id });
59
+ const output = file.write(book.snapshot());
60
+ const xml = strFromU8(unzipSync(output)[tablePath]!);
61
+ expect(xml).toMatch(/<autoFilter ref="A1:C5"><sortState ref="A2:C5"><sortCondition ref="A2:A5" sortBy="fontColor" dxfId="\d+"\/><\/sortState><\/autoFilter><sortState ref="A2:C5" caseSensitive="1"><sortCondition ref="B2:B5"\/><\/sortState><tableColumns/u);
62
+ expect(xml).toContain('<tableColumn id="12" name="Net"/>');
63
+ expect(xml).toContain('name="TableStyleMedium2"');
64
+ const reopened = openXlsx("Sorted", output);
65
+ expect(reopened.restrictions).toEqual([]);
66
+ expect(reopened.snapshot.structuredTables?.[0]?.sorts).toEqual(table.sorts);
67
+ expect(reopened.snapshot.structuredTables?.[0]?.filter).toBeUndefined();
68
+ } finally { await book.close(); }
69
+ });
70
+
71
+ it("preserves files with an unsupported native table condition or an out-of-body key", () => {
72
+ for (const replace of ['ref="B2:B5" customList="100,,200"', 'ref="B6"']) {
73
+ const bytes = tableFile(xml => xml.replace('ref="B2:B5"', replace));
74
+ const file = openXlsx("Unmodeled table sort", bytes);
75
+ expect(file.restrictions).toContain("结构化表");
76
+ expect(file.snapshot.structuredTables).toBeUndefined();
77
+ expect(file.write(file.snapshot)).toEqual(bytes);
78
+ }
79
+ });
@@ -0,0 +1,40 @@
1
+ import { workbookBorderSides, type WorkbookCellFormat, type WorkbookTableStyleElement, type WorkbookTableStyleElements, type WorkbookTableStyleRegion } from "@quirekit/workbook";
2
+ import { tintXlsxColor } from "../../styles/color";
3
+ import { xlsxPresetTableStyles } from "./preset-data";
4
+ import type { XlsxTableThemeBorder, XlsxTableThemeColor } from "./types";
5
+
6
+ /** @param theme - Source workbook colors.
7
+ * @returns A resolver for all standardized ordinary-table styles. */
8
+ export function createXlsxBuiltinTableStyles(theme: readonly string[]) {
9
+ /** @param color - Standard preset theme references. @returns Source-resolved sRGB. */
10
+ function resolveColor([index, tint]: XlsxTableThemeColor): string {
11
+ return tintXlsxColor(theme[index]!, tint ?? 0);
12
+ }
13
+ /** @param edge - Optional preset stroke. @returns Appearance of the edge in this workbook. */
14
+ function resolveBorder(edge: XlsxTableThemeBorder | undefined) {
15
+ return edge && { stroke: edge[0], color: resolveColor([edge[1], edge[2]]) };
16
+ }
17
+ const available = new Map(Object.entries(xlsxPresetTableStyles).map(([name, style]) => [name.toLowerCase(), style]));
18
+ const resolved = new Map<string, WorkbookTableStyleElements>();
19
+ /** @param name - Native style name. @returns Style with source colors resolved, when standardized. */
20
+ return (name: string): WorkbookTableStyleElements | undefined => {
21
+ const prior = resolved.get(name);
22
+ if (prior) return prior;
23
+ const preset = available.get(name);
24
+ if (!preset) return;
25
+ const elements: Partial<Record<WorkbookTableStyleRegion, WorkbookTableStyleElement>> = {};
26
+ for (const type of Object.keys(preset) as WorkbookTableStyleRegion[]) {
27
+ const { bold, color, background, size, borders } = preset[type]!;
28
+ const outlines = borders && Object.fromEntries(workbookBorderSides.flatMap(side => {
29
+ const border = resolveBorder(borders[side]);
30
+ return border ? [[side, border]] : [];
31
+ }));
32
+ const format: WorkbookCellFormat = { ...(bold !== undefined && { bold }), ...(color && { color: resolveColor(color) }),
33
+ ...(background && { background: resolveColor(background) }), ...(outlines && { borders: outlines }) };
34
+ const horizontal = resolveBorder(borders?.horizontal), vertical = resolveBorder(borders?.vertical);
35
+ elements[type] = { format, ...(size && { size }), ...(horizontal && { horizontal }), ...(vertical && { vertical }) };
36
+ }
37
+ resolved.set(name, elements);
38
+ return elements;
39
+ };
40
+ }
@@ -0,0 +1,55 @@
1
+ import type { Element } from "@xmldom/xmldom";
2
+ import { workbookBorderSides, type WorkbookBorderSide, type WorkbookCellBorder, type WorkbookCellFormat,
3
+ type WorkbookTableStyleElement } from "@quirekit/workbook";
4
+ import { child, readIndex, readSize } from "../../opc/xml";
5
+ import type { styleColorReader } from "../../styles/color";
6
+ import { readWorkbookBorderStroke } from "../../styles/read";
7
+ import { builtinNumberFormats } from "../../styles/numbers";
8
+
9
+ /** @param node - Differential font switch. @returns Explicit toggle if the value is understood. */
10
+ function enabled(node: Element | undefined): boolean | undefined {
11
+ if (!node) return;
12
+ const value = node.getAttribute("val");
13
+ if (!value || ["1", "true", "single"].includes(value)) return true;
14
+ if (["0", "false", "none"].includes(value)) return false;
15
+ }
16
+
17
+ /** @param node - Differential row or column edge. @param color - Source workbook palette.
18
+ * @returns A stroke, explicit clear, or no override. */
19
+ function readEdge(node: Element | undefined, color: ReturnType<typeof styleColorReader>): WorkbookCellBorder | null | undefined {
20
+ if (!node) return;
21
+ const style = node.getAttribute("style");
22
+ if (!style || style === "none") return null;
23
+ const stroke = readWorkbookBorderStroke(node);
24
+ const ink = child(node, "color");
25
+ const resolved = ink ? color(ink) : "#000000";
26
+ if (stroke && resolved) return { stroke, color: resolved };
27
+ }
28
+
29
+ /** @param node - Source differential formatting record. @param color - Source palette.
30
+ * @returns Display attributes for an ordinary-table style element. */
31
+ export function readXlsxTableDifferential(node: Element, color: ReturnType<typeof styleColorReader>): WorkbookTableStyleElement {
32
+ const font = child(node, "font"), fill = child(node, "fill"), border = child(node, "border"), numFmt = child(node, "numFmt");
33
+ const pattern = fill && child(fill, "patternFill"), patternType = pattern?.getAttribute("patternType");
34
+ const fillColor = pattern && (patternType === "solid" ? child(pattern, "fgColor") ?? child(pattern, "bgColor")
35
+ : !patternType ? child(pattern, "bgColor") : undefined);
36
+ const borders: Partial<Record<WorkbookBorderSide, WorkbookCellBorder | null>> = {};
37
+ if (border) for (const side of workbookBorderSides) {
38
+ const edge = readEdge(child(border, side), color);
39
+ if (edge !== undefined) borders[side] = edge;
40
+ }
41
+ const properties = {
42
+ fontFamily: font && child(font, "name")?.getAttribute("val") || undefined,
43
+ fontSize: font && readSize(child(font, "sz"), "val"),
44
+ bold: enabled(font && child(font, "b")), italic: enabled(font && child(font, "i")),
45
+ underline: enabled(font && child(font, "u")), strike: enabled(font && child(font, "strike")),
46
+ color: color(font && child(font, "color")), background: color(fillColor),
47
+ numberFormat: numFmt && (numFmt.getAttribute("formatCode") || builtinNumberFormats.get(readIndex(numFmt, "numFmtId") ?? -1))
48
+ } satisfies WorkbookCellFormat;
49
+ const format: WorkbookCellFormat = {
50
+ ...Object.fromEntries(Object.entries(properties).filter(([, value]) => value !== undefined)),
51
+ ...(Object.keys(borders).length && { borders })
52
+ };
53
+ return { format, horizontal: readEdge(border && child(border, "horizontal"), color),
54
+ vertical: readEdge(border && child(border, "vertical"), color) };
55
+ }
@@ -0,0 +1,17 @@
1
+ import { xlsxDarkTableStyles } from "./presets/dark";
2
+ import { xlsxLightTableStyles } from "./presets/light";
3
+ import { xlsxLightGridTableStyles } from "./presets/light-grid";
4
+ import { xlsxMediumTableStyles } from "./presets/medium";
5
+ import { xlsxMediumEdgeTableStyles } from "./presets/medium-edges";
6
+ import type { XlsxPresetTableStyle } from "./types";
7
+
8
+ /** Standard ordinary-table recipes, ECMA-376 Part 1 (2016), Annex G, presetTableStyles.xml. */
9
+ // The source attachment numbers its preset differentials from 1.
10
+ // Source XML SHA-256: 74c6cf73d551bb2bd33a51690d4922095260b6647b2a38fcbc0d6da6c6275d7e
11
+ export const xlsxPresetTableStyles: Readonly<Record<string, XlsxPresetTableStyle>> = {
12
+ ...xlsxDarkTableStyles,
13
+ ...xlsxLightTableStyles,
14
+ ...xlsxLightGridTableStyles,
15
+ ...xlsxMediumTableStyles,
16
+ ...xlsxMediumEdgeTableStyles
17
+ };
@@ -0,0 +1,104 @@
1
+ import type { XlsxPresetTableStyle } from "../types";
2
+
3
+ /** Dark styles with filled headers, totals and column accents. */
4
+ export const xlsxDarkTableStyles: Readonly<Record<string, XlsxPresetTableStyle>> = {
5
+ TableStyleDark1: {
6
+ wholeTable: {color: [0], background: [1, 0.4499954222235786]},
7
+ headerRow: {bold: true, color: [0], background: [1], borders: {bottom: ["medium", 0]}},
8
+ totalRow: {bold: true, color: [0], background: [1, 0.1499984740745262], borders: {top: ["medium", 0]}},
9
+ firstColumn: {bold: true, color: [0], background: [1, 0.249977111117893], borders: {right: ["medium", 0]}},
10
+ lastColumn: {bold: true, color: [0], background: [1, 0.249977111117893], borders: {left: ["medium", 0]}},
11
+ firstRowStripe: {background: [1, 0.249977111117893]},
12
+ firstColumnStripe: {background: [1, 0.249977111117893]},
13
+ },
14
+ TableStyleDark2: {
15
+ wholeTable: {color: [0], background: [4]},
16
+ headerRow: {bold: true, color: [0], background: [1], borders: {bottom: ["medium", 0]}},
17
+ totalRow: {bold: true, color: [0], background: [4, -0.499984740745262], borders: {top: ["medium", 0]}},
18
+ firstColumn: {bold: true, color: [0], background: [4, -0.249977111117893], borders: {right: ["medium", 0]}},
19
+ lastColumn: {bold: true, color: [0], background: [4, -0.249977111117893], borders: {left: ["medium", 0]}},
20
+ firstRowStripe: {background: [4, -0.249977111117893]},
21
+ firstColumnStripe: {background: [4, -0.249977111117893]},
22
+ },
23
+ TableStyleDark3: {
24
+ wholeTable: {color: [0], background: [5]},
25
+ headerRow: {bold: true, color: [0], background: [1], borders: {bottom: ["medium", 0]}},
26
+ totalRow: {bold: true, color: [0], background: [5, -0.499984740745262], borders: {top: ["medium", 0]}},
27
+ firstColumn: {bold: true, color: [0], background: [5, -0.249977111117893], borders: {right: ["medium", 0]}},
28
+ lastColumn: {bold: true, color: [0], background: [5, -0.249977111117893], borders: {left: ["medium", 0]}},
29
+ firstRowStripe: {background: [5, -0.249977111117893]},
30
+ firstColumnStripe: {background: [5, -0.249977111117893]},
31
+ },
32
+ TableStyleDark4: {
33
+ wholeTable: {color: [0], background: [6]},
34
+ headerRow: {bold: true, color: [0], background: [1], borders: {bottom: ["medium", 0]}},
35
+ totalRow: {bold: true, color: [0], background: [6, -0.499984740745262], borders: {top: ["medium", 0]}},
36
+ firstColumn: {bold: true, color: [0], background: [6, -0.249977111117893], borders: {right: ["medium", 0]}},
37
+ lastColumn: {bold: true, color: [0], background: [6, -0.249977111117893], borders: {left: ["medium", 0]}},
38
+ firstRowStripe: {background: [6, -0.249977111117893]},
39
+ firstColumnStripe: {background: [6, -0.249977111117893]},
40
+ },
41
+ TableStyleDark5: {
42
+ wholeTable: {color: [0], background: [7]},
43
+ headerRow: {bold: true, color: [0], background: [1], borders: {bottom: ["medium", 0]}},
44
+ totalRow: {bold: true, color: [0], background: [7, -0.499984740745262], borders: {top: ["medium", 0]}},
45
+ firstColumn: {bold: true, color: [0], background: [7, -0.249977111117893], borders: {right: ["medium", 0]}},
46
+ lastColumn: {bold: true, color: [0], background: [7, -0.249977111117893], borders: {left: ["medium", 0]}},
47
+ firstRowStripe: {background: [7, -0.249977111117893]},
48
+ firstColumnStripe: {background: [7, -0.249977111117893]},
49
+ },
50
+ TableStyleDark6: {
51
+ wholeTable: {color: [0], background: [8]},
52
+ headerRow: {bold: true, color: [0], background: [1], borders: {bottom: ["medium", 0]}},
53
+ totalRow: {bold: true, color: [0], background: [8, -0.499984740745262], borders: {top: ["medium", 0]}},
54
+ firstColumn: {bold: true, color: [0], background: [8, -0.249977111117893], borders: {right: ["medium", 0]}},
55
+ lastColumn: {bold: true, color: [0], background: [8, -0.249977111117893], borders: {left: ["medium", 0]}},
56
+ firstRowStripe: {background: [8, -0.249977111117893]},
57
+ firstColumnStripe: {background: [8, -0.249977111117893]},
58
+ },
59
+ TableStyleDark7: {
60
+ wholeTable: {color: [0], background: [9]},
61
+ headerRow: {bold: true, color: [0], background: [1], borders: {bottom: ["medium", 0]}},
62
+ totalRow: {bold: true, color: [0], background: [9, -0.499984740745262], borders: {top: ["medium", 0]}},
63
+ firstColumn: {bold: true, color: [0], background: [9, -0.249977111117893], borders: {right: ["medium", 0]}},
64
+ lastColumn: {bold: true, color: [0], background: [9, -0.249977111117893], borders: {left: ["medium", 0]}},
65
+ firstRowStripe: {background: [9, -0.249977111117893]},
66
+ firstColumnStripe: {background: [9, -0.249977111117893]},
67
+ },
68
+ TableStyleDark8: {
69
+ wholeTable: {background: [0, -0.1499984740745262]},
70
+ headerRow: {color: [0], background: [1]},
71
+ totalRow: {bold: true, color: [1], borders: {top: ["double", 1]}},
72
+ firstColumn: {bold: true, color: [1]},
73
+ lastColumn: {bold: true, color: [1]},
74
+ firstRowStripe: {background: [0, -0.3499862666707358]},
75
+ firstColumnStripe: {background: [0, -0.3499862666707358]},
76
+ },
77
+ TableStyleDark9: {
78
+ wholeTable: {background: [4, 0.7999816888943144]},
79
+ headerRow: {color: [0], background: [5]},
80
+ totalRow: {bold: true, color: [1], borders: {top: ["double", 1]}},
81
+ firstColumn: {bold: true, color: [1]},
82
+ lastColumn: {bold: true, color: [1]},
83
+ firstRowStripe: {background: [4, 0.5999938962981048]},
84
+ firstColumnStripe: {background: [4, 0.5999938962981048]},
85
+ },
86
+ TableStyleDark10: {
87
+ wholeTable: {background: [6, 0.7999816888943144]},
88
+ headerRow: {color: [0], background: [7]},
89
+ totalRow: {bold: true, color: [1], borders: {top: ["double", 1]}},
90
+ firstColumn: {bold: true, color: [1]},
91
+ lastColumn: {bold: true, color: [1]},
92
+ firstRowStripe: {background: [6, 0.5999938962981048]},
93
+ firstColumnStripe: {background: [6, 0.5999938962981048]},
94
+ },
95
+ TableStyleDark11: {
96
+ wholeTable: {background: [8, 0.7999816888943144]},
97
+ headerRow: {color: [0], background: [9]},
98
+ totalRow: {bold: true, color: [1], borders: {top: ["double", 1]}},
99
+ firstColumn: {bold: true, color: [1]},
100
+ lastColumn: {bold: true, color: [1]},
101
+ firstRowStripe: {background: [8, 0.5999938962981048]},
102
+ firstColumnStripe: {background: [8, 0.5999938962981048]},
103
+ },
104
+ };
@@ -0,0 +1,68 @@
1
+ import type { XlsxPresetTableStyle } from "../types";
2
+
3
+ /** Light styles with horizontal and vertical grid borders. */
4
+ export const xlsxLightGridTableStyles: Readonly<Record<string, XlsxPresetTableStyle>> = {
5
+ TableStyleLight15: {
6
+ wholeTable: {color: [1], borders: {left: ["thin", 1], right: ["thin", 1], top: ["thin", 1], bottom: ["thin", 1], vertical: ["thin", 1], horizontal: ["thin", 1]}},
7
+ headerRow: {bold: true, color: [1], borders: {bottom: ["medium", 1]}},
8
+ totalRow: {bold: true, color: [1], borders: {top: ["double", 1]}},
9
+ firstColumn: {bold: true, color: [1]},
10
+ lastColumn: {bold: true, color: [1]},
11
+ firstRowStripe: {background: [0, -0.1499984740745262]},
12
+ firstColumnStripe: {background: [0, -0.1499984740745262]},
13
+ },
14
+ TableStyleLight16: {
15
+ wholeTable: {color: [1], borders: {left: ["thin", 4], right: ["thin", 4], top: ["thin", 4], bottom: ["thin", 4], vertical: ["thin", 4], horizontal: ["thin", 4]}},
16
+ headerRow: {bold: true, color: [1], borders: {bottom: ["medium", 4]}},
17
+ totalRow: {bold: true, color: [1], borders: {top: ["double", 4]}},
18
+ firstColumn: {bold: true, color: [1]},
19
+ lastColumn: {bold: true, color: [1]},
20
+ firstRowStripe: {background: [4, 0.7999816888943144]},
21
+ firstColumnStripe: {background: [4, 0.7999816888943144]},
22
+ },
23
+ TableStyleLight17: {
24
+ wholeTable: {color: [1], borders: {left: ["thin", 5], right: ["thin", 5], top: ["thin", 5], bottom: ["thin", 5], vertical: ["thin", 5], horizontal: ["thin", 5]}},
25
+ headerRow: {bold: true, color: [1], borders: {bottom: ["medium", 5]}},
26
+ totalRow: {bold: true, color: [1], borders: {top: ["double", 5]}},
27
+ firstColumn: {bold: true, color: [1]},
28
+ lastColumn: {bold: true, color: [1]},
29
+ firstRowStripe: {background: [5, 0.7999816888943144]},
30
+ firstColumnStripe: {background: [5, 0.7999816888943144]},
31
+ },
32
+ TableStyleLight18: {
33
+ wholeTable: {color: [1], borders: {left: ["thin", 6], right: ["thin", 6], top: ["thin", 6], bottom: ["thin", 6], vertical: ["thin", 6], horizontal: ["thin", 6]}},
34
+ headerRow: {bold: true, color: [1], borders: {bottom: ["medium", 6]}},
35
+ totalRow: {bold: true, color: [1], borders: {top: ["double", 6]}},
36
+ firstColumn: {bold: true, color: [1]},
37
+ lastColumn: {bold: true, color: [1]},
38
+ firstRowStripe: {background: [6, 0.7999816888943144]},
39
+ firstColumnStripe: {background: [6, 0.7999816888943144]},
40
+ },
41
+ TableStyleLight19: {
42
+ wholeTable: {color: [1], borders: {left: ["thin", 7], right: ["thin", 7], top: ["thin", 7], bottom: ["thin", 7], vertical: ["thin", 7], horizontal: ["thin", 7]}},
43
+ headerRow: {bold: true, color: [1], borders: {bottom: ["medium", 7]}},
44
+ totalRow: {bold: true, color: [1], borders: {top: ["double", 7]}},
45
+ firstColumn: {bold: true, color: [1]},
46
+ lastColumn: {bold: true, color: [1]},
47
+ firstRowStripe: {background: [7, 0.7999816888943144]},
48
+ firstColumnStripe: {background: [7, 0.7999816888943144]},
49
+ },
50
+ TableStyleLight20: {
51
+ wholeTable: {color: [1], borders: {left: ["thin", 8], right: ["thin", 8], top: ["thin", 8], bottom: ["thin", 8], vertical: ["thin", 8], horizontal: ["thin", 8]}},
52
+ headerRow: {bold: true, color: [1], borders: {bottom: ["medium", 8]}},
53
+ totalRow: {bold: true, color: [1], borders: {top: ["double", 8]}},
54
+ firstColumn: {bold: true, color: [1]},
55
+ lastColumn: {bold: true, color: [1]},
56
+ firstRowStripe: {background: [8, 0.7999816888943144]},
57
+ firstColumnStripe: {background: [8, 0.7999816888943144]},
58
+ },
59
+ TableStyleLight21: {
60
+ wholeTable: {color: [1], borders: {left: ["thin", 9], right: ["thin", 9], top: ["thin", 9], bottom: ["thin", 9], vertical: ["thin", 9], horizontal: ["thin", 9]}},
61
+ headerRow: {bold: true, color: [1], borders: {bottom: ["medium", 9]}},
62
+ totalRow: {bold: true, color: [1], borders: {top: ["double", 9]}},
63
+ firstColumn: {bold: true, color: [1]},
64
+ lastColumn: {bold: true, color: [1]},
65
+ firstRowStripe: {background: [9, 0.7999816888943144]},
66
+ firstColumnStripe: {background: [9, 0.7999816888943144]},
67
+ },
68
+ };
@@ -0,0 +1,145 @@
1
+ import type { XlsxPresetTableStyle } from "../types";
2
+
3
+ /** Light styles with outside and stripe borders. */
4
+ export const xlsxLightTableStyles: Readonly<Record<string, XlsxPresetTableStyle>> = {
5
+ TableStyleLight1: {
6
+ wholeTable: {color: [1], borders: {top: ["thin", 1], bottom: ["thin", 1]}},
7
+ headerRow: {bold: true, color: [1], borders: {bottom: ["thin", 1]}},
8
+ totalRow: {bold: true, color: [1], borders: {top: ["thin", 1]}},
9
+ firstColumn: {bold: true, color: [1]},
10
+ lastColumn: {bold: true, color: [1]},
11
+ firstRowStripe: {background: [0, -0.1499984740745262]},
12
+ firstColumnStripe: {background: [0, -0.1499984740745262]},
13
+ },
14
+ TableStyleLight2: {
15
+ wholeTable: {color: [4, -0.249977111117893], borders: {top: ["thin", 4], bottom: ["thin", 4]}},
16
+ headerRow: {bold: true, color: [4, -0.249977111117893], borders: {bottom: ["thin", 4]}},
17
+ totalRow: {bold: true, color: [4, -0.249977111117893], borders: {top: ["thin", 4]}},
18
+ firstColumn: {bold: true, color: [4, -0.249977111117893]},
19
+ lastColumn: {bold: true, color: [4, -0.249977111117893]},
20
+ firstRowStripe: {background: [4, 0.7999816888943144]},
21
+ firstColumnStripe: {background: [4, 0.7999816888943144]},
22
+ },
23
+ TableStyleLight3: {
24
+ wholeTable: {color: [5, -0.249977111117893], borders: {top: ["thin", 5], bottom: ["thin", 5]}},
25
+ headerRow: {bold: true, color: [5, -0.249977111117893], borders: {bottom: ["thin", 5]}},
26
+ totalRow: {bold: true, color: [5, -0.249977111117893], borders: {top: ["thin", 5]}},
27
+ firstColumn: {bold: true, color: [5, -0.249977111117893]},
28
+ lastColumn: {bold: true, color: [5, -0.249977111117893]},
29
+ firstRowStripe: {background: [5, 0.7999816888943144]},
30
+ firstColumnStripe: {background: [5, 0.7999816888943144]},
31
+ },
32
+ TableStyleLight4: {
33
+ wholeTable: {color: [6, -0.249977111117893], borders: {top: ["thin", 6], bottom: ["thin", 6]}},
34
+ headerRow: {bold: true, color: [6, -0.249977111117893], borders: {bottom: ["thin", 6]}},
35
+ totalRow: {bold: true, color: [6, -0.249977111117893], borders: {top: ["thin", 6]}},
36
+ firstColumn: {bold: true, color: [6, -0.249977111117893]},
37
+ lastColumn: {bold: true, color: [6, -0.249977111117893]},
38
+ firstRowStripe: {background: [6, 0.7999816888943144]},
39
+ firstColumnStripe: {background: [6, 0.7999816888943144]},
40
+ },
41
+ TableStyleLight5: {
42
+ wholeTable: {color: [7, -0.249977111117893], borders: {top: ["thin", 7], bottom: ["thin", 7]}},
43
+ headerRow: {bold: true, color: [7, -0.249977111117893], borders: {bottom: ["thin", 7]}},
44
+ totalRow: {bold: true, color: [7, -0.249977111117893], borders: {top: ["thin", 7]}},
45
+ firstColumn: {bold: true, color: [7, -0.249977111117893]},
46
+ lastColumn: {bold: true, color: [7, -0.249977111117893]},
47
+ firstRowStripe: {background: [7, 0.7999816888943144]},
48
+ firstColumnStripe: {background: [7, 0.7999816888943144]},
49
+ },
50
+ TableStyleLight6: {
51
+ wholeTable: {color: [8, -0.249977111117893], borders: {top: ["thin", 8], bottom: ["thin", 8]}},
52
+ headerRow: {bold: true, color: [8, -0.249977111117893], borders: {bottom: ["thin", 8]}},
53
+ totalRow: {bold: true, color: [8, -0.249977111117893], borders: {top: ["thin", 8]}},
54
+ firstColumn: {bold: true, color: [8, -0.249977111117893]},
55
+ lastColumn: {bold: true, color: [8, -0.249977111117893]},
56
+ firstRowStripe: {background: [8, 0.7999816888943144]},
57
+ firstColumnStripe: {background: [8, 0.7999816888943144]},
58
+ },
59
+ TableStyleLight7: {
60
+ wholeTable: {color: [9, -0.249977111117893], borders: {top: ["thin", 9], bottom: ["thin", 9]}},
61
+ headerRow: {bold: true, color: [9, -0.249977111117893], borders: {bottom: ["thin", 9]}},
62
+ totalRow: {bold: true, color: [9, -0.249977111117893], borders: {top: ["thin", 9]}},
63
+ firstColumn: {bold: true, color: [9, -0.249977111117893]},
64
+ lastColumn: {bold: true, color: [9, -0.249977111117893]},
65
+ firstRowStripe: {background: [9, 0.7999816888943144]},
66
+ firstColumnStripe: {background: [9, 0.7999816888943144]},
67
+ },
68
+ TableStyleLight8: {
69
+ wholeTable: {color: [1], borders: {left: ["thin", 1], right: ["thin", 1], top: ["thin", 1], bottom: ["thin", 1]}},
70
+ headerRow: {bold: true, color: [0], background: [1]},
71
+ totalRow: {bold: true, color: [1], borders: {top: ["double", 1]}},
72
+ firstColumn: {bold: true, color: [1]},
73
+ lastColumn: {bold: true, color: [1]},
74
+ firstRowStripe: {borders: {top: ["thin", 1]}},
75
+ secondRowStripe: {borders: {top: ["thin", 1]}},
76
+ firstColumnStripe: {borders: {left: ["thin", 1]}},
77
+ secondColumnStripe: {borders: {left: ["thin", 1]}},
78
+ },
79
+ TableStyleLight9: {
80
+ wholeTable: {color: [1], borders: {left: ["thin", 4], right: ["thin", 4], top: ["thin", 4], bottom: ["thin", 4]}},
81
+ headerRow: {bold: true, color: [0], background: [4]},
82
+ totalRow: {bold: true, color: [1], borders: {top: ["double", 4]}},
83
+ firstColumn: {bold: true, color: [1]},
84
+ lastColumn: {bold: true, color: [1]},
85
+ firstRowStripe: {borders: {top: ["thin", 4]}},
86
+ secondRowStripe: {borders: {top: ["thin", 4]}},
87
+ firstColumnStripe: {borders: {left: ["thin", 4]}},
88
+ secondColumnStripe: {borders: {left: ["thin", 4]}},
89
+ },
90
+ TableStyleLight10: {
91
+ wholeTable: {color: [1], borders: {left: ["thin", 5], right: ["thin", 5], top: ["thin", 5], bottom: ["thin", 5]}},
92
+ headerRow: {bold: true, color: [0], background: [5]},
93
+ totalRow: {bold: true, color: [1], borders: {top: ["double", 5]}},
94
+ firstColumn: {bold: true, color: [1]},
95
+ lastColumn: {bold: true, color: [1]},
96
+ firstRowStripe: {borders: {top: ["thin", 5]}},
97
+ secondRowStripe: {borders: {top: ["thin", 5]}},
98
+ firstColumnStripe: {borders: {left: ["thin", 5]}},
99
+ secondColumnStripe: {borders: {left: ["thin", 5]}},
100
+ },
101
+ TableStyleLight11: {
102
+ wholeTable: {color: [1], borders: {left: ["thin", 6], right: ["thin", 6], top: ["thin", 6], bottom: ["thin", 6]}},
103
+ headerRow: {bold: true, color: [0], background: [6]},
104
+ totalRow: {bold: true, color: [1], borders: {top: ["double", 6]}},
105
+ firstColumn: {bold: true, color: [1]},
106
+ lastColumn: {bold: true, color: [1]},
107
+ firstRowStripe: {borders: {top: ["thin", 6]}},
108
+ secondRowStripe: {borders: {top: ["thin", 6]}},
109
+ firstColumnStripe: {borders: {left: ["thin", 6]}},
110
+ secondColumnStripe: {borders: {left: ["thin", 6]}},
111
+ },
112
+ TableStyleLight12: {
113
+ wholeTable: {color: [1], borders: {left: ["thin", 7], right: ["thin", 7], top: ["thin", 7], bottom: ["thin", 7]}},
114
+ headerRow: {bold: true, color: [0], background: [7]},
115
+ totalRow: {bold: true, color: [1], borders: {top: ["double", 7]}},
116
+ firstColumn: {bold: true, color: [1]},
117
+ lastColumn: {bold: true, color: [1]},
118
+ firstRowStripe: {borders: {top: ["thin", 7]}},
119
+ secondRowStripe: {borders: {top: ["thin", 7]}},
120
+ firstColumnStripe: {borders: {left: ["thin", 7]}},
121
+ secondColumnStripe: {borders: {left: ["thin", 7]}},
122
+ },
123
+ TableStyleLight13: {
124
+ wholeTable: {color: [1], borders: {left: ["thin", 8], right: ["thin", 8], top: ["thin", 8], bottom: ["thin", 8]}},
125
+ headerRow: {bold: true, color: [0], background: [8]},
126
+ totalRow: {bold: true, color: [1], borders: {top: ["double", 8]}},
127
+ firstColumn: {bold: true, color: [1]},
128
+ lastColumn: {bold: true, color: [1]},
129
+ firstRowStripe: {borders: {top: ["thin", 8]}},
130
+ secondRowStripe: {borders: {top: ["thin", 8]}},
131
+ firstColumnStripe: {borders: {left: ["thin", 8]}},
132
+ secondColumnStripe: {borders: {left: ["thin", 8]}},
133
+ },
134
+ TableStyleLight14: {
135
+ wholeTable: {color: [1], borders: {left: ["thin", 9], right: ["thin", 9], top: ["thin", 9], bottom: ["thin", 9]}},
136
+ headerRow: {bold: true, color: [0], background: [9]},
137
+ totalRow: {bold: true, color: [1], borders: {top: ["double", 9]}},
138
+ firstColumn: {bold: true, color: [1]},
139
+ lastColumn: {bold: true, color: [1]},
140
+ firstRowStripe: {borders: {top: ["thin", 9]}},
141
+ secondRowStripe: {borders: {top: ["thin", 9]}},
142
+ firstColumnStripe: {borders: {left: ["thin", 9]}},
143
+ secondColumnStripe: {borders: {left: ["thin", 9]}},
144
+ },
145
+ };
@@ -0,0 +1,131 @@
1
+ import type { XlsxPresetTableStyle } from "../types";
2
+
3
+ /** Medium styles emphasizing the header, total row and outside edges. */
4
+ export const xlsxMediumEdgeTableStyles: Readonly<Record<string, XlsxPresetTableStyle>> = {
5
+ TableStyleMedium15: {
6
+ wholeTable: {color: [1], borders: {left: ["thin", 1], right: ["thin", 1], top: ["medium", 1], bottom: ["medium", 1], vertical: ["thin", 1], horizontal: ["thin", 1]}},
7
+ headerRow: {bold: true, color: [0], background: [1], borders: {bottom: ["medium", 1]}},
8
+ totalRow: {borders: {top: ["double", 1]}},
9
+ firstColumn: {bold: true, color: [0], background: [1]},
10
+ lastColumn: {bold: true, color: [0], background: [1]},
11
+ firstRowStripe: {background: [0, -0.1499984740745262]},
12
+ firstColumnStripe: {background: [0, -0.1499984740745262]},
13
+ },
14
+ TableStyleMedium16: {
15
+ wholeTable: {color: [1], borders: {top: ["medium", 1], bottom: ["medium", 1]}},
16
+ headerRow: {bold: true, color: [0], background: [4], borders: {bottom: ["medium", 1]}},
17
+ totalRow: {borders: {top: ["double", 1]}},
18
+ firstColumn: {bold: true, color: [0], background: [4]},
19
+ lastColumn: {bold: true, color: [0], background: [4]},
20
+ firstRowStripe: {background: [0, -0.1499984740745262]},
21
+ firstColumnStripe: {background: [0, -0.1499984740745262]},
22
+ },
23
+ TableStyleMedium17: {
24
+ wholeTable: {color: [1], borders: {top: ["medium", 1], bottom: ["medium", 1]}},
25
+ headerRow: {bold: true, color: [0], background: [5], borders: {bottom: ["medium", 1]}},
26
+ totalRow: {borders: {top: ["double", 1]}},
27
+ firstColumn: {bold: true, color: [0], background: [5]},
28
+ lastColumn: {bold: true, color: [0], background: [5]},
29
+ firstRowStripe: {background: [0, -0.1499984740745262]},
30
+ firstColumnStripe: {background: [0, -0.1499984740745262]},
31
+ },
32
+ TableStyleMedium18: {
33
+ wholeTable: {color: [1], borders: {top: ["medium", 1], bottom: ["medium", 1]}},
34
+ headerRow: {bold: true, color: [0], background: [6], borders: {bottom: ["medium", 1]}},
35
+ totalRow: {borders: {top: ["double", 1]}},
36
+ firstColumn: {bold: true, color: [0], background: [6]},
37
+ lastColumn: {bold: true, color: [0], background: [6]},
38
+ firstRowStripe: {background: [0, -0.1499984740745262]},
39
+ firstColumnStripe: {background: [0, -0.1499984740745262]},
40
+ },
41
+ TableStyleMedium19: {
42
+ wholeTable: {color: [1], borders: {top: ["medium", 1], bottom: ["medium", 1]}},
43
+ headerRow: {bold: true, color: [0], background: [7], borders: {bottom: ["medium", 1]}},
44
+ totalRow: {borders: {top: ["double", 1]}},
45
+ firstColumn: {bold: true, color: [0], background: [7]},
46
+ lastColumn: {bold: true, color: [0], background: [7]},
47
+ firstRowStripe: {background: [0, -0.1499984740745262]},
48
+ firstColumnStripe: {background: [0, -0.1499984740745262]},
49
+ },
50
+ TableStyleMedium20: {
51
+ wholeTable: {color: [1], borders: {top: ["medium", 1], bottom: ["medium", 1]}},
52
+ headerRow: {bold: true, color: [0], background: [8], borders: {bottom: ["medium", 1]}},
53
+ totalRow: {borders: {top: ["double", 1]}},
54
+ firstColumn: {bold: true, color: [0], background: [8]},
55
+ lastColumn: {bold: true, color: [0], background: [8]},
56
+ firstRowStripe: {background: [0, -0.1499984740745262]},
57
+ firstColumnStripe: {background: [0, -0.1499984740745262]},
58
+ },
59
+ TableStyleMedium21: {
60
+ wholeTable: {color: [1], borders: {top: ["medium", 1], bottom: ["medium", 1]}},
61
+ headerRow: {bold: true, color: [0], background: [9], borders: {bottom: ["medium", 1]}},
62
+ totalRow: {borders: {top: ["double", 1]}},
63
+ firstColumn: {bold: true, color: [0], background: [9]},
64
+ lastColumn: {bold: true, color: [0], background: [9]},
65
+ firstRowStripe: {background: [0, -0.1499984740745262]},
66
+ firstColumnStripe: {background: [0, -0.1499984740745262]},
67
+ },
68
+ TableStyleMedium22: {
69
+ wholeTable: {color: [1], background: [0, -0.1499984740745262], borders: {left: ["thin", 1], right: ["thin", 1], top: ["thin", 1], bottom: ["thin", 1], vertical: ["thin", 1], horizontal: ["thin", 1]}},
70
+ headerRow: {bold: true, color: [1]},
71
+ totalRow: {bold: true, color: [1], borders: {top: ["medium", 1]}},
72
+ firstColumn: {bold: true, color: [1]},
73
+ lastColumn: {bold: true, color: [1]},
74
+ firstRowStripe: {background: [0, -0.3499862666707358]},
75
+ firstColumnStripe: {background: [0, -0.3499862666707358]},
76
+ },
77
+ TableStyleMedium23: {
78
+ wholeTable: {color: [1], background: [4, 0.7999816888943144], borders: {left: ["thin", 4, 0.3999755851924192], right: ["thin", 4, 0.3999755851924192], top: ["thin", 4, 0.3999755851924192], bottom: ["thin", 4, 0.3999755851924192], vertical: ["thin", 4, 0.3999755851924192], horizontal: ["thin", 4, 0.3999755851924192]}},
79
+ headerRow: {bold: true, color: [1]},
80
+ totalRow: {bold: true, color: [1], borders: {top: ["medium", 4]}},
81
+ firstColumn: {bold: true, color: [1]},
82
+ lastColumn: {bold: true, color: [1]},
83
+ firstRowStripe: {background: [4, 0.5999938962981048]},
84
+ firstColumnStripe: {background: [4, 0.5999938962981048]},
85
+ },
86
+ TableStyleMedium24: {
87
+ wholeTable: {color: [1], background: [5, 0.7999816888943144], borders: {left: ["thin", 5, 0.3999755851924192], right: ["thin", 5, 0.3999755851924192], top: ["thin", 5, 0.3999755851924192], bottom: ["thin", 5, 0.3999755851924192], vertical: ["thin", 5, 0.3999755851924192], horizontal: ["thin", 5, 0.3999755851924192]}},
88
+ headerRow: {bold: true, color: [1]},
89
+ totalRow: {bold: true, color: [1], borders: {top: ["medium", 5]}},
90
+ firstColumn: {bold: true, color: [1]},
91
+ lastColumn: {bold: true, color: [1]},
92
+ firstRowStripe: {background: [5, 0.5999938962981048]},
93
+ firstColumnStripe: {background: [5, 0.5999938962981048]},
94
+ },
95
+ TableStyleMedium25: {
96
+ wholeTable: {color: [1], background: [6, 0.7999816888943144], borders: {left: ["thin", 6, 0.3999755851924192], right: ["thin", 6, 0.3999755851924192], top: ["thin", 6, 0.3999755851924192], bottom: ["thin", 6, 0.3999755851924192], vertical: ["thin", 6, 0.3999755851924192], horizontal: ["thin", 6, 0.3999755851924192]}},
97
+ headerRow: {bold: true, color: [1]},
98
+ totalRow: {bold: true, color: [1], borders: {top: ["medium", 6]}},
99
+ firstColumn: {bold: true, color: [1]},
100
+ lastColumn: {bold: true, color: [1]},
101
+ firstRowStripe: {background: [6, 0.5999938962981048]},
102
+ firstColumnStripe: {background: [6, 0.5999938962981048]},
103
+ },
104
+ TableStyleMedium26: {
105
+ wholeTable: {color: [1], background: [7, 0.7999816888943144], borders: {left: ["thin", 7, 0.3999755851924192], right: ["thin", 7, 0.3999755851924192], top: ["thin", 7, 0.3999755851924192], bottom: ["thin", 7, 0.3999755851924192], vertical: ["thin", 7, 0.3999755851924192], horizontal: ["thin", 7, 0.3999755851924192]}},
106
+ headerRow: {bold: true, color: [1]},
107
+ totalRow: {bold: true, color: [1], borders: {top: ["medium", 7]}},
108
+ firstColumn: {bold: true, color: [1]},
109
+ lastColumn: {bold: true, color: [1]},
110
+ firstRowStripe: {background: [7, 0.5999938962981048]},
111
+ firstColumnStripe: {background: [7, 0.5999938962981048]},
112
+ },
113
+ TableStyleMedium27: {
114
+ wholeTable: {color: [1], background: [8, 0.7999816888943144], borders: {left: ["thin", 8, 0.3999755851924192], right: ["thin", 8, 0.3999755851924192], top: ["thin", 8, 0.3999755851924192], bottom: ["thin", 8, 0.3999755851924192], vertical: ["thin", 8, 0.3999755851924192], horizontal: ["thin", 8, 0.3999755851924192]}},
115
+ headerRow: {bold: true, color: [1]},
116
+ totalRow: {bold: true, color: [1], borders: {top: ["medium", 8]}},
117
+ firstColumn: {bold: true, color: [1]},
118
+ lastColumn: {bold: true, color: [1]},
119
+ firstRowStripe: {background: [8, 0.5999938962981048]},
120
+ firstColumnStripe: {background: [8, 0.5999938962981048]},
121
+ },
122
+ TableStyleMedium28: {
123
+ wholeTable: {color: [1], background: [9, 0.7999816888943144], borders: {left: ["thin", 9, 0.3999755851924192], right: ["thin", 9, 0.3999755851924192], top: ["thin", 9, 0.3999755851924192], bottom: ["thin", 9, 0.3999755851924192], vertical: ["thin", 9, 0.3999755851924192], horizontal: ["thin", 9, 0.3999755851924192]}},
124
+ headerRow: {bold: true, color: [1]},
125
+ totalRow: {bold: true, color: [1], borders: {top: ["medium", 9]}},
126
+ firstColumn: {bold: true, color: [1]},
127
+ lastColumn: {bold: true, color: [1]},
128
+ firstRowStripe: {background: [9, 0.5999938962981048]},
129
+ firstColumnStripe: {background: [9, 0.5999938962981048]},
130
+ },
131
+ };