Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

feat(formula): supplement ISEMAIL/ISURL/ENCODEURL formula (#3990)

wpxp123456224e88c4d93c
diff --git a/packages/core/src/common/url.ts b/packages/core/src/common/url.ts
index 9fb831ffcd..e3931f5282 100644
--- a/packages/core/src/common/url.ts
+++ b/packages/core/src/common/url.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-const topLevelDomainSet = new Set([
+export const topLevelDomainSet = new Set([
'ac',
'ad',
'ae',
diff --git a/packages/core/src/shared/tools.ts b/packages/core/src/shared/tools.ts
index 1165d8501f..b3abf6bd37 100644
--- a/packages/core/src/shared/tools.ts
+++ b/packages/core/src/shared/tools.ts
@@ -18,7 +18,7 @@ import type { IStyleData } from '../types/interfaces';
import type { IKeyValue, Nullable } from './types';
import { customAlphabet, nanoid } from 'nanoid';
-import { isLegalUrl, normalizeUrl } from '../common/url';
+import { isLegalUrl, normalizeUrl, topLevelDomainSet } from '../common/url';
const rmsPrefix = /^-ms-/;
const rDashAlpha = /-([a-z])/g;
@@ -456,6 +456,10 @@ export class Tools {
return normalizeUrl(url);
}
+ static topLevelDomainCombiningString() {
+ return [...topLevelDomainSet].join('|');
+ }
+
static itCount(count: number): Function {
return (callback: Function) => {
for (let i = 0; i < count; i++) {
diff --git a/packages/engine-formula/src/functions/information/function-map.ts b/packages/engine-formula/src/functions/information/function-map.ts
index eb821887bd..6ec0bb781b 100644
--- a/packages/engine-formula/src/functions/information/function-map.ts
+++ b/packages/engine-formula/src/functions/information/function-map.ts
@@ -19,6 +19,7 @@ import { ErrorType } from './error-type';
import { FUNCTION_NAMES_INFORMATION } from './function-names';
import { Isblank } from './isblank';
import { Isdate } from './isdate';
+import { Isemail } from './isemail';
import { Iserr } from './iserr';
import { Iserror } from './iserror';
import { Iseven } from './iseven/iseven';
@@ -30,6 +31,7 @@ import { Isnumber } from './isnumber';
import { Isodd } from './isodd/isodd';
import { Isref } from './isref';
import { Istext } from './istext';
+import { Isurl } from './isurl';
import { N } from './n';
import { Na } from './na';
import { Sheet } from './sheet';
@@ -41,6 +43,7 @@ export const functionInformation = [
[ErrorType, FUNCTION_NAMES_INFORMATION.ERROR_TYPE],
[Isblank, FUNCTION_NAMES_INFORMATION.ISBLANK],
[Isdate, FUNCTION_NAMES_INFORMATION.ISDATE],
+ [Isemail, FUNCTION_NAMES_INFORMATION.ISEMAIL],
[Iserr, FUNCTION_NAMES_INFORMATION.ISERR],
[Iserror, FUNCTION_NAMES_INFORMATION.ISERROR],
[Iseven, FUNCTION_NAMES_INFORMATION.ISEVEN],
@@ -52,6 +55,7 @@ export const functionInformation = [
[Isodd, FUNCTION_NAMES_INFORMATION.ISODD],
[Isref, FUNCTION_NAMES_INFORMATION.ISREF],
[Istext, FUNCTION_NAMES_INFORMATION.ISTEXT],
+ [Isurl, FUNCTION_NAMES_INFORMATION.ISURL],
[N, FUNCTION_NAMES_INFORMATION.N],
[Na, FUNCTION_NAMES_INFORMATION.NA],
[Sheet, FUNCTION_NAMES_INFORMATION.SHEET],
diff --git a/packages/engine-formula/src/functions/information/function-names.ts b/packages/engine-formula/src/functions/information/function-names.ts
index b165996436..2b4e40e914 100644
--- a/packages/engine-formula/src/functions/information/function-names.ts
+++ b/packages/engine-formula/src/functions/information/function-names.ts
@@ -20,6 +20,7 @@ export enum FUNCTION_NAMES_INFORMATION {
INFO = 'INFO',
ISBLANK = 'ISBLANK',
ISDATE = 'ISDATE',
+ ISEMAIL = 'ISEMAIL',
ISERR = 'ISERR',
ISERROR = 'ISERROR',
ISEVEN = 'ISEVEN',
@@ -32,6 +33,7 @@ export enum FUNCTION_NAMES_INFORMATION {
ISOMITTED = 'ISOMITTED',
ISREF = 'ISREF',
ISTEXT = 'ISTEXT',
+ ISURL = 'ISURL',
N = 'N',
NA = 'NA',
SHEET = 'SHEET',
diff --git a/packages/engine-formula/src/functions/information/isemail/__tests__/index.spec.ts b/packages/engine-formula/src/functions/information/isemail/__tests__/index.spec.ts
new file mode 100644
index 0000000000..196ca4e080
--- /dev/null
+++ b/packages/engine-formula/src/functions/information/isemail/__tests__/index.spec.ts
@@ -0,0 +1,101 @@
+/**
+ * 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 { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_INFORMATION } from '../../function-names';
+import { Isemail } from '../index';
+
+describe('Test isemail function', () => {
+ const testFunction = new Isemail(FUNCTION_NAMES_INFORMATION.ISEMAIL);
+
+ describe('Isemail', () => {
+ it('value is normal', () => {
+ const value = StringValueObject.create('[email protected]');
+ const result = testFunction.calculate(value);
+ expect(getObjectValue(result)).toBe(true);
+ });
+
+ it('value is number', () => {
+ const value = NumberValueObject.create(1);
+ const result = testFunction.calculate(value);
+ expect(getObjectValue(result)).toBe(false);
+ });
+
+ it('value is blank cell', () => {
+ const value = NullValueObject.create();
+ const result = testFunction.calculate(value);
+ expect(getObjectValue(result)).toBe(false);
+ });
+
+ it('value is boolean', () => {
+ const value = BooleanValueObject.create(true);
+ const result = testFunction.calculate(value);
+ expect(getObjectValue(result)).toBe(false);
+ });
+
+ it('value is error', () => {
+ const value = ErrorValueObject.create(ErrorType.NAME);
+ const result = testFunction.calculate(value);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+ });
+
+ it('value array', () => {
+ const value = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, 2],
+ ]),
+ rowCount: 1,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(value);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+
+ const value2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [`${'abcde'.repeat(50)}@univer.com`],
+ ]),
+ rowCount: 1,
+ columnCount: 1,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result2 = testFunction.calculate(value2);
+ expect(getObjectValue(result2)).toBe(false);
+ });
+
+ it('More test', () => {
+ const value = StringValueObject.create('[email protected]');
+ const result = testFunction.calculate(value);
+ expect(getObjectValue(result)).toBe(true);
+
+ const value2 = StringValueObject.create('[email protected]');
+ const result2 = testFunction.calculate(value2);
+ expect(getObjectValue(result2)).toBe(true);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/information/isemail/index.ts b/packages/engine-formula/src/functions/information/isemail/index.ts
new file mode 100644
index 0000000000..61dc99a6be
--- /dev/null
+++ b/packages/engine-formula/src/functions/information/isemail/index.ts
@@ -0,0 +1,66 @@
+/**
+ * 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 { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+import { Tools } from '@univerjs/core';
+import { ErrorType } from '../../../basics/error-type';
+import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
+import { BooleanValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+
+export class Isemail extends BaseFunction {
+ override minParams = 1;
+
+ override maxParams = 1;
+
+ override calculate(value: BaseValueObject): BaseValueObject {
+ let _value = value;
+
+ if (_value.isArray()) {
+ const rowCount = (_value as ArrayValueObject).getRowCount();
+ const columnCount = (_value as ArrayValueObject).getColumnCount();
+
+ if (rowCount > 1 || columnCount > 1) {
+ return ErrorValueObject.create(ErrorType.VALUE);
+ }
+
+ _value = (_value as ArrayValueObject).get(0, 0) as BaseValueObject;
+ }
+
+ if (_value.isError()) {
+ return _value;
+ }
+
+ if (_value.isNull() || _value.isBoolean() || _value.isNumber()) {
+ return BooleanValueObject.create(false);
+ }
+
+ const val = `${_value.getValue()}`;
+
+ if (val.length > 254) {
+ return BooleanValueObject.create(false);
+ }
+
+ const topLevelDomain = Tools.topLevelDomainCombiningString();
+
+ const reg = new RegExp(
+ `^(?:[\\w+-]+\\.)*[\\w+-]+@[a-z0-9_-]+(?:\\.[a-z0-9_-]+)*\\.(?:${topLevelDomain})$`,
+ 'i'
+ );
+
+ return BooleanValueObject.create(reg.test(val));
+ }
+}
diff --git a/packages/engine-formula/src/functions/information/isurl/__tests__/index.spec.ts b/packages/engine-formula/src/functions/information/isurl/__tests__/index.spec.ts
new file mode 100644
index 0000000000..3912f47127
--- /dev/null
+++ b/packages/engine-formula/src/functions/information/isurl/__tests__/index.spec.ts
@@ -0,0 +1,91 @@
+/**
+ * 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 { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_INFORMATION } from '../../function-names';
+import { Isurl } from '../index';
+
+describe('Test isurl function', () => {
+ const testFunction = new Isurl(FUNCTION_NAMES_INFORMATION.ISURL);
+
+ describe('Isurl', () => {
+ it('value is normal', () => {
+ const value = StringValueObject.create('univer.ai');
+ const result = testFunction.calculate(value);
+ expect(getObjectValue(result)).toBe(true);
+ });
+
+ it('value is number', () => {
+ const value = NumberValueObject.create(1);
+ const result = testFunction.calculate(value);
+ expect(getObjectValue(result)).toBe(false);
+ });
+
+ it('value is blank cell', () => {
+ const value = NullValueObject.create();
+ const result = testFunction.calculate(value);
+ expect(getObjectValue(result)).toBe(false);
+ });
+
+ it('value is boolean', () => {
+ const value = BooleanValueObject.create(true);
+ const result = testFunction.calculate(value);
+ expect(getObjectValue(result)).toBe(false);
+ });
+
+ it('value is error', () => {
+ const value = ErrorValueObject.create(ErrorType.NAME);
+ const result = testFunction.calculate(value);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+ });
+
+ it('value array', () => {
+ const value = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, 2],
+ ]),
+ rowCount: 1,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(value);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+
+ const value2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [`${'abcde'.repeat(200)}.univer.ai`],
+ ]),
+ rowCount: 1,
+ columnCount: 1,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result2 = testFunction.calculate(value2);
+ expect(getObjectValue(result2)).toBe(false);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/information/isurl/index.ts b/packages/engine-formula/src/functions/information/isurl/index.ts
new file mode 100644
index 0000000000..18c2b6d876
--- /dev/null
+++ b/packages/engine-formula/src/functions/information/isurl/index.ts
@@ -0,0 +1,66 @@
+/**
+ * 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 { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+import { Tools } from '@univerjs/core';
+import { ErrorType } from '../../../basics/error-type';
+import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
+import { BooleanValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+
+export class Isurl extends BaseFunction {
+ override minParams = 1;
+
+ override maxParams = 1;
+
+ override calculate(value: BaseValueObject): BaseValueObject {
+ let _value = value;
+
+ if (_value.isArray()) {
+ const rowCount = (_value as ArrayValueObject).getRowCount();
+ const columnCount = (_value as ArrayValueObject).getColumnCount();
+
+ if (rowCount > 1 || columnCount > 1) {
+ return ErrorValueObject.create(ErrorType.VALUE);
+ }
+
+ _value = (_value as ArrayValueObject).get(0, 0) as BaseValueObject;
+ }
+
+ if (_value.isError()) {
+ return _value;
+ }
+
+ if (_value.isNull() || _value.isBoolean() || _value.isNumber()) {
+ return BooleanValueObject.create(false);
+ }
+
+ const val = `${_value.getValue()}`.replace(/^\s+|\s+$/g, '');
+
+ if (val.length > 1000) {
+ return BooleanValueObject.create(false);
+ }
+
+ const topLevelDomain = Tools.topLevelDomainCombiningString();
+
+ const reg = new RegExp(
+ `^(?:(?:https?|s?ftp|ftps|nfs|ssh)://+[a-z0-9_-]+(?:\\.[a-z0-9_-]+)*(?::[0-9]+)?(?:/(?:[A-Za-z0-9\\-._~!$&'()*+,;=:@]|%[A-Fa-f0-9]{2})*)*/?(?:[?#]\\S*)?|[a-z0-9_-]+(?:\\.[a-z0-9_-]+)*\\.(?:${topLevelDomain})(?::[0-9]+)?(?:/(?:[A-Za-z0-9\\-._~!$&'()*+,;=:@]|%[A-Fa-f0-9]{2})*)*/?(?:[?#]\\S*)?|mailto:(?:[\\w+-]+\\.)*[\\w+-]+@[a-z0-9_-]+(?:\\.[a-z0-9_-]+)*\\.(?:${topLevelDomain})|(?:news|aim):[%a-z0-9$_\\.+!*(),;/?#:@&~=-]+)$`,
+ 'i'
+ );
+
+ return BooleanValueObject.create(reg.test(val));
+ }
+}
diff --git a/packages/engine-formula/src/functions/web/encodeurl/__tests__/index.spec.ts b/packages/engine-formula/src/functions/web/encodeurl/__tests__/index.spec.ts
new file mode 100644
index 0000000000..af537aba71
--- /dev/null
+++ b/packages/engine-formula/src/functions/web/encodeurl/__tests__/index.spec.ts
@@ -0,0 +1,93 @@
+/**
+ * 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 { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_WEB } from '../../function-names';
+import { Encodeurl } from '../index';
+
+describe('Test encodeurl function', () => {
+ const testFunction = new Encodeurl(FUNCTION_NAMES_WEB.ENCODEURL);
+
+ describe('Encodeurl', () => {
+ it('value is normal', () => {
+ const text = StringValueObject.create('https://univer.ai/');
+ const result = testFunction.calculate(text);
+ expect(getObjectValue(result)).toBe('https%3A%2F%2Funiver.ai%2F');
+ });
+
+ it('value is number', () => {
+ const text = NumberValueObject.create(1);
+ const result = testFunction.calculate(text);
+ expect(getObjectValue(result)).toBe('1');
+ });
+
+ it('value is blank cell', () => {
+ const text = NullValueObject.create();
+ const result = testFunction.calculate(text);
+ expect(getObjectValue(result)).toBe('');
+ });
+
+ it('value is boolean', () => {
+ const text = BooleanValueObject.create(true);
+ const result = testFunction.calculate(text);
+ expect(getObjectValue(result)).toBe('TRUE');
+ });
+
+ it('value is error', () => {
+ const text = ErrorValueObject.create(ErrorType.NAME);
+ const result = testFunction.calculate(text);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+ });
+
+ it('value array', () => {
+ const text = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, 2],
+ ]),
+ rowCount: 1,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(text);
+ expect(getObjectValue(result)).toStrictEqual([
+ ['1', '2'],
+ ]);
+
+ const text2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ ['hello, world!'],
+ ]),
+ rowCount: 1,
+ columnCount: 1,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result2 = testFunction.calculate(text2);
+ expect(getObjectValue(result2)).toBe('hello%2C%20world%21');
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/web/encodeurl/index.ts b/packages/engine-formula/src/functions/web/encodeurl/index.ts
new file mode 100644
index 0000000000..610312e5e4
--- /dev/null
+++ b/packages/engine-formula/src/functions/web/encodeurl/index.ts
@@ -0,0 +1,53 @@
+/**
+ * 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 { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+import type { BaseValueObject } from '../../../engine/value-object/base-value-object';
+import { getTextValueOfNumberFormat } from '../../../basics/format';
+import { StringValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+
+export class Encodeurl extends BaseFunction {
+ override minParams = 1;
+
+ override maxParams = 1;
+
+ override calculate(text: BaseValueObject): BaseValueObject {
+ if (text.isArray()) {
+ const resultArray = (text as ArrayValueObject).mapValue((textObject) => this._handleSingleObject(textObject));
+
+ if ((resultArray as ArrayValueObject).getRowCount() === 1 && (resultArray as ArrayValueObject).getColumnCount() === 1) {
+ return (resultArray as ArrayValueObject).get(0, 0) as BaseValueObject;
+ }
+
+ return resultArray;
+ }
+
+ return this._handleSingleObject(text);
+ }
+
+ private _handleSingleObject(text: BaseValueObject): BaseValueObject {
+ if (text.isError()) {
+ return text;
+ }
+
+ const textValue = getTextValueOfNumberFormat(text);
+
+ const result = encodeURIComponent(textValue).replace(/[!~'()*]/g, (c) => `%${c.charCodeAt(0).toString(16).toLocaleUpperCase()}`);
+
+ return StringValueObject.create(result);
+ }
+}
diff --git a/packages/engine-formula/src/functions/web/function-map.ts b/packages/engine-formula/src/functions/web/function-map.ts
index 6f78796186..28e32bcc2c 100644
--- a/packages/engine-formula/src/functions/web/function-map.ts
+++ b/packages/engine-formula/src/functions/web/function-map.ts
@@ -14,4 +14,9 @@
* limitations under the License.
*/
-export const functionWeb = [];
+import { Encodeurl } from './encodeurl';
+import { FUNCTION_NAMES_WEB } from './function-names';
+
+export const functionWeb = [
+ [Encodeurl, FUNCTION_NAMES_WEB.ENCODEURL],
+];
diff --git a/packages/sheets-formula-ui/src/locale/function-list/information/en-US.ts b/packages/sheets-formula-ui/src/locale/function-list/information/en-US.ts
index 41fa6897c3..38036ad6e5 100644
--- a/packages/sheets-formula-ui/src/locale/function-list/information/en-US.ts
+++ b/packages/sheets-formula-ui/src/locale/function-list/information/en-US.ts
@@ -82,6 +82,19 @@ export default {
value: { name: 'value', detail: 'The value to be verified as a date.' },
},
},
+ ISEMAIL: {
+ description: 'Checks if a value is a valid email address',
+ abstract: 'Checks if a value is a valid email address',
+ links: [
+ {
+ title: 'Instruction',
+ url: 'https://support.google.com/docs/answer/3256503?hl=en&sjid=2155433538747546473-AP',
+ },
+ ],
+ functionParameter: {
+ value: { name: 'value', detail: 'The value to be verified as an email address.' },
+ },
+ },
ISERR: {
description: 'Returns TRUE if the value is any error value except #N/A',
abstract: 'Returns TRUE if the value is any error value except #N/A',
@@ -239,6 +252,19 @@ export default {
value: { name: 'value', detail: 'The value that you want tested. The value argument can be a blank (empty cell), error, logical value, text, number, or reference value, or a name referring to any of these.' },
},
},
+ ISURL: {
+ description: 'Checks whether a value is a valid URL.',
+ abstract: 'Checks whether a value is a valid URL.',
+ links: [
+ {
+ title: 'Instruction',
+ url: 'https://support.google.com/docs/answer/3256501?hl=en&sjid=7312884847858065932-AP',
+ },
+ ],
+ functionParameter: {
+ value: { name: 'value', detail: 'The value to be verified as a URL.' },
+ },
+ },
N: {
description: 'Returns a value converted to a number',
abstract: 'Returns a value converted to a number',
diff --git a/packages/sheets-formula-ui/src/locale/function-list/information/ja-JP.ts b/packages/sheets-formula-ui/src/locale/function-list/information/ja-JP.ts
index 9616fafa7a..bf740930b3 100644
--- a/packages/sheets-formula-ui/src/locale/function-list/information/ja-JP.ts
+++ b/packages/sheets-formula-ui/src/locale/function-list/information/ja-JP.ts
@@ -82,6 +82,19 @@ export default {
value: { name: '値', detail: '日付であるかを検証する値です。' },
},
},
+ ISEMAIL: {
+ description: '値が有効なメールアドレスであるかどうかを検証します',
+ abstract: '値が有効なメールアドレスであるかどうかを検証します',
+ links: [
+ {
+ title: '指導',
+ url: 'https://support.google.com/docs/answer/3256503?hl=ja&sjid=2155433538747546473-AP',
+ },
+ ],
+ functionParameter: {
+ value: { name: '値', detail: 'メールアドレスであるかどうかを検証する値です。' },
+ },
+ },
ISERR: {
description: '対象が #N/A 以外のエラー値のときに TRUE を返します。',
abstract: '対象が #N/A 以外のエラー値のときに TRUE を返します。',
@@ -239,6 +252,19 @@ export default {
value: { name: '値', detail: 'テストする値を指定します。テストの対象引数には、空白セル、エラー、論理値、文字列、数値、参照値、または対象となるデータを参照する名前を指定することができます。' },
},
},
+ ISURL: {
+ description: '値が有効な URL であるかどうかを検証します。',
+ abstract: '値が有効な URL であるかどうかを検証します。',
+ links: [
+ {
+ title: '指導',
+ url: 'https://support.google.com/docs/answer/3256501?hl=ja&sjid=7312884847858065932-AP',
+ },
+ ],
+ functionParameter: {
+ value: { name: '値', detail: 'URL であるかを検証する値を指定します。' },
+ },
+ },
N: {
description: '値を数値に変換します。',
abstract: '値を数値に変換します。',
diff --git a/packages/sheets-formula-ui/src/locale/function-list/information/vi-VN.ts b/packages/sheets-formula-ui/src/locale/function-list/information/vi-VN.ts
index 4279357a5d..fe55fb8efe 100644
--- a/packages/sheets-formula-ui/src/locale/function-list/information/vi-VN.ts
+++ b/packages/sheets-formula-ui/src/locale/function-list/information/vi-VN.ts
@@ -68,6 +68,19 @@ export default {
value: { name: 'Giá trị', detail: 'Giá trị cần xác minh có phải là một ngày hay không.' },
},
},
+ ISEMAIL: {
+ description: 'Tra xem một giá trị có phải là địa chỉ email hợp lệ hay không bằng.',
+ abstract: 'Tra xem một giá trị có phải là địa chỉ email hợp lệ hay không bằng.',
+ links: [
+ {
+ title: 'Hướng dẫn',
+ url: 'https://support.google.com/docs/answer/3256503?hl=vi&sjid=2155433538747546473-AP',
+ },
+ ],
+ functionParameter: {
+ value: { name: 'Giá trị', detail: 'Giá trị được xác minh là một địa chỉ email.' },
+ },
+ },
ISERR: {
description: 'Trả về TRUE nếu giá trị là bất kỳ giá trị lỗi nào ngoại trừ #N/A',
abstract: 'Trả về TRUE nếu giá trị là bất kỳ giá trị lỗi nào ngoại trừ #N/A',
@@ -211,6 +224,19 @@ export default {
value: { name: 'Giá trị', detail: 'Giá trị mà bạn muốn kiểm tra. Đối số giá trị có thể là trống (ô trống), lỗi, giá trị lô-gic, văn bản, số, giá trị tham chiếu hoặc tên tham chiếu tới bất kỳ giá trị nào trong những giá trị này.' },
},
},
+ ISURL: {
+ description: 'Kiểm tra liệu giá trị có phải là một URL hợp lệ.',
+ abstract: 'Kiểm tra liệu giá trị có phải là một URL hợp lệ.',
+ links: [
+ {
+ title: 'Hướng dẫn',
+ url: 'https://support.google.com/docs/answer/3256501?hl=vi&sjid=7312884847858065932-AP',
+ },
+ ],
+ functionParameter: {
+ value: { name: 'Giá trị', detail: 'Giá trị được xác minh là một URL.' },
+ },
+ },
N: {
description: 'Trả về một giá trị được chuyển đổi thành số.',
abstract: 'Trả về một giá trị được chuyển đổi thành số.',
diff --git a/packages/sheets-formula-ui/src/locale/function-list/information/zh-CN.ts b/packages/sheets-formula-ui/src/locale/function-list/information/zh-CN.ts
index 709baa582c..1569c79e86 100644
--- a/packages/sheets-formula-ui/src/locale/function-list/information/zh-CN.ts
+++ b/packages/sheets-formula-ui/src/locale/function-list/information/zh-CN.ts
@@ -82,6 +82,19 @@ export default {
value: { name: '值', detail: '要验证其是否为日期的值。' },
},
},
+ ISEMAIL: {
+ description: '检查输入的值是否为有效的电子邮件地址',
+ abstract: '检查输入的值是否为有效的电子邮件地址',
+ links: [
+ {
+ title: '教学',
+ url: 'https://support.google.com/docs/answer/3256503?hl=zh-Hans&sjid=2155433538747546473-AP',
+ },
+ ],
+ functionParameter: {
+ value: { name: '值', detail: '要验证其是否为电子邮件地址的值。' },
+ },
+ },
ISERR: {
description: '如果值为除 #N/A 以外的任何错误值,则返回 TRUE',
abstract: '如果值为除 #N/A 以外的任何错误值,则返回 TRUE',
@@ -239,6 +252,19 @@ export default {
value: { name: '值', detail: '指的是要测试的值。参数值可以是空白(空单元格)、错误值、逻辑值、文本、数字、引用值,或者引用要测试的以上任意值的名称。' },
},
},
+ ISURL: {
+ description: '检查某个值是否为有效网址',
+ abstract: '检查某个值是否为有效网址',
+ links: [
+ {
+ title: '教学',
+ url: 'https://support.google.com/docs/answer/3256501?hl=zh-Hans&sjid=7312884847858065932-AP',
+ },
+ ],
+ functionParameter: {
+ value: { name: '值', detail: '要验证其是否为网址的值。' },
+ },
+ },
N: {
description: '返回转换为数字的值',
abstract: '返回转换为数字的值',
diff --git a/packages/sheets-formula-ui/src/locale/function-list/information/zh-TW.ts b/packages/sheets-formula-ui/src/locale/function-list/information/zh-TW.ts
index c09671a798..57e73f0eff 100644
--- a/packages/sheets-formula-ui/src/locale/function-list/information/zh-TW.ts
+++ b/packages/sheets-formula-ui/src/locale/function-list/information/zh-TW.ts
@@ -82,6 +82,19 @@ export default {
value: { name: '值', detail: '要驗證是否為日期的值。' },
},
},
+ ISEMAIL: {
+ description: '檢查某個值是否為有效的電子郵件地址',
+ abstract: '檢查某個值是否為有效的電子郵件地址',
+ links: [
+ {
+ title: '教導',
+ url: 'https://support.google.com/docs/answer/3256503?hl=zh-Hant&sjid=2155433538747546473-AP',
+ },
+ ],
+ functionParameter: {
+ value: { name: '值', detail: '要驗證是否為電子郵件地址的值。' },
+ },
+ },
ISERR: {
description: '如果值為 #N/A 以外的任何錯誤值,則傳回 TRUE',
abstract: '如果值為 #N/A 以外的任何錯誤值,則傳回 TRUE',
@@ -238,6 +251,19 @@ export default {
value: { name: '值', detail: '指的是要測試的值。參數值可以是空白(空白儲存格)、錯誤值、邏輯值、文字、數字、參考值,或引用要測試的以上任意值的名稱。' },
},
},
+ ISURL: {
+ description: '檢查特定值是否為有效的網址',
+ abstract: '檢查特定值是否為有效的網址',
+ links: [
+ {
+ title: '教導',
+ url: 'https://support.google.com/docs/answer/3256501?hl=zh-Hant&sjid=7312884847858065932-AP',
+ },
+ ],
+ functionParameter: {
+ value: { name: '值', detail: '要驗證是否為網址的值。' },
+ },
+ },
N: {
description: '返回轉換為數字的值',
abstract: '返回轉換為數字的值',
diff --git a/packages/sheets-formula-ui/src/locale/function-list/web/en-US.ts b/packages/sheets-formula-ui/src/locale/function-list/web/en-US.ts
index 450d2a5684..c60694017f 100644
--- a/packages/sheets-formula-ui/src/locale/function-list/web/en-US.ts
+++ b/packages/sheets-formula-ui/src/locale/function-list/web/en-US.ts
@@ -25,8 +25,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ text: { name: 'text', detail: 'A string to be URL encoded' },
},
},
FILTERXML: {
diff --git a/packages/sheets-formula-ui/src/locale/function-list/web/ja-JP.ts b/packages/sheets-formula-ui/src/locale/function-list/web/ja-JP.ts
index 997947ef59..1a5bb40486 100644
--- a/packages/sheets-formula-ui/src/locale/function-list/web/ja-JP.ts
+++ b/packages/sheets-formula-ui/src/locale/function-list/web/ja-JP.ts
@@ -25,8 +25,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ text: { name: '文字列', detail: 'URL エンコードされる文字列' },
},
},
FILTERXML: {
diff --git a/packages/sheets-formula-ui/src/locale/function-list/web/ru-RU.ts b/packages/sheets-formula-ui/src/locale/function-list/web/ru-RU.ts
index 35dbab0ba7..0852c92c4b 100644
--- a/packages/sheets-formula-ui/src/locale/function-list/web/ru-RU.ts
+++ b/packages/sheets-formula-ui/src/locale/function-list/web/ru-RU.ts
@@ -25,8 +25,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'первый' },
- number2: { name: 'number2', detail: 'второй' },
+ text: { name: 'tекст', detail: 'Строка для кодирования URL-адреса' },
},
},
FILTERXML: {
diff --git a/packages/sheets-formula-ui/src/locale/function-list/web/vi-VN.ts b/packages/sheets-formula-ui/src/locale/function-list/web/vi-VN.ts
index a989b44752..ea84a316fa 100644
--- a/packages/sheets-formula-ui/src/locale/function-list/web/vi-VN.ts
+++ b/packages/sheets-formula-ui/src/locale/function-list/web/vi-VN.ts
@@ -14,6 +14,18 @@
* limitations under the License.
*/
-import enUS from './en-US';
-
-export default enUS;
+export default {
+ ENCODEURL: {
+ description: 'Trả về một chuỗi được mã hóa URL.',
+ abstract: 'Trả về một chuỗi được mã hóa URL.',
+ links: [
+ {
+ title: 'Hướng dẫn',
+ url: 'https://support.microsoft.com/vi-vn/office/encodeurl-%E5%87%BD%E6%95%B0-07c7fb90-7c60-4bff-8687-fac50fe33d0e',
+ },
+ ],
+ functionParameter: {
+ text: { name: 'văn bản', detail: 'Một chuỗi cần mã hóa URL.' },
+ },
+ },
+};
diff --git a/packages/sheets-formula-ui/src/locale/function-list/web/zh-CN.ts b/packages/sheets-formula-ui/src/locale/function-list/web/zh-CN.ts
index a67ddc6ad1..e5cf8824aa 100644
--- a/packages/sheets-formula-ui/src/locale/function-list/web/zh-CN.ts
+++ b/packages/sheets-formula-ui/src/locale/function-list/web/zh-CN.ts
@@ -25,8 +25,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ text: { name: '文本', detail: '要进行 URL 编码的字符串' },
},
},
FILTERXML: {
diff --git a/packages/sheets-formula-ui/src/locale/function-list/web/zh-TW.ts b/packages/sheets-formula-ui/src/locale/function-list/web/zh-TW.ts
index f358431dee..dd09a70e51 100644
--- a/packages/sheets-formula-ui/src/locale/function-list/web/zh-TW.ts
+++ b/packages/sheets-formula-ui/src/locale/function-list/web/zh-TW.ts
@@ -25,8 +25,7 @@ export default {
},
],
functionParameter: {
- number1: { name: 'number1', detail: 'first' },
- number2: { name: 'number2', detail: 'second' },
+ text: { name: '文字', detail: '要編碼 URL 的字串' },
},
},
FILTERXML: {
diff --git a/packages/sheets-formula/src/services/function-list/information.ts b/packages/sheets-formula/src/services/function-list/information.ts
index 2919559d66..ed5102c60c 100644
--- a/packages/sheets-formula/src/services/function-list/information.ts
+++ b/packages/sheets-formula/src/services/function-list/information.ts
@@ -106,6 +106,21 @@ export const FUNCTION_LIST_INFORMATION: IFunctionInfo[] = [
},
],
},
+ {
+ functionName: FUNCTION_NAMES_INFORMATION.ISEMAIL,
+ functionType: FunctionType.Information,
+ description: 'formula.functionList.ISEMAIL.description',
+ abstract: 'formula.functionList.ISEMAIL.abstract',
+ functionParameter: [
+ {
+ name: 'formula.functionList.ISEMAIL.functionParameter.value.name',
+ detail: 'formula.functionList.ISEMAIL.functionParameter.value.detail',
+ example: '"[email protected]"',
+ require: 1,
+ repeat: 0,
+ },
+ ],
+ },
{
functionName: FUNCTION_NAMES_INFORMATION.ISERR,
functionType: FunctionType.Information,
@@ -293,6 +308,21 @@ export const FUNCTION_LIST_INFORMATION: IFunctionInfo[] = [
},
],
},
+ {
+ functionName: FUNCTION_NAMES_INFORMATION.ISURL,
+ functionType: FunctionType.Information,
+ description: 'formula.functionList.ISURL.description',
+ abstract: 'formula.functionList.ISURL.abstract',
+ functionParameter: [
+ {
+ name: 'formula.functionList.ISURL.functionParameter.value.name',
+ detail: 'formula.functionList.ISURL.functionParameter.value.detail',
+ example: '"univer.ai"',
+ require: 1,
+ repeat: 0,
+ },
+ ],
+ },
{
functionName: FUNCTION_NAMES_INFORMATION.N,
functionType: FunctionType.Information,
diff --git a/packages/sheets-formula/src/services/function-list/web.ts b/packages/sheets-formula/src/services/function-list/web.ts
index 479181046d..693745620d 100644
--- a/packages/sheets-formula/src/services/function-list/web.ts
+++ b/packages/sheets-formula/src/services/function-list/web.ts
@@ -24,16 +24,9 @@ export const FUNCTION_LIST_WEB: IFunctionInfo[] = [
abstract: 'formula.functionList.ENCODEURL.abstract',
functionParameter: [
{
- name: 'formula.functionList.ENCODEURL.functionParameter.number1.name',
- detail: 'formula.functionList.ENCODEURL.functionParameter.number1.detail',
- example: 'A1:A20',
- require: 1,
- repeat: 0,
- },
- {
- name: 'formula.functionList.ENCODEURL.functionParameter.number2.name',
- detail: 'formula.functionList.ENCODEURL.functionParameter.number2.detail',
- example: 'A1:A20',
+ name: 'formula.functionList.ENCODEURL.functionParameter.text.name',
+ detail: 'formula.functionList.ENCODEURL.functionParameter.text.detail',
+ example: '"https://univer.ai/"',
require: 1,
repeat: 0,
},