@cj-tech-master/excelts 4.1.0 → 4.2.0-canary.20260110034516.0919d4d

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 (56) hide show
  1. package/dist/browser/index.browser.d.ts +2 -0
  2. package/dist/browser/index.browser.js +1 -0
  3. package/dist/browser/index.d.ts +2 -0
  4. package/dist/browser/index.js +1 -0
  5. package/dist/browser/modules/excel/form-control.d.ts +157 -0
  6. package/dist/browser/modules/excel/form-control.js +267 -0
  7. package/dist/browser/modules/excel/utils/ooxml-paths.d.ts +2 -0
  8. package/dist/browser/modules/excel/utils/ooxml-paths.js +8 -0
  9. package/dist/browser/modules/excel/worksheet.d.ts +32 -0
  10. package/dist/browser/modules/excel/worksheet.js +44 -1
  11. package/dist/browser/modules/excel/xlsx/rel-type.d.ts +1 -0
  12. package/dist/browser/modules/excel/xlsx/rel-type.js +2 -1
  13. package/dist/browser/modules/excel/xlsx/xform/core/content-types-xform.js +17 -1
  14. package/dist/browser/modules/excel/xlsx/xform/drawing/ctrl-prop-xform.d.ts +22 -0
  15. package/dist/browser/modules/excel/xlsx/xform/drawing/ctrl-prop-xform.js +52 -0
  16. package/dist/browser/modules/excel/xlsx/xform/drawing/vml-drawing-xform.d.ts +44 -0
  17. package/dist/browser/modules/excel/xlsx/xform/drawing/vml-drawing-xform.js +181 -0
  18. package/dist/browser/modules/excel/xlsx/xform/sheet/worksheet-xform.js +24 -1
  19. package/dist/browser/modules/excel/xlsx/xlsx.browser.d.ts +1 -0
  20. package/dist/browser/modules/excel/xlsx/xlsx.browser.js +24 -5
  21. package/dist/cjs/index.js +3 -1
  22. package/dist/cjs/modules/excel/form-control.js +270 -0
  23. package/dist/cjs/modules/excel/utils/ooxml-paths.js +10 -0
  24. package/dist/cjs/modules/excel/worksheet.js +44 -1
  25. package/dist/cjs/modules/excel/xlsx/rel-type.js +2 -1
  26. package/dist/cjs/modules/excel/xlsx/xform/core/content-types-xform.js +16 -0
  27. package/dist/cjs/modules/excel/xlsx/xform/drawing/ctrl-prop-xform.js +55 -0
  28. package/dist/cjs/modules/excel/xlsx/xform/drawing/vml-drawing-xform.js +184 -0
  29. package/dist/cjs/modules/excel/xlsx/xform/sheet/worksheet-xform.js +23 -0
  30. package/dist/cjs/modules/excel/xlsx/xlsx.browser.js +23 -4
  31. package/dist/esm/index.browser.js +1 -0
  32. package/dist/esm/index.js +1 -0
  33. package/dist/esm/modules/excel/form-control.js +267 -0
  34. package/dist/esm/modules/excel/utils/ooxml-paths.js +8 -0
  35. package/dist/esm/modules/excel/worksheet.js +44 -1
  36. package/dist/esm/modules/excel/xlsx/rel-type.js +2 -1
  37. package/dist/esm/modules/excel/xlsx/xform/core/content-types-xform.js +17 -1
  38. package/dist/esm/modules/excel/xlsx/xform/drawing/ctrl-prop-xform.js +52 -0
  39. package/dist/esm/modules/excel/xlsx/xform/drawing/vml-drawing-xform.js +181 -0
  40. package/dist/esm/modules/excel/xlsx/xform/sheet/worksheet-xform.js +24 -1
  41. package/dist/esm/modules/excel/xlsx/xlsx.browser.js +24 -5
  42. package/dist/iife/THIRD_PARTY_NOTICES.md +112 -0
  43. package/dist/iife/excelts.iife.js +466 -30
  44. package/dist/iife/excelts.iife.js.map +1 -1
  45. package/dist/iife/excelts.iife.min.js +30 -30
  46. package/dist/types/index.browser.d.ts +2 -0
  47. package/dist/types/index.d.ts +2 -0
  48. package/dist/types/modules/excel/form-control.d.ts +157 -0
  49. package/dist/types/modules/excel/utils/ooxml-paths.d.ts +2 -0
  50. package/dist/types/modules/excel/worksheet.d.ts +32 -0
  51. package/dist/types/modules/excel/xlsx/rel-type.d.ts +1 -0
  52. package/dist/types/modules/excel/xlsx/xform/drawing/ctrl-prop-xform.d.ts +22 -0
  53. package/dist/types/modules/excel/xlsx/xform/drawing/vml-drawing-xform.d.ts +44 -0
  54. package/dist/types/modules/excel/xlsx/xlsx.browser.d.ts +1 -0
  55. package/package.json +2 -2
  56. /package/dist/{LICENSE → iife/LICENSE} +0 -0
