Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(formula): token uppercase #1579

Merged
merged 2 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,85 @@ const TEST_WORKBOOK_DATA: IWorkbookData = {
sheets: {
sheet1: {
id: 'sheet1',
name: 'Main',
cellData: {
0: {
0: {
v: 1,
t: CellValueType.NUMBER,
},
1: {
v: 2,
t: CellValueType.NUMBER,
},
},
1: {
0: {
v: 3,
t: CellValueType.NUMBER,
},
1: {
v: 4,
t: CellValueType.NUMBER,
},
2: {
v: 'B2',
t: CellValueType.STRING,
},
3: {
v: 'R2C2',
t: CellValueType.STRING,
},
},
2: {
0: {
v: 1,
t: CellValueType.NUMBER,
},
1: {
v: ' ',
t: CellValueType.STRING,
},
2: {
v: 1.23,
t: CellValueType.NUMBER,
},
3: {
v: true,
t: CellValueType.BOOLEAN,
},
4: {
v: false,
t: CellValueType.BOOLEAN,
},
},
3: {
0: {
v: 0,
t: CellValueType.NUMBER,
},
1: {
v: '100',
t: CellValueType.STRING,
},
2: {
v: '2.34',
t: CellValueType.STRING,
},
3: {
v: 'test',
t: CellValueType.STRING,
},
4: {
v: -3,
t: CellValueType.NUMBER,
},
},
},
},
sheet2: {
id: 'sheet2',
name: 'Tool',
cellData: {
0: {
0: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,5 +164,15 @@ describe('Test indirect', () => {

expect((result as BaseValueObject).getValue()).toStrictEqual(4);
});

it('Cross tab sum', async () => {
const lexerNode = lexer.treeBuilder('=----sum(Tool!A1:A2)');

const astNode = astTreeBuilder.parse(lexerNode as LexerNode);

const result = interpreter.execute(astNode as BaseAstNode);

expect((result as BaseValueObject).getValue()).toStrictEqual(4);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -268,14 +268,16 @@ export class FunctionNodeFactory extends BaseAstNodeFactory {
}
const token = param.getToken();

const { tokenTrim, minusPrefixNode, atPrefixNode } = prefixHandler(token.trim().toUpperCase(), this._functionService, this._injector);
const { tokenTrim, minusPrefixNode, atPrefixNode } = prefixHandler(token.trim(), this._functionService, this._injector);

if (!Number.isNaN(Number(tokenTrim))) {
return ErrorNode.create(ErrorType.VALUE);
}

if (this._functionService.hasExecutor(tokenTrim)) {
const functionNode = this.create(tokenTrim);
const tokenTrimUpper = tokenTrim.toUpperCase();

if (this._functionService.hasExecutor(tokenTrimUpper)) {
const functionNode = this.create(tokenTrimUpper);
if (atPrefixNode) {
functionNode.setParent(atPrefixNode);
// return atPrefixNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export class ReferenceNodeFactory extends BaseAstNodeFactory {
// return true;
// }

const { tokenTrim, minusPrefixNode, atPrefixNode } = prefixHandler(tokenTrimPre.toUpperCase(), this._functionService, this._injector);
const { tokenTrim, minusPrefixNode, atPrefixNode } = prefixHandler(tokenTrimPre, this._functionService, this._injector);

if (!isLexerNode && tokenTrim.charAt(0) === '"' && tokenTrim.charAt(tokenTrim.length - 1) === '"') {
return;
Expand Down
Loading