@visactor/vtable-sheet 1.22.1 → 1.22.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/es/index.d.ts CHANGED
@@ -2,5 +2,5 @@ import VTableSheet from './components/vtable-sheet';
2
2
  import type { ISheetDefine, IVTableSheetOptions } from './ts-types';
3
3
  import * as TYPES from './ts-types';
4
4
  import * as VTable from './vtable';
5
- export declare const version = "1.22.1";
5
+ export declare const version = "1.22.2";
6
6
  export { VTableSheet, TYPES, VTable, ISheetDefine, IVTableSheetOptions };
package/es/index.js CHANGED
@@ -6,7 +6,7 @@ import * as VTable from "./vtable";
6
6
 
7
7
  import { importStyles } from "./styles/style-manager";
8
8
 
9
- export const version = "1.22.1";
9
+ export const version = "1.22.2";
10
10
 
11
11
  importStyles();
12
12
 
package/es/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,2BAA2B,CAAC;AAEpD,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC;AAEhC,YAAY,EAAE,CAAC;AAIf,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,EAAqC,CAAC","file":"index.js","sourcesContent":["import VTableSheet from './components/vtable-sheet';\nimport type { ISheetDefine, IVTableSheetOptions } from './ts-types';\nimport * as TYPES from './ts-types';\nimport * as VTable from './vtable';\nimport { importStyles } from './styles/style-manager';\nexport const version = \"1.22.1\";\n// 导入样式\nimportStyles();\n/**\n * @namespace VTableSheet\n */\nexport { VTableSheet, TYPES, VTable, ISheetDefine, IVTableSheetOptions };\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,2BAA2B,CAAC;AAEpD,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC;AAEhC,YAAY,EAAE,CAAC;AAIf,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,EAAqC,CAAC","file":"index.js","sourcesContent":["import VTableSheet from './components/vtable-sheet';\nimport type { ISheetDefine, IVTableSheetOptions } from './ts-types';\nimport * as TYPES from './ts-types';\nimport * as VTable from './vtable';\nimport { importStyles } from './styles/style-manager';\nexport const version = \"1.22.2\";\n// 导入样式\nimportStyles();\n/**\n * @namespace VTableSheet\n */\nexport { VTableSheet, TYPES, VTable, ISheetDefine, IVTableSheetOptions };\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visactor/vtable-sheet",
3
- "version": "1.22.1",
3
+ "version": "1.22.2",
4
4
  "description": "Lightweight editable spreadsheet component based on VTable",
5
5
  "keywords": [
6
6
  "vtable-sheet",
@@ -42,9 +42,9 @@
42
42
  "@visactor/vscale": "~0.18.1",
43
43
  "@visactor/vdataset": "~0.18.1",
44
44
  "cssfontparser": "^1.2.1",
45
- "@visactor/vtable": "1.22.1",
46
- "@visactor/vtable-editors": "1.22.1",
47
- "@visactor/vtable-plugins": "1.22.1"
45
+ "@visactor/vtable-editors": "1.22.2",
46
+ "@visactor/vtable-plugins": "1.22.2",
47
+ "@visactor/vtable": "1.22.2"
48
48
  },
49
49
  "devDependencies": {
50
50
  "luxon": "*",
@@ -86,9 +86,9 @@
86
86
  "node-fetch": "2.6.7",
87
87
  "form-data": "~4.0.0",
88
88
  "axios": "^1.4.0",
89
+ "@internal/bundler": "0.0.1",
89
90
  "@internal/eslint-config": "0.0.1",
90
- "@internal/ts-config": "0.0.1",
91
- "@internal/bundler": "0.0.1"
91
+ "@internal/ts-config": "0.0.1"
92
92
  },
93
93
  "unpkg": "latest",
94
94
  "unpkgFiles": [
@@ -1,70 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: !0
5
- });
6
-
7
- const formula_engine_1 = require("../formula-engine");
8
-
9
- describe("Formula Case Correction", (() => {
10
- let engine;
11
- beforeEach((() => {
12
- engine = new formula_engine_1.FormulaEngine, engine.addSheet("Sheet1", [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ]);
13
- })), afterEach((() => {
14
- engine.release();
15
- })), test("should correct lowercase function names to uppercase", (() => {
16
- const result = engine.calculateFormula("=sum(a1:c1)");
17
- expect(result.value).toBe(6), expect(result.error).toBeUndefined();
18
- })), test("should correct mixed case function names to uppercase", (() => {
19
- const result = engine.calculateFormula("=SuM(a1:c1)");
20
- expect(result.value).toBe(6), expect(result.error).toBeUndefined();
21
- })), test("should correct lowercase cell references to uppercase", (() => {
22
- const result = engine.calculateFormula("=SUM(f4)");
23
- expect(result.value).toBe(0), expect(result.error).toBeUndefined();
24
- })), test("should correct mixed case cell references to uppercase", (() => {
25
- const result = engine.calculateFormula("=SUM(a1:b2)");
26
- expect(result.value).toBe(12), expect(result.error).toBeUndefined();
27
- })), test("should correct complex formula with multiple case issues", (() => {
28
- const result = engine.calculateFormula("=sum(a1:c1) + average(a2:c2)");
29
- expect(result.value).toBe(11), expect(result.error).toBeUndefined();
30
- })), test("should handle nested functions with case issues", (() => {
31
- const result = engine.calculateFormula("=sum(max(a1:b1), min(a2:b2))");
32
- expect(result.value).toBe(6), expect(result.error).toBeUndefined();
33
- })), test("should preserve string literals while correcting case", (() => {
34
- const result = engine.calculateFormula('=IF(a1>0, "lowercase", "UPPERCASE")');
35
- expect(result.value).toBe("lowercase"), expect(result.error).toBeUndefined();
36
- })), test("should correct formula when setting cell content", (() => {
37
- engine.setCellContent({
38
- sheet: "Sheet1",
39
- row: 0,
40
- col: 3
41
- }, "=sum(a1:c1)");
42
- const result = engine.getCellValue({
43
- sheet: "Sheet1",
44
- row: 0,
45
- col: 3
46
- });
47
- expect(result.value).toBe(6), expect(result.error).toBeUndefined();
48
- })), test("should handle single letter column references", (() => {
49
- const result = engine.calculateFormula("=sum(f1:h1)");
50
- expect(result.value).toBe(0), expect(result.error).toBeUndefined();
51
- })), test("should handle multi-letter column references", (() => {
52
- const result = engine.calculateFormula("=sum(aa1:ab1)");
53
- expect(result.error).toBeUndefined();
54
- })), test("should not affect non-formula strings", (() => {
55
- const result = engine.calculateFormula("just a regular string");
56
- expect(result.value).toBe("just a regular string"), expect(result.error).toBeUndefined();
57
- })), test("should handle empty formula", (() => {
58
- const result = engine.calculateFormula("=");
59
- expect(result.value).toBe(""), expect(result.error).toBeUndefined();
60
- })), test("should preserve sheet names while correcting cell references", (() => {
61
- engine.addSheet("Sheet2", [ [ 10, 20 ], [ 30, 40 ] ]);
62
- const result = engine.calculateFormula("=sum(sheet2!a1:b1)");
63
- expect(result.value).toBe(30), expect(result.error).toBeUndefined();
64
- })), test("should preserve mixed case sheet names", (() => {
65
- engine.addSheet("MySheet", [ [ 5, 15 ], [ 25, 35 ] ]);
66
- const result = engine.calculateFormula("=sum(MySheet!a1:b1)");
67
- expect(result.value).toBe(20), expect(result.error).toBeUndefined();
68
- }));
69
- }));
70
- //# sourceMappingURL=formula-case-correction.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/formula/__tests__/formula-case-correction.test.ts"],"names":[],"mappings":";;AAAA,sDAAkD;AAElD,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE;IACvC,IAAI,MAAqB,CAAC;IAE1B,UAAU,CAAC,GAAG,EAAE;QACd,MAAM,GAAG,IAAI,8BAAa,EAAE,CAAC;QAC7B,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE;YACxB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;YACT,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;YACT,CA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AC,CAAC;IAEH,IAAI,CAAC,8DAA8D,EAAE,GAAG,EAAE;QAExE,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE;YACxB,CAAC,EAAE,EAAE,EAAE,CAAC;YACR,CAAC,EAAE,EAAE,EAAE,CAAC;SACT,CAAC,CAAC;QAEH,MAAM,MAAM,GAAG,MAAM,CAAC,gBAAgB,CAAC,oBAAoB,CAAC,CAAC;QAC7D,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC9B,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,aAAa,EAAE,CAAC;IACvC,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,wCAAwC,EAAE,GAAG,EAAE;QAElD,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAE;YACzB,CAAC,CAAC,EAAE,EAAE,CAAC;YACP,CAAC,EAAE,EAAE,EAAE,CAAC;SACT,CAAC,CAAC;QAEH,MAAM,MAAM,GAAG,MAAM,CAAC,gBAAgB,CAAC,qBAAqB,CAAC,CAAC;QAC9D,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC9B,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,aAAa,EAAE,CAAC;IACvC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","file":"formula-case-correction.test.js","sourcesContent":["import { FormulaEngine } from '../formula-engine';\n\ndescribe('Formula Case Correction', () => {\n let engine: FormulaEngine;\n\n beforeEach(() => {\n engine = new FormulaEngine();\n engine.addSheet('Sheet1', [\n [1, 2, 3],\n [4, 5, 6],\n [7, 8, 9]\n ]);\n });\n\n afterEach(() => {\n engine.release();\n });\n\n test('should correct lowercase function names to uppercase', () => {\n const result = engine.calculateFormula('=sum(a1:c1)');\n expect(result.value).toBe(6); // 1+2+3\n expect(result.error).toBeUndefined();\n });\n\n test('should correct mixed case function names to uppercase', () => {\n const result = engine.calculateFormula('=SuM(a1:c1)');\n expect(result.value).toBe(6); // 1+2+3\n expect(result.error).toBeUndefined();\n });\n\n test('should correct lowercase cell references to uppercase', () => {\n const result = engine.calculateFormula('=SUM(f4)');\n // F4 doesn't exist in our test data, so it should return 0\n expect(result.value).toBe(0);\n expect(result.error).toBeUndefined();\n });\n\n test('should correct mixed case cell references to uppercase', () => {\n const result = engine.calculateFormula('=SUM(a1:b2)');\n expect(result.value).toBe(12); // 1+2+4+5\n expect(result.error).toBeUndefined();\n });\n\n test('should correct complex formula with multiple case issues', () => {\n const result = engine.calculateFormula('=sum(a1:c1) + average(a2:c2)');\n expect(result.value).toBe(11); // (1+2+3) + (5) = 6 + 5 = 11\n expect(result.error).toBeUndefined();\n });\n\n test('should handle nested functions with case issues', () => {\n const result = engine.calculateFormula('=sum(max(a1:b1), min(a2:b2))');\n expect(result.value).toBe(6); // max(1,2) + min(4,5) = 2 + 4 = 6 (min of 4,5 is 4)\n expect(result.error).toBeUndefined();\n });\n\n test('should preserve string literals while correcting case', () => {\n const result = engine.calculateFormula('=IF(a1>0, \"lowercase\", \"UPPERCASE\")');\n expect(result.value).toBe('lowercase');\n expect(result.error).toBeUndefined();\n });\n\n test('should correct formula when setting cell content', () => {\n engine.setCellContent({ sheet: 'Sheet1', row: 0, col: 3 }, '=sum(a1:c1)');\n const result = engine.getCellValue({ sheet: 'Sheet1', row: 0, col: 3 });\n expect(result.value).toBe(6); // 1+2+3\n expect(result.error).toBeUndefined();\n });\n\n test('should handle single letter column references', () => {\n const result = engine.calculateFormula('=sum(f1:h1)');\n // F1, G1, H1 don't exist, so should return 0\n expect(result.value).toBe(0);\n expect(result.error).toBeUndefined();\n });\n\n test('should handle multi-letter column references', () => {\n // Test with AA, AB, etc. (though they don't exist in our test data)\n const result = engine.calculateFormula('=sum(aa1:ab1)');\n // The engine might be treating AA1:AB1 as a valid range even if it doesn't exist\n // Let's just verify it doesn't crash and returns some value\n expect(result.error).toBeUndefined();\n });\n\n test('should not affect non-formula strings', () => {\n const result = engine.calculateFormula('just a regular string');\n expect(result.value).toBe('just a regular string');\n expect(result.error).toBeUndefined();\n });\n\n test('should handle empty formula', () => {\n const result = engine.calculateFormula('=');\n // Empty formula should return empty value, not an error\n expect(result.value).toBe('');\n expect(result.error).toBeUndefined();\n });\n\n test('should preserve sheet names while correcting cell references', () => {\n // Add another sheet for testing\n engine.addSheet('Sheet2', [\n [10, 20],\n [30, 40]\n ]);\n\n const result = engine.calculateFormula('=sum(sheet2!a1:b1)');\n expect(result.value).toBe(30); // 10 + 20\n expect(result.error).toBeUndefined();\n });\n\n test('should preserve mixed case sheet names', () => {\n // Add a sheet with mixed case name\n engine.addSheet('MySheet', [\n [5, 15],\n [25, 35]\n ]);\n\n const result = engine.calculateFormula('=sum(MySheet!a1:b1)');\n expect(result.value).toBe(20); // 5 + 15\n expect(result.error).toBeUndefined();\n });\n});\n"]}
@@ -1,64 +0,0 @@
1
- import { FormulaEngine } from "../formula-engine";
2
-
3
- describe("Formula Case Correction", (() => {
4
- let engine;
5
- beforeEach((() => {
6
- engine = new FormulaEngine, engine.addSheet("Sheet1", [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ]);
7
- })), afterEach((() => {
8
- engine.release();
9
- })), test("should correct lowercase function names to uppercase", (() => {
10
- const result = engine.calculateFormula("=sum(a1:c1)");
11
- expect(result.value).toBe(6), expect(result.error).toBeUndefined();
12
- })), test("should correct mixed case function names to uppercase", (() => {
13
- const result = engine.calculateFormula("=SuM(a1:c1)");
14
- expect(result.value).toBe(6), expect(result.error).toBeUndefined();
15
- })), test("should correct lowercase cell references to uppercase", (() => {
16
- const result = engine.calculateFormula("=SUM(f4)");
17
- expect(result.value).toBe(0), expect(result.error).toBeUndefined();
18
- })), test("should correct mixed case cell references to uppercase", (() => {
19
- const result = engine.calculateFormula("=SUM(a1:b2)");
20
- expect(result.value).toBe(12), expect(result.error).toBeUndefined();
21
- })), test("should correct complex formula with multiple case issues", (() => {
22
- const result = engine.calculateFormula("=sum(a1:c1) + average(a2:c2)");
23
- expect(result.value).toBe(11), expect(result.error).toBeUndefined();
24
- })), test("should handle nested functions with case issues", (() => {
25
- const result = engine.calculateFormula("=sum(max(a1:b1), min(a2:b2))");
26
- expect(result.value).toBe(6), expect(result.error).toBeUndefined();
27
- })), test("should preserve string literals while correcting case", (() => {
28
- const result = engine.calculateFormula('=IF(a1>0, "lowercase", "UPPERCASE")');
29
- expect(result.value).toBe("lowercase"), expect(result.error).toBeUndefined();
30
- })), test("should correct formula when setting cell content", (() => {
31
- engine.setCellContent({
32
- sheet: "Sheet1",
33
- row: 0,
34
- col: 3
35
- }, "=sum(a1:c1)");
36
- const result = engine.getCellValue({
37
- sheet: "Sheet1",
38
- row: 0,
39
- col: 3
40
- });
41
- expect(result.value).toBe(6), expect(result.error).toBeUndefined();
42
- })), test("should handle single letter column references", (() => {
43
- const result = engine.calculateFormula("=sum(f1:h1)");
44
- expect(result.value).toBe(0), expect(result.error).toBeUndefined();
45
- })), test("should handle multi-letter column references", (() => {
46
- const result = engine.calculateFormula("=sum(aa1:ab1)");
47
- expect(result.error).toBeUndefined();
48
- })), test("should not affect non-formula strings", (() => {
49
- const result = engine.calculateFormula("just a regular string");
50
- expect(result.value).toBe("just a regular string"), expect(result.error).toBeUndefined();
51
- })), test("should handle empty formula", (() => {
52
- const result = engine.calculateFormula("=");
53
- expect(result.value).toBe(""), expect(result.error).toBeUndefined();
54
- })), test("should preserve sheet names while correcting cell references", (() => {
55
- engine.addSheet("Sheet2", [ [ 10, 20 ], [ 30, 40 ] ]);
56
- const result = engine.calculateFormula("=sum(sheet2!a1:b1)");
57
- expect(result.value).toBe(30), expect(result.error).toBeUndefined();
58
- })), test("should preserve mixed case sheet names", (() => {
59
- engine.addSheet("MySheet", [ [ 5, 15 ], [ 25, 35 ] ]);
60
- const result = engine.calculateFormula("=sum(MySheet!a1:b1)");
61
- expect(result.value).toBe(20), expect(result.error).toBeUndefined();
62
- }));
63
- }));
64
- //# sourceMappingURL=formula-case-correction.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/formula/__tests__/formula-case-correction.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE;IACvC,IAAI,MAAqB,CAAC;IAE1B,UAAU,CAAC,GAAG,EAAE;QACd,MAAM,GAAG,IAAI,aAAa,EAAE,CAAC;QAC7B,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE;YACxB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;YACT,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;YACT,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;SACV,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,CAAC,OAAO,EAAE,CAAC;IACnB,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,sDAAsD,EAAE,GAAG,EAAE;QAChE,MAAM,MAAM,GAAG,MAAM,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;QACtD,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC7B,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,aAAa,EAAE,CAAC;IACvC,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,uDAAuD,EAAE,GAAG,EAAE;QACjE,MAAM,MAAM,GAAG,MAAM,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;QACtD,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC7B,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,aAAa,EAAE,CAAC;IACvC,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,uDAAuD,EAAE,GAAG,EAA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AM,CAAC,KAAK,CAAC,CAAC,aAAa,EAAE,CAAC;IACvC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","file":"formula-case-correction.test.js","sourcesContent":["import { FormulaEngine } from '../formula-engine';\n\ndescribe('Formula Case Correction', () => {\n let engine: FormulaEngine;\n\n beforeEach(() => {\n engine = new FormulaEngine();\n engine.addSheet('Sheet1', [\n [1, 2, 3],\n [4, 5, 6],\n [7, 8, 9]\n ]);\n });\n\n afterEach(() => {\n engine.release();\n });\n\n test('should correct lowercase function names to uppercase', () => {\n const result = engine.calculateFormula('=sum(a1:c1)');\n expect(result.value).toBe(6); // 1+2+3\n expect(result.error).toBeUndefined();\n });\n\n test('should correct mixed case function names to uppercase', () => {\n const result = engine.calculateFormula('=SuM(a1:c1)');\n expect(result.value).toBe(6); // 1+2+3\n expect(result.error).toBeUndefined();\n });\n\n test('should correct lowercase cell references to uppercase', () => {\n const result = engine.calculateFormula('=SUM(f4)');\n // F4 doesn't exist in our test data, so it should return 0\n expect(result.value).toBe(0);\n expect(result.error).toBeUndefined();\n });\n\n test('should correct mixed case cell references to uppercase', () => {\n const result = engine.calculateFormula('=SUM(a1:b2)');\n expect(result.value).toBe(12); // 1+2+4+5\n expect(result.error).toBeUndefined();\n });\n\n test('should correct complex formula with multiple case issues', () => {\n const result = engine.calculateFormula('=sum(a1:c1) + average(a2:c2)');\n expect(result.value).toBe(11); // (1+2+3) + (5) = 6 + 5 = 11\n expect(result.error).toBeUndefined();\n });\n\n test('should handle nested functions with case issues', () => {\n const result = engine.calculateFormula('=sum(max(a1:b1), min(a2:b2))');\n expect(result.value).toBe(6); // max(1,2) + min(4,5) = 2 + 4 = 6 (min of 4,5 is 4)\n expect(result.error).toBeUndefined();\n });\n\n test('should preserve string literals while correcting case', () => {\n const result = engine.calculateFormula('=IF(a1>0, \"lowercase\", \"UPPERCASE\")');\n expect(result.value).toBe('lowercase');\n expect(result.error).toBeUndefined();\n });\n\n test('should correct formula when setting cell content', () => {\n engine.setCellContent({ sheet: 'Sheet1', row: 0, col: 3 }, '=sum(a1:c1)');\n const result = engine.getCellValue({ sheet: 'Sheet1', row: 0, col: 3 });\n expect(result.value).toBe(6); // 1+2+3\n expect(result.error).toBeUndefined();\n });\n\n test('should handle single letter column references', () => {\n const result = engine.calculateFormula('=sum(f1:h1)');\n // F1, G1, H1 don't exist, so should return 0\n expect(result.value).toBe(0);\n expect(result.error).toBeUndefined();\n });\n\n test('should handle multi-letter column references', () => {\n // Test with AA, AB, etc. (though they don't exist in our test data)\n const result = engine.calculateFormula('=sum(aa1:ab1)');\n // The engine might be treating AA1:AB1 as a valid range even if it doesn't exist\n // Let's just verify it doesn't crash and returns some value\n expect(result.error).toBeUndefined();\n });\n\n test('should not affect non-formula strings', () => {\n const result = engine.calculateFormula('just a regular string');\n expect(result.value).toBe('just a regular string');\n expect(result.error).toBeUndefined();\n });\n\n test('should handle empty formula', () => {\n const result = engine.calculateFormula('=');\n // Empty formula should return empty value, not an error\n expect(result.value).toBe('');\n expect(result.error).toBeUndefined();\n });\n\n test('should preserve sheet names while correcting cell references', () => {\n // Add another sheet for testing\n engine.addSheet('Sheet2', [\n [10, 20],\n [30, 40]\n ]);\n\n const result = engine.calculateFormula('=sum(sheet2!a1:b1)');\n expect(result.value).toBe(30); // 10 + 20\n expect(result.error).toBeUndefined();\n });\n\n test('should preserve mixed case sheet names', () => {\n // Add a sheet with mixed case name\n engine.addSheet('MySheet', [\n [5, 15],\n [25, 35]\n ]);\n\n const result = engine.calculateFormula('=sum(MySheet!a1:b1)');\n expect(result.value).toBe(20); // 5 + 15\n expect(result.error).toBeUndefined();\n });\n});\n"]}