functionBigAddFunction() {
this.name = "BIGADD";
this.minArgs = 1;
this.maxArgs = 10;
this.description = function () {
return {
description: "使用 BigNumber.js 相加多个字符串数值",
parameters: [
{
name: "value1",
repeatable: false,
optional: false,
description: "第一个数值(字符串)"
},
{
name: "valueN",
repeatable: true,
optional: true,
description: "更多数值(字符串)"
}
]
};
};
}
BigAddFunction.prototype = new GC.Spread.CalcEngine.Functions.Function();
BigAddFunction.prototype.evaluate = function () {
debugger
try {
if (arguments.length === 0) return"0";
let total = newwindow.BigNumber(0);
for (let i = 0; i < arguments.length; i++) {
let arg = arguments[i];
if (arg !== null && arg !== undefined) {
let str = String(arg);
if (str.trim() !== "") {
total = total.plus(newwindow.BigNumber(str));
}
}
}
return total.toString();
} catch (e) {
console.error("BIGADD error:", e);
return"#VALUE!";
}
};
GC.Spread.CalcEngine.Functions.defineGlobalCustomFunction("BIGADD", new BigAddFunction());