@@ -12,9 +12,11 @@ export { Image } from "./modules/excel/image.js";
12
12
  export * from "./modules/excel/anchor.js";
13
13
  export { Table } from "./modules/excel/table.js";
14
14
  export { DataValidations } from "./modules/excel/data-validations.js";
15
+ export { FormCheckbox } from "./modules/excel/form-control.js";
15
16
  export * from "./modules/excel/enums.js";
16
17
  export * from "./modules/excel/types.js";
17
18
  export type { PivotTable, PivotTableModel, PivotTableSource, CacheField, DataField, PivotTableSubtotal, ParsedCacheDefinition, ParsedCacheRecords } from "./modules/excel/pivot-table.js";
19
+ export type { FormCheckboxModel, FormCheckboxOptions, FormControlRange, FormControlAnchor } from "./modules/excel/form-control.js";
18
20
  import { WorkbookWriter } from "./modules/excel/stream/workbook-writer.browser.js";
19
21
  import { WorkbookReader } from "./modules/excel/stream/workbook-reader.browser.js";
20
22
  import { WorksheetWriter } from "./modules/excel/stream/worksheet-writer.js";
@@ -8,6 +8,7 @@ export { Image } from "./modules/excel/image.js";
8
8
  export * from "./modules/excel/anchor.js";
9
9
  export { Table } from "./modules/excel/table.js";
10
10
  export { DataValidations } from "./modules/excel/data-validations.js";
11
+ export { FormCheckbox } from "./modules/excel/form-control.js";
11
12
  export { WorkbookWriter } from "./modules/excel/stream/workbook-writer.js";
12
13
  export { WorkbookReader } from "./modules/excel/stream/workbook-reader.js";
13
14
  export { WorksheetWriter } from "./modules/excel/stream/worksheet-writer.js";
@@ -15,6 +16,7 @@ export { WorksheetReader } from "./modules/excel/stream/worksheet-reader.js";
15
16
  export * from "./modules/excel/enums.js";
16
17
  export * from "./modules/excel/types.js";
17
18
  export type { PivotTable, PivotTableModel, PivotTableSource, CacheField, DataField, PivotTableSubtotal, ParsedCacheDefinition, ParsedCacheRecords } from "./modules/excel/pivot-table.js";
19
+ export type { FormCheckboxModel, FormCheckboxOptions, FormControlRange, FormControlAnchor } from "./modules/excel/form-control.js";
18
20
  export type { WorkbookReaderOptions, ParseEvent, SharedStringEvent, WorksheetReadyEvent, HyperlinksEvent } from "./modules/excel/stream/workbook-reader.js";
19
21
  export type { WorksheetReaderOptions, WorksheetEvent, RowEvent, HyperlinkEvent, WorksheetHyperlink } from "./modules/excel/stream/worksheet-reader.js";
20
22
  export type { WorkbookWriterOptions, ZipOptions, ZlibOptions } from "./modules/excel/stream/workbook-writer.js";
