-
-
Notifications
You must be signed in to change notification settings - Fork 665
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(formula): add functions, fix function calculation error (#1395)
* feat(formula): add row function * feat(formula): add column function * feat(formula): add rows, columns function * feat(formula): add index function * test(formula): index function handles row number,column number * feat(formula): add iserror, iserr functions * feat(formula): add iserr, islogical, isna, isnontext, isnumber, isref, istext, power functions * feat(formula): add mod function * feat(formula): add subtotal function, supports sum * test(formula): add test for SUM, AVERAGE, COUNT,COUNTA, MAX,MIN * feat(formula): add var,varp,var.s,var.p,vara,varpa functions * feat(formula): add std functions * feat(formula): subtotal product * fix(formula): edit formula description
- Loading branch information
Showing
133 changed files
with
6,936 additions
and
676 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
packages/engine-formula/src/engine/utils/__tests__/math-kit.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* Copyright 2023-present DreamNum Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { describe, expect, it } from 'vitest'; | ||
import { truncateNumber } from '../math-kit'; | ||
|
||
describe('Test math kit', () => { | ||
it('Function truncateNumber', () => { | ||
expect(truncateNumber('1234567890123456')).toBe(1234567890123450); | ||
expect(truncateNumber('123.4567890123456789')).toBe(123.456789012345); | ||
expect(truncateNumber('0.1234567890123456789')).toBe(0.123456789012345); | ||
expect(truncateNumber('1.234567890123456e+20')).toBe(123456789012345000000); | ||
expect(truncateNumber('123456789012345')).toBe(123456789012345); | ||
expect(truncateNumber('0.000000000000123456')).toBe(0.000000000000123456); | ||
}); | ||
}); |
27 changes: 27 additions & 0 deletions
27
packages/engine-formula/src/engine/utils/__tests__/object-covert.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* Copyright 2023-present DreamNum Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { describe, expect, it } from 'vitest'; | ||
|
||
import { convertTonNumber } from '../object-covert'; | ||
import { BooleanValueObject } from '../../value-object/primitive-object'; | ||
|
||
describe('Test object cover', () => { | ||
it('Function convertTonNumber', () => { | ||
expect(convertTonNumber(new BooleanValueObject(true)).getValue()).toBe(1); | ||
expect(convertTonNumber(new BooleanValueObject(false)).getValue()).toBe(0); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* Copyright 2023-present DreamNum Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import type { BaseValueObject } from '../value-object/base-value-object'; | ||
import { NumberValueObject } from '../value-object/primitive-object'; | ||
|
||
export function convertTonNumber(valueObject: BaseValueObject) { | ||
const currentValue = valueObject.getValue(); | ||
let result = 0; | ||
if (currentValue) { | ||
result = 1; | ||
} | ||
return new NumberValueObject(result, true); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.