rapid-spreadjs 1.0.59 → 1.0.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +132 -0
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs.min.js +1 -1
- package/dist/index.cjs.min.js.map +1 -1
- package/dist/index.esm.js +132 -0
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -12856,6 +12856,7 @@ const FormulaUtils = {
|
|
|
12856
12856
|
//自定义函数逻辑
|
|
12857
12857
|
cusFun.prototype.evaluate = function () {
|
|
12858
12858
|
// 获取该自定义公式被引用单元格的索引
|
|
12859
|
+
console.log('所有参数:', arguments);
|
|
12859
12860
|
/**
|
|
12860
12861
|
* 说明:
|
|
12861
12862
|
* 如果isContext=true,则arguments的第一个参数为上下文参数,后面的参数才是自定义参数真正传入的参数
|
|
@@ -19375,6 +19376,137 @@ const FormulaUtils = {
|
|
|
19375
19376
|
return d;
|
|
19376
19377
|
},
|
|
19377
19378
|
},
|
|
19379
|
+
{
|
|
19380
|
+
funName: 'YJDXPD',
|
|
19381
|
+
funDesc: '单项判定',
|
|
19382
|
+
funDefaultVal: null,
|
|
19383
|
+
isAcceptArea: true,
|
|
19384
|
+
funParams: [
|
|
19385
|
+
{
|
|
19386
|
+
name: '判定范围,格式如:-2,2、-2~2或±2',
|
|
19387
|
+
repeatable: false,
|
|
19388
|
+
optional: false,
|
|
19389
|
+
},
|
|
19390
|
+
{
|
|
19391
|
+
name: '判定值,如:1',
|
|
19392
|
+
repeatable: false,
|
|
19393
|
+
optional: false,
|
|
19394
|
+
},
|
|
19395
|
+
],
|
|
19396
|
+
funCallback: (spread, sheet, retData) => {
|
|
19397
|
+
//如果传递的参数小于2个,则返回空字符串
|
|
19398
|
+
if (retData.allCellVals.length < 2) {
|
|
19399
|
+
return '';
|
|
19400
|
+
}
|
|
19401
|
+
retData.allCellVals[0]; retData.allCellVals[1];
|
|
19402
|
+
try {
|
|
19403
|
+
const rangeStr = retData.allCellVals[0], num = retData.allCellVals[1];
|
|
19404
|
+
// 参数基础校验
|
|
19405
|
+
if (typeof rangeStr !== 'string' || typeof num !== 'number' || isNaN(num)) {
|
|
19406
|
+
return '/';
|
|
19407
|
+
}
|
|
19408
|
+
// 去除字符串中的空格
|
|
19409
|
+
const cleanStr = rangeStr.replace(/\s/g, '');
|
|
19410
|
+
let min, max;
|
|
19411
|
+
// 处理三种格式
|
|
19412
|
+
if (cleanStr.includes(',')) {
|
|
19413
|
+
// 格式:"-2,2"
|
|
19414
|
+
const parts = cleanStr.split(',');
|
|
19415
|
+
if (parts.length !== 2)
|
|
19416
|
+
return '/';
|
|
19417
|
+
min = parseFloat(parts[0]);
|
|
19418
|
+
max = parseFloat(parts[1]);
|
|
19419
|
+
}
|
|
19420
|
+
else if (cleanStr.includes('~')) {
|
|
19421
|
+
// 格式:"-2~2"
|
|
19422
|
+
const parts = cleanStr.split('~');
|
|
19423
|
+
if (parts.length !== 2)
|
|
19424
|
+
return '/';
|
|
19425
|
+
min = parseFloat(parts[0]);
|
|
19426
|
+
max = parseFloat(parts[1]);
|
|
19427
|
+
}
|
|
19428
|
+
else if (cleanStr.includes('±')) {
|
|
19429
|
+
// 格式:"±2"
|
|
19430
|
+
const valueStr = cleanStr.replace('±', '');
|
|
19431
|
+
const value = parseFloat(valueStr);
|
|
19432
|
+
if (isNaN(value))
|
|
19433
|
+
return '/';
|
|
19434
|
+
min = -value;
|
|
19435
|
+
max = value;
|
|
19436
|
+
}
|
|
19437
|
+
else {
|
|
19438
|
+
// 不是三种指定格式之一
|
|
19439
|
+
return '/';
|
|
19440
|
+
}
|
|
19441
|
+
// 检查解析结果是否有效
|
|
19442
|
+
if (isNaN(min) || isNaN(max)) {
|
|
19443
|
+
return '/';
|
|
19444
|
+
}
|
|
19445
|
+
// 判断数字是否在范围内
|
|
19446
|
+
if (num >= min && num <= max) {
|
|
19447
|
+
return '合格';
|
|
19448
|
+
}
|
|
19449
|
+
else {
|
|
19450
|
+
return '不合格';
|
|
19451
|
+
}
|
|
19452
|
+
}
|
|
19453
|
+
catch (error) {
|
|
19454
|
+
// 任何错误都返回"/"
|
|
19455
|
+
return '/';
|
|
19456
|
+
}
|
|
19457
|
+
},
|
|
19458
|
+
},
|
|
19459
|
+
{
|
|
19460
|
+
funName: 'YJTEXTJOIN',
|
|
19461
|
+
funDesc: '此函数将多个区域和/或字符串的文本组合起来,并包括你在要组合的各文本值之间指定的分隔符。',
|
|
19462
|
+
funDefaultVal: null,
|
|
19463
|
+
isAcceptArea: true,
|
|
19464
|
+
funParams: [
|
|
19465
|
+
{
|
|
19466
|
+
name: '需要用作判断的数字数组或字符串数组',
|
|
19467
|
+
repeatable: false,
|
|
19468
|
+
optional: false,
|
|
19469
|
+
},
|
|
19470
|
+
{
|
|
19471
|
+
name: '返回值的数组',
|
|
19472
|
+
repeatable: false,
|
|
19473
|
+
optional: false,
|
|
19474
|
+
},
|
|
19475
|
+
{
|
|
19476
|
+
name: '比较大小或比较相等的字符串,格式为:“>”、“<”、“>=”、“<=”、“=”',
|
|
19477
|
+
repeatable: false,
|
|
19478
|
+
optional: false,
|
|
19479
|
+
},
|
|
19480
|
+
{
|
|
19481
|
+
name: '比较的值,类型为数字类型或字符串类型,如:3或“合格”',
|
|
19482
|
+
repeatable: false,
|
|
19483
|
+
optional: false,
|
|
19484
|
+
},
|
|
19485
|
+
{
|
|
19486
|
+
name: '返回值的分隔符,默认为:,',
|
|
19487
|
+
repeatable: false,
|
|
19488
|
+
optional: false,
|
|
19489
|
+
},
|
|
19490
|
+
],
|
|
19491
|
+
funCallback: (spread, sheet, retData) => {
|
|
19492
|
+
// //如果传递的参数小于3个,则返回空字符串
|
|
19493
|
+
// if (retData.allCellValsEw.length < 3) {
|
|
19494
|
+
// return '';
|
|
19495
|
+
// }
|
|
19496
|
+
let xData = FormulaUtils.commFun.convertToInt(retData.allCellValsEw[0].filter((item) => FormulaUtils.commFun.isNumber(item))), yData = FormulaUtils.commFun.convertToInt(retData.allCellValsEw[1].filter((item) => FormulaUtils.commFun.isNumber(item))), x = retData.allCellValsEw[2];
|
|
19497
|
+
if (Array.isArray(x) && x.length > 0) {
|
|
19498
|
+
x = Number(x[0]);
|
|
19499
|
+
}
|
|
19500
|
+
else {
|
|
19501
|
+
x = Number(x);
|
|
19502
|
+
}
|
|
19503
|
+
console.log(111, retData);
|
|
19504
|
+
console.log(222, xData);
|
|
19505
|
+
console.log(333, yData);
|
|
19506
|
+
console.log(444, x);
|
|
19507
|
+
return 'OK';
|
|
19508
|
+
},
|
|
19509
|
+
},
|
|
19378
19510
|
{
|
|
19379
19511
|
funName: 'YJTREND',
|
|
19380
19512
|
funDesc: '返回线性回归拟合线的一组纵坐标值(y值)',
|