@@ -0,0 +1,157 @@
1
+ import type { Worksheet } from "./worksheet.js";
2
+ /**
3
+ * Form Control Checkbox - Legacy checkbox control compatible with Office 2007+ and WPS/LibreOffice
4
+ *
5
+ * Unlike the modern In-Cell Checkbox (which only works in Microsoft 365),
6
+ * Form Control Checkboxes are floating controls that work in virtually all
7
+ * spreadsheet applications.
8
+ */
9
+ /** EMU (English Metric Units) to pixels conversion factor at 96 DPI */
10
+ export declare const EMU_PER_PIXEL = 9525;
11
+ /** EMU to points conversion factor */
12
+ export declare const EMU_PER_POINT = 12700;
13
+ /** Anchor position for form control placement */
14
+ export interface FormControlAnchor {
15
+ /** Column index (0-based) */
16
+ col: number;
17
+ /** Column offset in EMUs (1 pixel ≈ 9525 EMUs at 96 DPI) */
18
+ colOff: number;
19
+ /** Row index (0-based) */
20
+ row: number;
21
+ /** Row offset in EMUs */
22
+ rowOff: number;
23
+ }
24
+ /** Checkbox state values */
25
+ export type CheckboxState = "Checked" | "Unchecked" | "Mixed";
26
+ /** Options for adding a form control checkbox */
27
+ export interface FormCheckboxOptions {
28
+ /** Cell reference where the checkbox value (TRUE/FALSE) will be stored */
29
+ link?: string;
30
+ /** Initial checked state */
31
+ checked?: boolean;
32
+ /** Label text displayed next to the checkbox */
33
+ text?: string;
34
+ /** Whether to use flat appearance (no 3D effect) */
35
+ noThreeD?: boolean;
36
+ /** Whether to print the checkbox */
37
+ print?: boolean;
38
+ }
39
+ /** Internal model for form control checkbox */
40
+ export interface FormCheckboxModel {
41
+ /** Unique shape ID (e.g., 1025, 1026, ...) */
42
+ shapeId: number;
43
+ /** Control property ID (rId in relationships) */
44
+ ctrlPropId: number;
45
+ /** Top-left anchor */
46
+ tl: FormControlAnchor;
47
+ /** Bottom-right anchor */
48
+ br: FormControlAnchor;
49
+ /** Cell link (e.g., "$A$1") */
50
+ link?: string;
51
+ /** Checked state */
52
+ checked: CheckboxState;
53
+ /** Label text */
54
+ text: string;
55
+ /** Use flat appearance */
56
+ noThreeD: boolean;
57
+ /** Print control */
58
+ print: boolean;
59
+ }
60
+ /** Range input for form control - can be a cell reference or position object */
61
+ export type FormControlRange = string | {
62
+ /** Top-left position */
63
+ tl: {
64
+ col: number;
65
+ row: number;
66
+ colOff?: number;
67
+ rowOff?: number;
68
+ } | string;
69
+ /** Bottom-right position (optional, defaults to reasonable size) */
70
+ br?: {
71
+ col: number;
72
+ row: number;
73
+ colOff?: number;
74
+ rowOff?: number;
75
+ } | string;
76
+ } | {
77
+ /** Start column (0-based) */
78
+ startCol: number;
79
+ /** Start row (0-based) */
80
+ startRow: number;
81
+ /** End column (0-based) */
82
+ endCol: number;
83
+ /** End row (0-based) */
84
+ endRow: number;
85
+ /** Column offset from start in EMUs */
86
+ startColOff?: number;
87
+ /** Row offset from start in EMUs */
88
+ startRowOff?: number;
89
+ /** Column offset from end in EMUs */
90
+ endColOff?: number;
91
+ /** Row offset from end in EMUs */
92
+ endRowOff?: number;
93
+ };
94
+ declare class FormCheckbox {
95
+ worksheet: Worksheet;
96
+ model: FormCheckboxModel;
97
+ constructor(worksheet: Worksheet, range: FormControlRange, options?: FormCheckboxOptions);
98
+ /**
99
+ * Get the checked state
100
+ */
101
+ get checked(): boolean;
102
+ /**
103
+ * Set the checked state
104
+ */
105
+ set checked(value: boolean);
106
+ /**
107
+ * Get the linked cell address
108
+ */
109
+ get link(): string | undefined;
110
+ /**
111
+ * Set the linked cell address
112
+ */
113
+ set link(value: string | undefined);
114
+ /**
115
+ * Get the label text
116
+ */
117
+ get text(): string;
118
+ /**
119
+ * Set the label text
120
+ */
121
+ set text(value: string);
122
+ /**
123
+ * Convert cell reference to absolute format (e.g., "A1" -> "$A$1")
124
+ */
125
+ private _toAbsoluteRef;
126
+ /**
127
+ * Parse range input into anchor positions
128
+ */
129
+ private _parseRange;
130
+ /**
131
+ * Convert anchor to VML anchor string format
132
+ * Format: "fromCol, fromColOff, fromRow, fromRowOff, toCol, toColOff, toRow, toRowOff"
133
+ * VML uses pixels for offsets
134
+ */
135
+ getVmlAnchor(): string;
136
+ /**
137
+ * Get VML style string for positioning
138
+ */
139
+ getVmlStyle(): string;
140
+ /**
141
+ * Get the numeric checked value for VML (0, 1, or 2)
142
+ */
143
+ getVmlCheckedValue(): number;
144
+ /**
145
+ * Convert anchor to VML anchor string format from model
146
+ */
147
+ static getVmlAnchor(model: FormCheckboxModel): string;
148
+ /**
149
+ * Get VML style string for positioning from model
150
+ */
151
+ static getVmlStyle(model: FormCheckboxModel): string;
152
+ /**
153
+ * Get the numeric checked value for VML from model (0, 1, or 2)
154
+ */
155
+ static getVmlCheckedValue(model: FormCheckboxModel): number;
156
+ }
157
+ export { FormCheckbox };
@@ -64,3 +64,5 @@ export declare function pivotTableRelTargetFromWorksheetName(pivotName: string):
64
64
  export declare function tableRelTargetFromWorksheet(target: string): string;
