@js-ak/excel-toolbox 1.8.3 → 1.9.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 (207) hide show
  1. package/build/cjs/lib/template/template-fs.js +2 -1
  2. package/build/cjs/lib/template/template-memory.js +2 -1
  3. package/build/cjs/lib/template/utils/column-letter-to-index.js +15 -0
  4. package/build/cjs/lib/template/utils/index.js +1 -1
  5. package/build/cjs/lib/template/utils/prepare-row-to-cells.js +2 -2
  6. package/build/cjs/lib/template/utils/validate-worksheet-xml.js +19 -9
  7. package/build/cjs/lib/utils/index.js +2 -0
  8. package/build/cjs/lib/utils/trim-and-join-multiline.js +32 -0
  9. package/build/cjs/lib/workbook-builder/default/border.js +18 -0
  10. package/build/cjs/lib/workbook-builder/default/cell-xf.js +15 -0
  11. package/build/cjs/lib/workbook-builder/default/fill.js +18 -0
  12. package/build/cjs/lib/workbook-builder/default/font.js +19 -0
  13. package/build/cjs/lib/workbook-builder/default/index.js +21 -0
  14. package/build/cjs/lib/workbook-builder/default/sheet-name.js +10 -0
  15. package/build/cjs/lib/workbook-builder/index.js +18 -0
  16. package/build/cjs/lib/workbook-builder/merge-cells/add.js +72 -0
  17. package/build/cjs/lib/workbook-builder/merge-cells/helpers/index.js +18 -0
  18. package/build/cjs/lib/workbook-builder/merge-cells/helpers/ranges-equal.js +17 -0
  19. package/build/cjs/lib/workbook-builder/merge-cells/helpers/ranges-intersect.js +17 -0
  20. package/build/cjs/lib/workbook-builder/merge-cells/index.js +18 -0
  21. package/build/cjs/lib/workbook-builder/merge-cells/remove.js +60 -0
  22. package/build/cjs/lib/workbook-builder/shared-string-ref/add.js +24 -0
  23. package/build/cjs/lib/workbook-builder/shared-string-ref/index.js +19 -0
  24. package/build/cjs/lib/workbook-builder/shared-string-ref/remove-all-from-sheet.js +66 -0
  25. package/build/cjs/lib/workbook-builder/shared-string-ref/remove.js +66 -0
  26. package/build/cjs/lib/workbook-builder/style-ref/add-or-get.js +94 -0
  27. package/build/cjs/lib/workbook-builder/style-ref/helpers/add-num-fmt.js +25 -0
  28. package/build/cjs/lib/workbook-builder/style-ref/helpers/border-to-xml.js +49 -0
  29. package/build/cjs/lib/workbook-builder/style-ref/helpers/fill-to-xml.js +51 -0
  30. package/build/cjs/lib/workbook-builder/style-ref/helpers/font-to-xml.js +112 -0
  31. package/build/cjs/lib/workbook-builder/style-ref/helpers/index.js +21 -0
  32. package/build/cjs/lib/workbook-builder/style-ref/helpers/reindex-style-map-after-removal.js +30 -0
  33. package/build/cjs/lib/workbook-builder/style-ref/index.js +19 -0
  34. package/build/cjs/lib/workbook-builder/style-ref/remove-all-from-sheet.js +26 -0
  35. package/build/cjs/lib/workbook-builder/style-ref/remove.js +52 -0
  36. package/build/cjs/lib/workbook-builder/types/app-xml-options.js +2 -0
  37. package/build/cjs/lib/workbook-builder/types/border-style.js +2 -0
  38. package/build/cjs/lib/workbook-builder/types/cell-data.js +2 -0
  39. package/build/cjs/lib/workbook-builder/types/cell-style.js +2 -0
  40. package/build/cjs/lib/workbook-builder/types/cell-type.js +2 -0
  41. package/build/cjs/lib/workbook-builder/types/cell-value.js +2 -0
  42. package/build/cjs/lib/workbook-builder/types/cell-xf.js +2 -0
  43. package/build/cjs/lib/workbook-builder/types/index.js +27 -0
  44. package/build/cjs/lib/workbook-builder/types/merge-cell.js +2 -0
  45. package/build/cjs/lib/workbook-builder/types/row-data.js +2 -0
  46. package/build/cjs/lib/workbook-builder/types/sheet-data.js +2 -0
  47. package/build/cjs/lib/workbook-builder/types/xml-node.js +2 -0
  48. package/build/cjs/lib/workbook-builder/utils/build-app-xml.js +51 -0
  49. package/build/cjs/lib/workbook-builder/utils/build-cell-children.js +59 -0
  50. package/build/cjs/lib/workbook-builder/utils/build-content-types-xml.js +42 -0
  51. package/build/cjs/lib/workbook-builder/utils/build-core-xml.js +27 -0
  52. package/build/cjs/lib/workbook-builder/utils/build-rels-xml.js +19 -0
  53. package/build/cjs/lib/workbook-builder/utils/build-shared-strings-xml.js +39 -0
  54. package/build/cjs/lib/workbook-builder/utils/build-styles-xml.js +178 -0
  55. package/build/cjs/lib/workbook-builder/utils/build-theme-xml.js +609 -0
  56. package/build/cjs/lib/workbook-builder/utils/build-workbook-rels-xml.js +58 -0
  57. package/build/cjs/lib/workbook-builder/utils/build-workbook-xml.js +26 -0
  58. package/build/cjs/lib/workbook-builder/utils/build-worksheet-xml.js +66 -0
  59. package/build/cjs/lib/workbook-builder/utils/build-xml.js +72 -0
  60. package/build/cjs/lib/workbook-builder/utils/constants.js +55 -0
  61. package/build/cjs/lib/workbook-builder/utils/date-to-excel-serial.js +16 -0
  62. package/build/cjs/lib/workbook-builder/utils/index.js +34 -0
  63. package/build/cjs/lib/workbook-builder/utils/initialize-files.js +40 -0
  64. package/build/cjs/lib/workbook-builder/utils/sheet.js +144 -0
  65. package/build/cjs/lib/workbook-builder/utils/write-shared-strings-xml.js +49 -0
  66. package/build/cjs/lib/workbook-builder/utils/write-styles-xml.js +196 -0
  67. package/build/cjs/lib/workbook-builder/utils/write-worksheet-xml.js +209 -0
  68. package/build/cjs/lib/workbook-builder/utils/write-xml.js +37 -0
  69. package/build/cjs/lib/workbook-builder/workbook-builder.js +414 -0
  70. package/build/esm/lib/template/template-fs.js +2 -1
  71. package/build/esm/lib/template/template-memory.js +2 -1
  72. package/build/esm/lib/template/utils/column-letter-to-index.js +12 -0
  73. package/build/esm/lib/template/utils/index.js +1 -1
  74. package/build/esm/lib/template/utils/prepare-row-to-cells.js +1 -1
  75. package/build/esm/lib/template/utils/validate-worksheet-xml.js +19 -9
  76. package/build/esm/lib/utils/index.js +2 -0
  77. package/build/esm/lib/utils/trim-and-join-multiline.js +29 -0
  78. package/build/esm/lib/workbook-builder/default/border.js +14 -0
  79. package/build/esm/lib/workbook-builder/default/cell-xf.js +11 -0
  80. package/build/esm/lib/workbook-builder/default/fill.js +14 -0
  81. package/build/esm/lib/workbook-builder/default/font.js +15 -0
  82. package/build/esm/lib/workbook-builder/default/index.js +5 -0
  83. package/build/esm/lib/workbook-builder/default/sheet-name.js +6 -0
  84. package/build/esm/lib/workbook-builder/index.js +2 -0
  85. package/build/esm/lib/workbook-builder/merge-cells/add.js +36 -0
  86. package/build/esm/lib/workbook-builder/merge-cells/helpers/index.js +2 -0
  87. package/build/esm/lib/workbook-builder/merge-cells/helpers/ranges-equal.js +14 -0
  88. package/build/esm/lib/workbook-builder/merge-cells/helpers/ranges-intersect.js +14 -0
  89. package/build/esm/lib/workbook-builder/merge-cells/index.js +2 -0
  90. package/build/esm/lib/workbook-builder/merge-cells/remove.js +24 -0
  91. package/build/esm/lib/workbook-builder/shared-string-ref/add.js +21 -0
  92. package/build/esm/lib/workbook-builder/shared-string-ref/index.js +3 -0
  93. package/build/esm/lib/workbook-builder/shared-string-ref/remove-all-from-sheet.js +63 -0
  94. package/build/esm/lib/workbook-builder/shared-string-ref/remove.js +63 -0
  95. package/build/esm/lib/workbook-builder/style-ref/add-or-get.js +58 -0
  96. package/build/esm/lib/workbook-builder/style-ref/helpers/add-num-fmt.js +21 -0
  97. package/build/esm/lib/workbook-builder/style-ref/helpers/border-to-xml.js +45 -0
  98. package/build/esm/lib/workbook-builder/style-ref/helpers/fill-to-xml.js +47 -0
  99. package/build/esm/lib/workbook-builder/style-ref/helpers/font-to-xml.js +75 -0
  100. package/build/esm/lib/workbook-builder/style-ref/helpers/index.js +5 -0
  101. package/build/esm/lib/workbook-builder/style-ref/helpers/reindex-style-map-after-removal.js +26 -0
  102. package/build/esm/lib/workbook-builder/style-ref/index.js +3 -0
  103. package/build/esm/lib/workbook-builder/style-ref/remove-all-from-sheet.js +23 -0
  104. package/build/esm/lib/workbook-builder/style-ref/remove.js +49 -0
  105. package/build/esm/lib/workbook-builder/types/app-xml-options.js +1 -0
  106. package/build/esm/lib/workbook-builder/types/border-style.js +1 -0
  107. package/build/esm/lib/workbook-builder/types/cell-data.js +1 -0
  108. package/build/esm/lib/workbook-builder/types/cell-style.js +1 -0
  109. package/build/esm/lib/workbook-builder/types/cell-type.js +1 -0
  110. package/build/esm/lib/workbook-builder/types/cell-value.js +1 -0
  111. package/build/esm/lib/workbook-builder/types/cell-xf.js +1 -0
  112. package/build/esm/lib/workbook-builder/types/index.js +11 -0
  113. package/build/esm/lib/workbook-builder/types/merge-cell.js +1 -0
  114. package/build/esm/lib/workbook-builder/types/row-data.js +1 -0
  115. package/build/esm/lib/workbook-builder/types/sheet-data.js +1 -0
  116. package/build/esm/lib/workbook-builder/types/xml-node.js +1 -0
  117. package/build/esm/lib/workbook-builder/utils/build-app-xml.js +48 -0
  118. package/build/esm/lib/workbook-builder/utils/build-cell-children.js +56 -0
  119. package/build/esm/lib/workbook-builder/utils/build-content-types-xml.js +39 -0
  120. package/build/esm/lib/workbook-builder/utils/build-core-xml.js +24 -0
  121. package/build/esm/lib/workbook-builder/utils/build-rels-xml.js +16 -0
  122. package/build/esm/lib/workbook-builder/utils/build-shared-strings-xml.js +36 -0
  123. package/build/esm/lib/workbook-builder/utils/build-styles-xml.js +142 -0
  124. package/build/esm/lib/workbook-builder/utils/build-theme-xml.js +606 -0
  125. package/build/esm/lib/workbook-builder/utils/build-workbook-rels-xml.js +55 -0
  126. package/build/esm/lib/workbook-builder/utils/build-workbook-xml.js +23 -0
  127. package/build/esm/lib/workbook-builder/utils/build-worksheet-xml.js +63 -0
  128. package/build/esm/lib/workbook-builder/utils/build-xml.js +69 -0
  129. package/build/esm/lib/workbook-builder/utils/constants.js +52 -0
  130. package/build/esm/lib/workbook-builder/utils/date-to-excel-serial.js +13 -0
  131. package/build/esm/lib/workbook-builder/utils/index.js +18 -0
  132. package/build/esm/lib/workbook-builder/utils/initialize-files.js +36 -0
  133. package/build/esm/lib/workbook-builder/utils/sheet.js +141 -0
  134. package/build/esm/lib/workbook-builder/utils/write-shared-strings-xml.js +43 -0
  135. package/build/esm/lib/workbook-builder/utils/write-styles-xml.js +157 -0
  136. package/build/esm/lib/workbook-builder/utils/write-worksheet-xml.js +203 -0
  137. package/build/esm/lib/workbook-builder/utils/write-xml.js +34 -0
  138. package/build/esm/lib/workbook-builder/workbook-builder.js +374 -0
  139. package/build/types/lib/template/utils/column-letter-to-index.d.ts +1 -0
  140. package/build/types/lib/template/utils/index.d.ts +1 -1
  141. package/build/types/lib/utils/index.d.ts +2 -0
  142. package/build/types/lib/utils/trim-and-join-multiline.d.ts +23 -0
  143. package/build/types/lib/workbook-builder/default/border.d.ts +7 -0
  144. package/build/types/lib/workbook-builder/default/cell-xf.d.ts +7 -0
  145. package/build/types/lib/workbook-builder/default/fill.d.ts +7 -0
  146. package/build/types/lib/workbook-builder/default/font.d.ts +21 -0
  147. package/build/types/lib/workbook-builder/default/index.d.ts +5 -0
  148. package/build/types/lib/workbook-builder/default/sheet-name.d.ts +6 -0
  149. package/build/types/lib/workbook-builder/index.d.ts +2 -0
  150. package/build/types/lib/workbook-builder/merge-cells/add.d.ts +15 -0
  151. package/build/types/lib/workbook-builder/merge-cells/helpers/index.d.ts +2 -0
  152. package/build/types/lib/workbook-builder/merge-cells/helpers/ranges-equal.d.ts +10 -0
  153. package/build/types/lib/workbook-builder/merge-cells/helpers/ranges-intersect.d.ts +10 -0
  154. package/build/types/lib/workbook-builder/merge-cells/index.d.ts +2 -0
  155. package/build/types/lib/workbook-builder/merge-cells/remove.d.ts +15 -0
  156. package/build/types/lib/workbook-builder/shared-string-ref/add.d.ts +13 -0
  157. package/build/types/lib/workbook-builder/shared-string-ref/index.d.ts +3 -0
  158. package/build/types/lib/workbook-builder/shared-string-ref/remove-all-from-sheet.d.ts +10 -0
  159. package/build/types/lib/workbook-builder/shared-string-ref/remove.d.ts +13 -0
  160. package/build/types/lib/workbook-builder/style-ref/add-or-get.d.ts +16 -0
  161. package/build/types/lib/workbook-builder/style-ref/helpers/add-num-fmt.d.ts +17 -0
  162. package/build/types/lib/workbook-builder/style-ref/helpers/border-to-xml.d.ts +16 -0
  163. package/build/types/lib/workbook-builder/style-ref/helpers/fill-to-xml.d.ts +17 -0
  164. package/build/types/lib/workbook-builder/style-ref/helpers/font-to-xml.d.ts +18 -0
  165. package/build/types/lib/workbook-builder/style-ref/helpers/index.d.ts +5 -0
  166. package/build/types/lib/workbook-builder/style-ref/helpers/reindex-style-map-after-removal.d.ts +15 -0
  167. package/build/types/lib/workbook-builder/style-ref/index.d.ts +3 -0
  168. package/build/types/lib/workbook-builder/style-ref/remove-all-from-sheet.d.ts +4 -0
  169. package/build/types/lib/workbook-builder/style-ref/remove.d.ts +18 -0
  170. package/build/types/lib/workbook-builder/types/app-xml-options.d.ts +9 -0
  171. package/build/types/lib/workbook-builder/types/border-style.d.ts +5 -0
  172. package/build/types/lib/workbook-builder/types/cell-data.d.ts +10 -0
  173. package/build/types/lib/workbook-builder/types/cell-style.d.ts +32 -0
  174. package/build/types/lib/workbook-builder/types/cell-type.d.ts +11 -0
  175. package/build/types/lib/workbook-builder/types/cell-value.d.ts +2 -0
  176. package/build/types/lib/workbook-builder/types/cell-xf.d.ts +13 -0
  177. package/build/types/lib/workbook-builder/types/index.d.ts +11 -0
  178. package/build/types/lib/workbook-builder/types/merge-cell.d.ts +6 -0
  179. package/build/types/lib/workbook-builder/types/row-data.d.ts +5 -0
  180. package/build/types/lib/workbook-builder/types/sheet-data.d.ts +13 -0
  181. package/build/types/lib/workbook-builder/types/xml-node.d.ts +11 -0
  182. package/build/types/lib/workbook-builder/utils/build-app-xml.d.ts +2 -0
  183. package/build/types/lib/workbook-builder/utils/build-cell-children.d.ts +9 -0
  184. package/build/types/lib/workbook-builder/utils/build-content-types-xml.d.ts +1 -0
  185. package/build/types/lib/workbook-builder/utils/build-core-xml.d.ts +1 -0
  186. package/build/types/lib/workbook-builder/utils/build-rels-xml.d.ts +1 -0
  187. package/build/types/lib/workbook-builder/utils/build-shared-strings-xml.d.ts +10 -0
  188. package/build/types/lib/workbook-builder/utils/build-styles-xml.d.ts +23 -0
  189. package/build/types/lib/workbook-builder/utils/build-theme-xml.d.ts +1 -0
  190. package/build/types/lib/workbook-builder/utils/build-workbook-rels-xml.d.ts +9 -0
  191. package/build/types/lib/workbook-builder/utils/build-workbook-xml.d.ts +3 -0
  192. package/build/types/lib/workbook-builder/utils/build-worksheet-xml.d.ts +2 -0
  193. package/build/types/lib/workbook-builder/utils/build-xml.d.ts +50 -0
  194. package/build/types/lib/workbook-builder/utils/constants.d.ts +47 -0
  195. package/build/types/lib/workbook-builder/utils/date-to-excel-serial.d.ts +9 -0
  196. package/build/types/lib/workbook-builder/utils/index.d.ts +18 -0
  197. package/build/types/lib/workbook-builder/utils/initialize-files.d.ts +13 -0
  198. package/build/types/lib/workbook-builder/utils/sheet.d.ts +21 -0
  199. package/build/types/lib/workbook-builder/utils/write-shared-strings-xml.d.ts +11 -0
  200. package/build/types/lib/workbook-builder/utils/write-styles-xml.d.ts +24 -0
  201. package/build/types/lib/workbook-builder/utils/write-worksheet-xml.d.ts +14 -0
  202. package/build/types/lib/workbook-builder/utils/write-xml.d.ts +3 -0
  203. package/build/types/lib/workbook-builder/workbook-builder.d.ts +110 -0
  204. package/package.json +1 -1
  205. /package/build/cjs/lib/{template/utils → utils}/escape-xml.js +0 -0
  206. /package/build/esm/lib/{template/utils → utils}/escape-xml.js +0 -0
  207. /package/build/types/lib/{template/utils → utils}/escape-xml.d.ts +0 -0
