跳到主要内容

XOR

返回所有参数的逻辑异或值。当 true 输入的数量为奇数时,函数返回 true;当 true 输入的数量为偶数时,返回 false

语法

expression.XOR(args);

expression - 表示 ApiWorksheetFunction 类的变量。

参数

名称必需/可选数据类型默认值描述
args必需ApiRange | ApiName | boolean | boolean[]要检查的条件。

返回值

boolean

示例

此示例演示如何返回所有参数的逻辑异或值。当 true 输入的数量为奇数时,函数返回 true;当 true 输入的数量为偶数时,返回 false。

// How to return the logical Exclusive Or value of all arguments.

// Use a function to calculate Exclusive Or.

const worksheet = Api.GetActiveSheet();

let func = Api.WorksheetFunction;
let ans = func.TRUE(); //returns TRUE, doesnt require arguments

worksheet.GetRange("A1").SetValue(ans);