Skip to content

Commit

Permalink
fix(formula): index row number
Browse files Browse the repository at this point in the history
  • Loading branch information
Dushusir committed Mar 18, 2024
1 parent 02016ab commit 254a505
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions packages/engine-formula/src/engine/utils/char-kit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@
* limitations under the License.
*/

/**
* Korean in Excel does not count as two characters. Here we calculate all Chinese, Japanese and Korean characters as two characters.
*
* ā -> 1
* ー -> 2
*
* @param str
* @returns
*/
export function charLenByte(str: string) {
let byteCount = 0;

Expand Down
4 changes: 2 additions & 2 deletions packages/engine-formula/src/functions/lookup/index/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ import { BaseFunction } from '../../base-function';

export class Index extends BaseFunction {
override calculate(reference: BaseValueObject, rowNum: BaseValueObject, columnNum?: BaseValueObject, areaNum?: BaseValueObject) {
if (reference == null || rowNum == null) {
if (reference == null) {
return ErrorValueObject.create(ErrorType.NA);
}

if (reference.isError()) {
return reference;
}

if (rowNum.isError()) {
if (rowNum?.isError()) {
return rowNum;
}

Expand Down

0 comments on commit 254a505

Please sign in to comment.