@@ -0,0 +1,7 @@
1
+ import { XmlNode } from "../types/index.js";
2
+ /**
3
+ * Creates a basic fill XML node with no pattern.
4
+ *
5
+ * @returns XML node representing an empty pattern fill
6
+ */
7
+ export declare const fill: () => XmlNode;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Creates a default font XML node with Calibri font.
3
+ *
4
+ * @returns XML node representing a default font configuration
5
+ */
6
+ export declare const font: () => {
7
+ children: ({
8
+ attrs: {
9
+ val: string;
10
+ theme?: undefined;
11
+ };
12
+ tag: string;
13
+ } | {
14
+ attrs: {
15
+ theme: string;
16
+ val?: undefined;
17
+ };
18
+ tag: string;
19
+ })[];
20
+ tag: string;
21
+ };
@@ -0,0 +1,5 @@
1
+ export * from "./border.js";
2
+ export * from "./cell-xf.js";
3
+ export * from "./fill.js";
4
+ export * from "./font.js";
5
+ export * from "./sheet-name.js";
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Returns the default sheet name.
3
+ *
4
+ * @returns Default sheet name string
5
+ */
6
+ export declare const sheetName: () => string;
@@ -0,0 +1,2 @@
1
+ export * from "./utils/constants.js";
2
+ export * from "./workbook-builder.js";
@@ -0,0 +1,15 @@
1
+ import type { WorkbookBuilder } from "../workbook-builder.js";
2
+ import { MergeCell } from "../types/index.js";
3
+ /**
4
+ * Adds a merge cell range to the specified sheet.
5
+ *
6
+ * @param this - WorkbookBuilder instance
7
+ * @param payload - Merge cell data with sheet name
8
+ *
9
+ * @returns The added merge cell object
10
+ *
11
+ * @throws Error if sheet is not found or merge intersects with existing merged cells
12
+ */
13
+ export declare function add(this: WorkbookBuilder, payload: MergeCell & {
14
+ sheetName: string;
15
+ }): MergeCell;
@@ -0,0 +1,2 @@
1
+ export * from "./ranges-equal.js";
2
+ export * from "./ranges-intersect.js";
@@ -0,0 +1,10 @@
1
+ import { MergeCell } from "../../types/index.js";
2
+ /**
3
+ * Compares two merge cell ranges for equality.
4
+ *
5
+ * @param a - First merge cell range to compare
6
+ * @param b - Second merge cell range to compare
7
+ *
8
+ * @returns True if both ranges have identical start and end coordinates
9
+ */
10
+ export declare function rangesEqual(a: MergeCell, b: MergeCell): boolean;
@@ -0,0 +1,10 @@
1
+ import { MergeCell } from "../../types/index.js";
2
+ /**
3
+ * Checks if two merge cell ranges intersect with each other.
4
+ *
5
+ * @param a - First merge cell range to check
6
+ * @param b - Second merge cell range to check
7
+ *
8
+ * @returns True if the ranges intersect (overlap), false otherwise
9
+ */
10
+ export declare function rangesIntersect(a: MergeCell, b: MergeCell): boolean;
@@ -0,0 +1,2 @@
1
+ export * from "./add.js";
2
+ export * from "./remove.js";
@@ -0,0 +1,15 @@
1
+ import type { WorkbookBuilder } from "../workbook-builder.js";
2
+ import { MergeCell } from "../types/index.js";
3
+ /**
4
+ * Removes a merge cell range from the specified sheet.
5
+ *
6
+ * @param this - WorkbookBuilder instance
7
+ * @param payload - Merge cell data with sheet name
8
+ *
9
+ * @returns True if the merge cell was successfully removed
10
+ *
11
+ * @throws Error if sheet is not found or merge cell does not exist
12
+ */
13
+ export declare function remove(this: WorkbookBuilder, payload: MergeCell & {
14
+ sheetName: string;
15
+ }): boolean;
@@ -0,0 +1,13 @@
1
+ import type { WorkbookBuilder } from "../workbook-builder.js";
2
+ /**
3
+ * Adds a shared string to the workbook and returns its index.
4
+ *
5
+ * @param this - WorkbookBuilder instance
6
+ * @param payload - Object containing sheet name and string value
7
+ *
8
+ * @returns The index of the shared string in the shared strings array
9
+ */
10
+ export declare function add(this: WorkbookBuilder, payload: {
11
+ sheetName: string;
12
+ str: string;
13
+ }): number;
@@ -0,0 +1,3 @@
1
+ export * from "./add.js";
2
+ export * from "./remove-all-from-sheet.js";
3
+ export * from "./remove.js";
@@ -0,0 +1,10 @@
1
+ import type { WorkbookBuilder } from "../workbook-builder.js";
2
+ /**
3
+ * Removes all shared string references for a specific sheet and cleans up unused strings.
4
+ *
5
+ * @param this - WorkbookBuilder instance
6
+ * @param payload - Object containing the sheet name to remove references from
7
+ */
8
+ export declare function removeAllFromSheet(this: WorkbookBuilder, payload: {
9
+ sheetName: string;
10
+ }): void;
@@ -0,0 +1,13 @@
1
+ import type { WorkbookBuilder } from "../workbook-builder.js";
2
+ /**
3
+ * Removes a shared string reference for a specific sheet and cleans up if unused.
4
+ *
5
+ * @param this - WorkbookBuilder instance
6
+ * @param payload - Object containing sheet name and string index to remove
7
+ *
8
+ * @returns True if the reference was successfully removed, false if string or reference not found
9
+ */
10
+ export declare function remove(this: WorkbookBuilder, payload: {
11
+ sheetName: string;
12
+ strIdx: number;
13
+ }): true;
@@ -0,0 +1,16 @@
1
+ import type { CellStyle } from "../types/index.js";
2
+ import type { WorkbookBuilder } from "../workbook-builder.js";
3
+ /**
4
+ * Adds a new cell style to the workbook or returns the index of an existing identical style.
5
+ * This function manages style deduplication by checking if an identical style already exists
6
+ * before creating a new one.
7
+ *
8
+ * @param this - The WorkbookBuilder instance
9
+ * @param payload - Object containing the style to add or get
10
+ * @param payload.style - The cell style configuration
11
+ *
12
+ * @returns The index of the style in the cellXfs array
13
+ */
14
+ export declare function addOrGet(this: WorkbookBuilder, payload: {
15
+ style: CellStyle;
16
+ }): number;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Adds a custom number format to the collection or returns the existing id.
3
+ *
4
+ * Excel reserves built-in ids below 164; custom formats start from 164.
5
+ *
6
+ * @param payload - Input arguments
7
+ * @param payload.formatCode - Format code, e.g., "0.00" or "dd/mm/yyyy"
8
+ * @param payload.numFmts - Mutable list of custom formats to search/extend
9
+ * @returns Numeric id of the number format
10
+ */
11
+ export declare const addNumFmt: (payload: {
12
+ formatCode: string;
13
+ numFmts: {
14
+ formatCode: string;
15
+ id: number;
16
+ }[];
17
+ }) => number;
@@ -0,0 +1,16 @@
1
+ import type { CellStyle, XmlNode } from "../../types/index.js";
2
+ /**
3
+ * Builds an XmlNode representing a <border> element based on the provided CellStyle.
4
+ *
5
+ * If no border is provided, the first existing border is returned (assumed default).
6
+ * Color values beginning with # are converted to RGB without the leading hash, as expected by Excel.
7
+ *
8
+ * @param payload - Input arguments
9
+ * @param payload.border - Optional border style from the cell style
10
+ * @param payload.existingBorders - Existing borders collection to fall back to
11
+ * @returns XmlNode representing a <border> element
12
+ */
13
+ export declare const borderToXml: (payload: {
14
+ border?: CellStyle["border"];
15
+ existingBorders: XmlNode["children"];
16
+ }) => XmlNode;
@@ -0,0 +1,17 @@
1
+ import type { CellStyle, XmlNode } from "../../types/index.js";
2
+ /**
3
+ * Builds an XmlNode representing a <fill> element based on the provided CellStyle.
4
+ *
5
+ * If no fill is provided, the first existing fill is returned (assumed default).
6
+ * Foreground/background colors may include a leading '#', which is removed to
7
+ * match Excel's expected RGB format.
8
+ *
9
+ * @param payload - Input arguments
10
+ * @param payload.existingFills - Existing fills collection to fall back to
11
+ * @param payload.fill - Optional fill from the cell style
12
+ * @returns XmlNode representing a <fill> element
13
+ */
14
+ export declare const fillToXml: (payload: {
15
+ existingFills: XmlNode["children"];
16
+ fill?: CellStyle["fill"];
17
+ }) => XmlNode;
@@ -0,0 +1,18 @@
1
+ import type { CellStyle, XmlNode } from "../../types/index.js";
2
+ /**
3
+ * Builds an XmlNode representing a <font> element based on the provided CellStyle.
4
+ *
5
+ * If no font is provided, returns the default font from the template. Color
6
+ * values may include a leading '#'. Six-digit RGB values are prefixed with
7
+ * 'FF' (alpha) to form ARGB; eight-digit values are used as-is. Throws for
8
+ * invalid color lengths.
9
+ *
10
+ * @param payload - Input arguments
11
+ * @param payload.existingFonts - Existing fonts collection (not used directly; kept for parity)
12
+ * @param payload.font - Optional font from the cell style
13
+ * @returns XmlNode representing a <font> element
14
+ */
15
+ export declare const fontToXml: (payload: {
16
+ existingFonts: XmlNode["children"];
17
+ font?: CellStyle["font"];
18
+ }) => XmlNode;
@@ -0,0 +1,5 @@
1
+ export * from "./add-num-fmt.js";
2
+ export * from "./border-to-xml.js";
3
+ export * from "./fill-to-xml.js";
4
+ export * from "./font-to-xml.js";
5
+ export * from "./reindex-style-map-after-removal.js";
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Reindexes a style map in-place after removing a style at a given index.
3
+ *
4
+ * - Deletes entries that point to the removed index
5
+ * - Decrements by 1 all indices greater than the removed index
6
+ *
7
+ * @param payload - Input arguments
8
+ * @param payload.removedIndex - The style index that was removed
9
+ * @param payload.styleMap - Map of serialized style key to style index
10
+ * @returns void
11
+ */
12
+ export declare const reindexStyleMapAfterRemoval: (payload: {
13
+ removedIndex: number;
14
+ styleMap: Map<string, number>;
15
+ }) => void;
@@ -0,0 +1,3 @@
1
+ export * from "./add-or-get.js";
2
+ export * from "./remove-all-from-sheet.js";
3
+ export * from "./remove.js";
@@ -0,0 +1,4 @@
1
+ import { WorkbookBuilder } from "../workbook-builder.js";
2
+ export declare function removeAllFromSheet(this: WorkbookBuilder, payload: {
3
+ sheetName: string;
4
+ }): boolean;
@@ -0,0 +1,18 @@
1
+ import type { CellStyle } from "../types/index.js";
2
+ import type { WorkbookBuilder } from "../workbook-builder.js";
3
+ /**
4
+ * Validates a cell style index and checks if the style exists in the workbook.
5
+ * This function performs validation checks on the provided style index and
6
+ * verifies that the style exists at the given index in the cellXfs array.
7
+ *
8
+ * @param this - The WorkbookBuilder instance
9
+ * @param payload - Object containing the style to validate
10
+ * @param payload.style - The cell style configuration with index
11
+ *
12
+ * @returns True if the style index is valid and the style exists
13
+ *
14
+ * @throws {Error} When styleIndex is invalid (not a number) or when style doesn't exist at the given index
15
+ */
16
+ export declare function remove(this: WorkbookBuilder, payload: {
17
+ style: CellStyle;
18
+ }): true;
@@ -0,0 +1,9 @@
1
+ export interface AppXmlOptions {
2
+ appVersion?: string;
3
+ application?: string;
4
+ company?: string;
5
+ hyperlinksChanged?: boolean;
6
+ linksUpToDate?: boolean;
7
+ sharedDoc?: boolean;
8
+ sheetNames?: string[];
9
+ }
@@ -0,0 +1,5 @@
1
+ /** Border side style. */
2
+ export type BorderStyle = {
3
+ style: "thin" | "medium" | "thick" | "dashed" | "dotted" | "double" | "hair" | "mediumDashed" | "dashDot" | "mediumDashDot" | "dashDotDot" | "mediumDashDotDot" | "slantDashDot";
4
+ color?: string;
5
+ };
@@ -0,0 +1,10 @@
1
+ import { CellStyle } from "./cell-style.js";
2
+ import { CellType } from "./cell-type.js";
3
+ import { CellValue } from "./cell-value.js";
4
+ /** Cell representation. */
5
+ export interface CellData {
6
+ value: CellValue;
7
+ isFormula?: boolean;
8
+ type?: CellType;
9
+ style?: CellStyle;
10
+ }
@@ -0,0 +1,32 @@
1
+ import { BorderStyle } from "./border-style.js";
2
+ /** Style definition applied to a cell. */
3
+ export type CellStyle = {
4
+ index?: number;
5
+ font?: {
6
+ name?: string;
7
+ size?: number;
8
+ bold?: boolean;
9
+ italic?: boolean;
10
+ underline?: boolean | "single" | "double";
11
+ color?: string;
12
+ };
13
+ fill?: {
14
+ type?: "pattern";
15
+ patternType?: string;
16
+ fgColor?: string;
17
+ bgColor?: string;
18
+ };
19
+ border?: {
20
+ top?: BorderStyle;
21
+ bottom?: BorderStyle;
22
+ left?: BorderStyle;
23
+ right?: BorderStyle;
24
+ };
25
+ alignment?: {
26
+ horizontal?: "left" | "center" | "right" | "justify";
27
+ vertical?: "top" | "center" | "bottom";
28
+ wrapText?: boolean;
29
+ indent?: number;
30
+ };
31
+ numberFormat?: string;
32
+ };
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Supported Excel cell types.
3
+ *
4
+ * s - Shared string (reference to sharedStrings.xml). <v> contains index in sharedStrings
5
+ * inlineStr - Inline string. Wrap value in <is><t>value</t></is>
6
+ * str - Formula string result. Not for plain text, only formula result
7
+ * b - Boolean. <v> — 0 or 1
8
+ * e - Error. <v> — error code
9
+ * n - Number. No attribute t or t="n"
10
+ */
11
+ export type CellType = "s" | "inlineStr" | "n" | "b" | "str" | "e";
@@ -0,0 +1,2 @@
1
+ /** Allowed cell value types. */
2
+ export type CellValue = string | number | boolean | Date | null | undefined;
@@ -0,0 +1,13 @@
1
+ export type Alignment = {
2
+ horizontal?: "left" | "center" | "right" | "justify";
3
+ vertical?: "top" | "center" | "bottom";
4
+ wrapText?: boolean;
5
+ indent?: number;
6
+ };
7
+ export type CellXf = {
8
+ borderId: number;
9
+ fillId: number;
10
+ fontId: number;
11
+ numFmtId: number;
12
+ alignment?: Alignment;
13
+ };
@@ -0,0 +1,11 @@
1
+ export * from "./app-xml-options.js";
2
+ export * from "./border-style.js";
3
+ export * from "./cell-data.js";
4
+ export * from "./cell-style.js";
5
+ export * from "./cell-type.js";
6
+ export * from "./cell-value.js";
7
+ export * from "./cell-xf.js";
8
+ export * from "./merge-cell.js";
9
+ export * from "./row-data.js";
10
+ export * from "./sheet-data.js";
11
+ export * from "./xml-node.js";
@@ -0,0 +1,6 @@
1
+ export interface MergeCell {
2
+ startRow: number;
3
+ startCol: number;
4
+ endRow: number;
5
+ endCol: number;
6
+ }
@@ -0,0 +1,5 @@
1
+ import { CellData } from "./cell-data.js";
2
+ /** Row representation. */
3
+ export interface RowData {
4
+ cells: Map<string, CellData>;
5
+ }
@@ -0,0 +1,13 @@
1
+ import { CellData } from "./cell-data.js";
2
+ import { MergeCell } from "./merge-cell.js";
3
+ import { RowData } from "./row-data.js";
4
+ /** Sheet representation with convenience methods. */
5
+ export interface SheetData {
6
+ name: string;
7
+ rows: Map<number, RowData>;
8
+ addMerge(mergeCell: MergeCell): MergeCell;
9
+ removeMerge(mergeCell: MergeCell): boolean;
10
+ setCell(rowIndex: number, column: string | number, cell: CellData): void;
11
+ getCell(rowIndex: number, column: string | number): CellData | undefined;
12
+ removeCell(rowIndex: number, column: string | number): boolean;
13
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Represents an XML node structure for building XML documents.
3
+ */
4
+ export type XmlNode = {
5
+ /** The XML tag name */
6
+ tag: string;
7
+ /** Optional attributes for the XML element */
8
+ attrs?: Record<string, string | number | undefined | null>;
9
+ /** Child elements or text content */
10
+ children?: (string | XmlNode)[];
11
+ };
@@ -0,0 +1,2 @@
1
+ import { AppXmlOptions } from "../types/index.js";
2
+ export declare function buildAppXml({ appVersion, application, company, hyperlinksChanged, linksUpToDate, sharedDoc, sheetNames, }?: AppXmlOptions): string;
@@ -0,0 +1,9 @@
1
+ import type { CellData, XmlNode } from "../types/index.js";
2
+ /**
3
+ * Builds XML children nodes for a cell based on its type and value.
4
+ *
5
+ * @param cell - The cell data containing value and type information
6
+ *
7
+ * @returns Array of XML nodes representing the cell's content structure
8
+ */
9
+ export declare function buildCellChildren(cell: CellData): XmlNode[];
@@ -0,0 +1 @@
1
+ export declare function buildContentTypesXml(sheetsCount: number): string;
@@ -0,0 +1 @@
1
+ export declare function buildCoreXml(creator?: string, lastModifiedBy?: string, created?: string, modified?: string): string;
@@ -0,0 +1 @@
1
+ export declare function buildRelsXml(): string;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Builds the `sharedStrings.xml` content from the provided strings.
3
+ *
4
+ * Note: According to the Excel specification, leading/trailing spaces in text
5
+ * nodes must set the attribute `xml:space="preserve"` on the corresponding <t>.
6
+ *
7
+ * @param strings - Array of unique strings used in the workbook
8
+ * @returns XML string for the shared strings part
9
+ */
10
+ export declare function buildSharedStringsXml(strings?: string[]): string;
@@ -0,0 +1,23 @@
1
+ import type { CellXf, XmlNode } from "../types/index.js";
2
+ /**
3
+ * Builds the `styles.xml` part for the workbook based on provided style collections.
4
+ * Falls back to default font/fill/border collections when none are provided.
5
+ *
6
+ * @param data - Style collections used to construct the stylesheet
7
+ * @param data.borders - Array of border XmlNodes
8
+ * @param data.cellXfs - Array of cell format records
9
+ * @param data.fills - Array of fill XmlNodes
10
+ * @param data.fonts - Array of font XmlNodes
11
+ * @param data.numFmts - Array of custom number formats (formatCode and id)
12
+ * @returns XML string for the styles part
13
+ */
14
+ export declare function buildStylesXml(data?: {
15
+ borders: XmlNode["children"];
16
+ cellXfs: CellXf[];
17
+ fills: XmlNode["children"];
18
+ fonts: XmlNode["children"];
19
+ numFmts: {
20
+ formatCode: string;
21
+ id: number;
22
+ }[];
23
+ }): string;
@@ -0,0 +1 @@
1
+ export declare function buildThemeXml(): string;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Builds the `_rels/workbook.xml.rels` content for the given number of sheets.
3
+ *
4
+ * Relationships are created for each worksheet and then for styles, theme, and shared strings.
5
+ *
6
+ * @param sheetsCount - Number of worksheets in the workbook
7
+ * @returns XML string for the workbook relationships part
8
+ */
9
+ export declare function buildWorkbookRels(sheetsCount: number): string;
@@ -0,0 +1,3 @@
1
+ export declare function buildWorkbookXml(sheets: {
2
+ name: string;
3
+ }[]): string;
@@ -0,0 +1,2 @@
1
+ import { SheetData } from "../types/index.js";
2
+ export declare function buildWorksheetXml(rows?: SheetData["rows"], merges?: string[]): string;
@@ -0,0 +1,50 @@
1
+ import { XmlNode } from "../types/index.js";
2
+ /**
3
+ * Builds XML string from an XmlNode structure.
4
+ *
5
+ * @param node - The XML node to convert to string
6
+ * @param level - The indentation level for formatting (default: 0)
7
+ *
8
+ * @returns The formatted XML string
9
+ */
10
+ export declare function buildXml(node: XmlNode, level?: number): string;
11
+ /**
12
+ * Cell XML Structure Documentation
13
+ *
14
+ * Reference: https://learn.microsoft.com/en-us/dotnet/api/documentformat.openxml.spreadsheet.cell?view=openxml-3.0.1
15
+ *
16
+ * Parent Elements:
17
+ * - row
18
+ *
19
+ * Child Elements:
20
+ * - extLst (Future Feature Data Storage Area)
21
+ * - f (Formula)
22
+ * - is (Rich Text Inline)
23
+ * - v (Cell Value)
24
+ *
25
+ * Attributes:
26
+ * - cm (Cell Metadata Index): The zero-based index of the cell metadata record associated with this cell.
27
+ * Metadata information is found in the Metadata Part. Cell metadata is extra information stored at the
28
+ * cell level, and is attached to the cell (travels through moves, copy / paste, clear, etc).
29
+ * Cell metadata is not accessible via formula reference.
30
+ * The possible values for this attribute are defined by the W3C XML Schema unsignedInt datatype.
31
+ *
32
+ * - ph (Show Phonetic): A Boolean value indicating if the spreadsheet application should show phonetic
33
+ * information. Phonetic information is displayed in the same cell across the top of the cell and serves
34
+ * as a 'hint' which indicates how the text should be pronounced. This should only be used for East Asian languages.
35
+ * The possible values for this attribute are defined by the W3C XML Schema boolean datatype.
36
+ *
37
+ * - r (Reference): An A1 style reference to the location of this cell
38
+ * The possible values for this attribute are defined by the ST_CellRef simple type.
39
+ *
40
+ * - s (Style Index): The index of this cell's style. Style records are stored in the Styles Part.
41
+ * The possible values for this attribute are defined by the W3C XML Schema unsignedInt datatype.
42
+ *
43
+ * - t (Cell Data Type): An enumeration representing the cell's data type.
44
+ * The possible values for this attribute are defined by the ST_CellType simple type.
45
+ *
46
+ * - vm (Value Metadata Index): The zero-based index of the value metadata record associated with this cell's value.
47
+ * Metadata records are stored in the Metadata Part. Value metadata is extra information stored at the cell level,
48
+ * but associated with the value rather than the cell itself. Value metadata is accessible via formula reference.
49
+ * The possible values for this attribute are defined by the W3C XML Schema unsignedInt datatype.
50
+ */