65
65
  export declare function tableRelTargetFromWorksheetName(name: string): string;
66
66
  export declare function mediaRelTargetFromRels(filename: string): string;
67
+ export declare function ctrlPropPath(id: number | string): string;
68
+ export declare function ctrlPropRelTargetFromWorksheet(id: number | string): string;
@@ -5,6 +5,7 @@ import type { Cell, FormulaResult } from "./cell.js";
5
5
  import { Image, type ImageModel } from "./image.js";
6
6
  import { Table, type TableModel } from "./table.js";
7
7
  import { DataValidations } from "./data-validations.js";
8
+ import { FormCheckbox, type FormCheckboxModel, type FormCheckboxOptions, type FormControlRange } from "./form-control.js";
8
9
  import { type PivotTable, type PivotTableModel } from "./pivot-table.js";
9
10
  import type { Workbook } from "./workbook.js";
10
11
  import type { AddImageRange, AutoFilter, CellValue, ColBreak, ConditionalFormattingOptions, DataValidation, RowBreak, RowValues, TableProperties, WorksheetProperties, WorksheetView } from "./types.js";
@@ -104,6 +105,7 @@ interface WorksheetModel {
104
105
  tables: TableModel[];
105
106
  pivotTables: PivotTable[];
106
107
  conditionalFormattings: ConditionalFormattingOptions[];
108
+ formControls: FormCheckboxModel[];
107
109
  cols?: ColumnModel[];
108
110
  rows?: RowModel[];
109
111
  dimensions?: Range;
@@ -135,6 +137,7 @@ declare class Worksheet {
135
137
  };
136
138
  pivotTables: PivotTable[];
137
139
  conditionalFormattings: ConditionalFormattingOptions[];
140
+ formControls: FormCheckbox[];
138
141
  private _headerRowCount?;
139
142
  constructor(options: WorksheetOptions);
140
143
  get name(): string;
@@ -295,6 +298,35 @@ declare class Worksheet {
295
298
  */
296
299
  addBackgroundImage(imageId: string | number): void;
297
300
  getBackgroundImageId(): string | undefined;
301
+ /**
302
+ * Add a form control checkbox to the worksheet.
303
+ *
304
+ * Form control checkboxes are the legacy style that work in Office 2007+,
305
+ * WPS Office, LibreOffice, and other spreadsheet applications.
306
+ *
307
+ * Unlike modern in-cell checkboxes (which only work in Microsoft 365),
308
+ * form control checkboxes are floating controls positioned over cells.
309
+ *
310
+ * @param range - Cell reference (e.g., "B2") or range (e.g., "B2:D3") for positioning
311
+ * @param options - Checkbox options
312
+ * @returns The created FormCheckbox instance
313
+ *
314
+ * @example
315
+ * // Simple checkbox at B2
316
+ * ws.addFormCheckbox("B2");
317
+ *
318
+ * // Checkbox with label and linked cell
319
+ * ws.addFormCheckbox("B2:D3", {
320
+ * text: "Accept terms",
321
+ * link: "A2",
322
+ * checked: false
323
+ * });
324
+ */
325
+ addFormCheckbox(range: FormControlRange, options?: FormCheckboxOptions): FormCheckbox;
326
+ /**
327
+ * Get all form control checkboxes in the worksheet
328
+ */
329
+ getFormCheckboxes(): FormCheckbox[];
298
330
  /**
299
331
  * Protect the worksheet with optional password and options
300
332
  */
@@ -16,5 +16,6 @@ declare const RelType: {
16
16
  PivotCacheRecords: string;
17
17
  PivotTable: string;
18
18
  FeaturePropertyBag: string;
19
+ CtrlProp: string;
19
20
  };
20
21
  export { RelType };
@@ -0,0 +1,22 @@
1
+ import { BaseXform } from "../base-xform.js";
2
+ import type { FormCheckboxModel } from "../../../form-control.js";
3
+ /**
4
+ * Control Properties Xform - Generates ctrlProp*.xml for form controls
5
+ *
6
+ * Each form control (checkbox, button, etc.) has an associated ctrlProp file
7
+ * that stores its properties like objectType, checked state, and linked cell.
8
+ */
9
+ declare class CtrlPropXform extends BaseXform {
10
+ model: FormCheckboxModel;
11
+ get tag(): string;
12
+ render(xmlStream: any, model?: FormCheckboxModel): void;
13
+ /**
14
+ * Generate XML string directly (convenience method)
15
+ * Uses render() internally to ensure consistency
16
+ */
17
+ toXml(model: FormCheckboxModel): string;
18
+ parseOpen(): boolean;
19
+ parseText(): void;
20
+ parseClose(): boolean;
21
+ }
22
+ export { CtrlPropXform };
@@ -0,0 +1,44 @@
1
+ import { BaseXform } from "../base-xform.js";
2
+ import { type FormCheckboxModel } from "../../../form-control.js";
3
+ /**
4
+ * Unified VML Drawing Xform - Combines Notes (comments) and Form Controls
5
+ *
6
+ * Excel uses a single VML file per worksheet that can contain:
7
+ * - Comment/note shapes (shapetype 202)
8
+ * - Form control shapes (checkbox shapetype 201, etc.)
9
+ *
10
+ * This unified xform renders both into a single VML file.
11
+ */
12
+ interface VmlDrawingModel {
13
+ /** Comment/note shapes */
14
+ comments?: any[];
15
+ /** Form control checkboxes */
16
+ formControls?: FormCheckboxModel[];
17
+ }
18
+ declare class VmlDrawingXform extends BaseXform {
19
+ map: {
20
+ [key: string]: any;
21
+ };
22
+ parser: any;
23
+ model: VmlDrawingModel;
24
+ constructor();
25
+ get tag(): string;
26
+ /**
27
+ * Render VML drawing containing both notes and form controls
28
+ */
29
+ render(xmlStream: any, model?: VmlDrawingModel): void;
30
+ /**
31
+ * Render a checkbox form control shape
32
+ */
33
+ private _renderCheckboxShape;
34
+ parseOpen(node: any): boolean;
35
+ parseText(text: string): void;
36
+ parseClose(name: string): boolean;
37
+ static DRAWING_ATTRIBUTES: {
38
+ "xmlns:v": string;
39
+ "xmlns:o": string;
40
+ "xmlns:x": string;
41
+ };
42
+ }
43
+ export { VmlDrawingXform };
44
+ export type { VmlDrawingModel };
@@ -93,6 +93,7 @@ declare class XLSX {
93
93
  PivotCacheRecords: string;
94
94
  PivotTable: string;
95
95
  FeaturePropertyBag: string;
96
+ CtrlProp: string;
96
97
  };
97
98
  constructor(workbook: Workbook);
98
99
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cj-tech-master/excelts",
3
- "version": "4.1.0",
3
+ "version": "4.2.0-canary.20260110034516.0919d4d",
4
4
  "description": "TypeScript Excel Workbook Manager - Read and Write xlsx and csv Files.",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -120,7 +120,7 @@
120
120
  "test:browser": "rimraf dist && npm run build:browser:bundle && vitest run --config vitest.browser.config.ts",
121
121
  "test:watch": "vitest",
122
122
  "build": "rimraf dist && concurrently \"npm run build:esm\" \"npm run build:cjs\" \"npm run build:browser\" \"npm run build:browser:bundle\" && npm run build:verify",
123
- "build:verify": "node scripts/check-dist-esm-specifiers.mjs --dir dist/esm && node scripts/check-dist-esm-specifiers.mjs --dir dist/browser && tsc --noEmit --module NodeNext --moduleResolution NodeNext dist/types/index.d.ts",
123
+ "build:verify": "tsc --noEmit --module NodeNext --moduleResolution NodeNext dist/types/index.d.ts",
124
124
  "analyze:browser": "rimraf dist && node --input-type=module -e \"import { execSync } from 'node:child_process'; process.env.ANALYZE='true'; execSync('rolldown -c rolldown.config.ts', { stdio: 'inherit' });\"",
125
125
  "clean": "pnpm dlx --reporter=silent rimraf \"**/node_modules\" pnpm-lock.yaml \"**/dist\" -g && pnpm i",
126
126
  "lint": "eslint && oxlint",
File without changes