@truecalc/workbook 3.1.0 → 3.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.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@truecalc/workbook",
3
3
  "type": "module",
4
4
  "description": "Spreadsheet workbook for the browser — full Workbook API compiled to WebAssembly",
5
- "version": "3.1.0",
5
+ "version": "3.3.0",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
@@ -77,6 +77,21 @@ export class JsWorkbook {
77
77
  * becomes a `Text` value.
78
78
  */
79
79
  set(sheet: string, a1: string, input: string): void;
80
+ /**
81
+ * Sets the cell at `a1` on `sheet` to a **Date-typed** serial value.
82
+ *
83
+ * Unlike [`set`](Self::set) — which stores a numeric string as a plain
84
+ * `Number` — this stores `serial` as a `Date`, the type a host uses for a
85
+ * cell it means as a date. The engine's arithmetic type propagation then
86
+ * keeps it rendering as a date through offset arithmetic: `=A1+1` and
87
+ * `=A1-7` on a Date cell stay dates (`=A1-B1` between two Date cells is a
88
+ * plain day count, matching Google Sheets).
89
+ *
90
+ * The serial round-trips exactly — it is stored verbatim, never
91
+ * reconstructed via `DATE(y, m, d)` — so pre-1900 (negative) serials and
92
+ * fractional time-of-day components are preserved bit-for-bit.
93
+ */
94
+ setDate(sheet: string, a1: string, serial: number): void;
80
95
  /**
81
96
  * Serializes the workbook to its canonical JSON string.
82
97
  */
@@ -113,6 +128,7 @@ export interface InitOutput {
113
128
  readonly jsworkbook_redefineName: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
114
129
  readonly jsworkbook_resolved: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
115
130
  readonly jsworkbook_set: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
131
+ readonly jsworkbook_setDate: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
116
132
  readonly jsworkbook_toJSON: (a: number, b: number) => void;
117
133
  readonly translateFormula: (a: number, b: number, c: number, d: number) => number;
118
134
  readonly __wbindgen_export: (a: number, b: number) => number;
@@ -234,6 +234,40 @@ export class JsWorkbook {
234
234
  wasm.__wbindgen_add_to_stack_pointer(16);
235
235
  }
236
236
  }
237
+ /**
238
+ * Sets the cell at `a1` on `sheet` to a **Date-typed** serial value.
239
+ *
240
+ * Unlike [`set`](Self::set) — which stores a numeric string as a plain
241
+ * `Number` — this stores `serial` as a `Date`, the type a host uses for a
242
+ * cell it means as a date. The engine's arithmetic type propagation then
243
+ * keeps it rendering as a date through offset arithmetic: `=A1+1` and
244
+ * `=A1-7` on a Date cell stay dates (`=A1-B1` between two Date cells is a
245
+ * plain day count, matching Google Sheets).
246
+ *
247
+ * The serial round-trips exactly — it is stored verbatim, never
248
+ * reconstructed via `DATE(y, m, d)` — so pre-1900 (negative) serials and
249
+ * fractional time-of-day components are preserved bit-for-bit.
250
+ * @param {string} sheet
251
+ * @param {string} a1
252
+ * @param {number} serial
253
+ */
254
+ setDate(sheet, a1, serial) {
255
+ try {
256
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
257
+ const ptr0 = passStringToWasm0(sheet, wasm.__wbindgen_export, wasm.__wbindgen_export2);
258
+ const len0 = WASM_VECTOR_LEN;
259
+ const ptr1 = passStringToWasm0(a1, wasm.__wbindgen_export, wasm.__wbindgen_export2);
260
+ const len1 = WASM_VECTOR_LEN;
261
+ wasm.jsworkbook_setDate(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, serial);
262
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
263
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
264
+ if (r1) {
265
+ throw takeObject(r0);
266
+ }
267
+ } finally {
268
+ wasm.__wbindgen_add_to_stack_pointer(16);
269
+ }
270
+ }
237
271
  /**
238
272
  * Serializes the workbook to its canonical JSON string.
239
273
  * @returns {string}
Binary file