@devmm/puredocs-excel-formula 1.1.1 → 1.1.2

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/dist/index.d.cts CHANGED
@@ -442,6 +442,8 @@ declare class FormulaContext {
442
442
  * cell. Requires the worksheet to expose getSpillRange; otherwise #REF!.
443
443
  */
444
444
  resolveSpillRange(anchorRef: string): FormulaValue;
445
+ /** {@link resolveSpillRange} for an anchor on another sheet ('S'!A1#). */
446
+ resolveSheetSpillRange(sheetName: string, anchorRef: string): FormulaValue;
445
447
  getRangeBounds(startRef: string, endRef: string): {
446
448
  startRow: number;
447
449
  startCol: number;
package/dist/index.d.ts CHANGED
@@ -442,6 +442,8 @@ declare class FormulaContext {
442
442
  * cell. Requires the worksheet to expose getSpillRange; otherwise #REF!.
443
443
  */
444
444
  resolveSpillRange(anchorRef: string): FormulaValue;
445
+ /** {@link resolveSpillRange} for an anchor on another sheet ('S'!A1#). */
446
+ resolveSheetSpillRange(sheetName: string, anchorRef: string): FormulaValue;
445
447
  getRangeBounds(startRef: string, endRef: string): {
446
448
  startRow: number;
447
449
  startCol: number;
package/dist/index.js CHANGED
@@ -2815,6 +2815,8 @@ function registerLookup(r) {
2815
2815
  r.register("COLUMNS", columns, 1, 1);
2816
2816
  r.register("OFFSET", offset, 3, 5, true);
2817
2817
  r.register("INDIRECT", indirect, 1, 2, true);
2818
+ r.register("ANCHORARRAY", anchorArray, 1, 1);
2819
+ r.register("SINGLE", single, 1, 1);
2818
2820
  }
2819
2821
  function num2(a, c, i) {
2820
2822
  const r = FormulaHelper.evalDouble(a[i], c);
@@ -3262,6 +3264,15 @@ function offset(a, c) {
3262
3264
  cellRefFromRowCol(newRow + height - 1, newCol + width - 1)
3263
3265
  );
3264
3266
  }
3267
+ function anchorArray(a, c) {
3268
+ const arg2 = a[0];
3269
+ if (arg2 instanceof CellReferenceNode) return c.resolveSpillRange(arg2.reference);
3270
+ if (arg2 instanceof SheetCellReferenceNode) return c.resolveSheetSpillRange(arg2.sheetName, arg2.cellReference);
3271
+ return FormulaValue.errorRef;
3272
+ }
3273
+ function single(a, c) {
3274
+ return new ImplicitIntersectionNode(a[0]).evaluate(c);
3275
+ }
3265
3276
 
3266
3277
  // src/functions/statistical-functions.ts
3267
3278
  function registerStatistical(r) {
@@ -4928,6 +4939,15 @@ var _FormulaContext = class _FormulaContext {
4928
4939
  if (colon < 0) return this.getCellValue(spillRef);
4929
4940
  return this.getRangeValues(spillRef.slice(0, colon), spillRef.slice(colon + 1));
4930
4941
  }
4942
+ /** {@link resolveSpillRange} for an anchor on another sheet ('S'!A1#). */
4943
+ resolveSheetSpillRange(sheetName, anchorRef) {
4944
+ if (!this.workbook) return FormulaValue.errorRef;
4945
+ try {
4946
+ return __privateMethod(this, _FormulaContext_instances, forSheet_fn).call(this, sheetName).resolveSpillRange(anchorRef);
4947
+ } catch {
4948
+ return FormulaValue.errorRef;
4949
+ }
4950
+ }
4931
4951
  getRangeBounds(startRef, endRef) {
4932
4952
  const s = parseCellRef(startRef);
4933
4953
  const e = parseCellRef(endRef);
@@ -5546,6 +5566,7 @@ function createWorkbookRecalcModel(workbook) {
5546
5566
  };
5547
5567
  }
5548
5568
  var MAX_ADOPTED_SPILL_CELLS = 262144;
5569
+ var resultOf = (fv2) => fv2.isBlank ? 0 : fv2.toObject();
5549
5570
  var normSheet = (s) => s.toUpperCase();
5550
5571
  var normRef = (r) => r.replace(/\$/g, "").toUpperCase();
5551
5572
  var keyOf = (sheet, ref) => `${normSheet(sheet)}!${normRef(ref)}`;
@@ -6206,7 +6227,7 @@ writeResult_fn = function(e) {
6206
6227
  if (!fv2.isArray) {
6207
6228
  __privateMethod(this, _RecalcEngine_instances, clearSpill_fn).call(this, anchorKey, changed);
6208
6229
  __privateGet(this, _model).setCellArrayRef?.(e.sheetName, e.ref, null);
6209
- const value2 = fv2.toObject();
6230
+ const value2 = resultOf(fv2);
6210
6231
  __privateMethod(this, _RecalcEngine_instances, writeCell_fn).call(this, e.sheetName, e.ref, value2, e.row, e.col);
6211
6232
  changed.push({ sheet: e.sheet, row: e.row, col: e.col });
6212
6233
  return { result: { sheet: e.sheetName, ref: e.ref, value: value2 }, changed };
@@ -6237,7 +6258,7 @@ writeResult_fn = function(e) {
6237
6258
  for (let dc = 0; dc < cols; dc++) {
6238
6259
  const r = e.row + dr, c = e.col + dc;
6239
6260
  const ref = cellRefFromRowCol(r, c);
6240
- __privateMethod(this, _RecalcEngine_instances, writeCell_fn).call(this, e.sheetName, ref, arr.get(dr, dc).toObject(), r, c);
6261
+ __privateMethod(this, _RecalcEngine_instances, writeCell_fn).call(this, e.sheetName, ref, resultOf(arr.get(dr, dc)), r, c);
6241
6262
  changed.push({ sheet: e.sheet, row: r, col: c });
6242
6263
  if (dr !== 0 || dc !== 0) {
6243
6264
  const cellKey2 = keyOf(e.sheet, ref);
@@ -6257,7 +6278,7 @@ writeResult_fn = function(e) {
6257
6278
  const spillRef = `${e.ref}:${cellRefFromRowCol(e.row + rows2 - 1, e.col + cols - 1)}`;
6258
6279
  __privateGet(this, _model).setCellArrayRef?.(e.sheetName, e.ref, spillRef);
6259
6280
  return {
6260
- result: { sheet: e.sheetName, ref: e.ref, value: arr.get(0, 0).toObject(), spill: { rows: rows2, cols } },
6281
+ result: { sheet: e.sheetName, ref: e.ref, value: resultOf(arr.get(0, 0)), spill: { rows: rows2, cols } },
6261
6282
  changed
6262
6283
  };
6263
6284
  };