rapid-spreadjs 1.0.183 → 1.0.185
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 +83 -4
- 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 +83 -4
- 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
|
@@ -1237,16 +1237,20 @@ const BusinessUtils = {
|
|
|
1237
1237
|
});
|
|
1238
1238
|
return itemExp;
|
|
1239
1239
|
};
|
|
1240
|
-
//将1~
|
|
1240
|
+
//将1~100这些数字替换为具体的设置条件
|
|
1241
1241
|
const replaceNum = (itemExp, conJsonArr) => {
|
|
1242
1242
|
const nums = [];
|
|
1243
|
-
for (let iNum = 1; iNum <=
|
|
1243
|
+
for (let iNum = 1; iNum <= 100; iNum++) {
|
|
1244
1244
|
nums.push(iNum);
|
|
1245
1245
|
}
|
|
1246
1246
|
nums.forEach((num) => {
|
|
1247
1247
|
if (itemExp.indexOf(num) > -1 && num <= conJsonArr.length) {
|
|
1248
1248
|
//将条件公式【1 || (2 && 3)】中的数组替换为#1#的形式
|
|
1249
|
-
|
|
1249
|
+
/**
|
|
1250
|
+
* 如下正则替换的原理为:将字符串中独立的数字66替换为Y
|
|
1251
|
+
* '78ab5c66d5566e4566f66g'.replace(new RegExp(`(?<!\\d)${66}(?!\\d)`, 'g'), 'Y') → '78ab5cYd5566e4566fYg'
|
|
1252
|
+
*/
|
|
1253
|
+
itemExp = itemExp.replace(new RegExp(`(?<!\\d)${num}(?!\\d)`, 'g'), `#${num}#`);
|
|
1250
1254
|
}
|
|
1251
1255
|
});
|
|
1252
1256
|
nums.forEach((num) => {
|
|
@@ -1299,6 +1303,8 @@ const BusinessUtils = {
|
|
|
1299
1303
|
//记录是否所有前置公式对应的条件都没有超差
|
|
1300
1304
|
let isAllNotCc = true;
|
|
1301
1305
|
for (let j = 0; j < qzGsJsonArr.length; j++) {
|
|
1306
|
+
// if (j == 11) debugger;
|
|
1307
|
+
// debugger;
|
|
1302
1308
|
const itemQzgs = qzGsJsonArr[j];
|
|
1303
1309
|
//当前公式中的前置条件
|
|
1304
1310
|
let curGsQz = itemQzgs.qzFor.replaceAll('jd(', '精度开始').replaceAll(')jd', '精度结束').replaceAll('abs', '[###]');
|
|
@@ -1345,7 +1351,7 @@ const BusinessUtils = {
|
|
|
1345
1351
|
}
|
|
1346
1352
|
}
|
|
1347
1353
|
}
|
|
1348
|
-
break;
|
|
1354
|
+
// break;
|
|
1349
1355
|
}
|
|
1350
1356
|
}
|
|
1351
1357
|
catch (error) {
|
|
@@ -16780,6 +16786,79 @@ const FormulaUtils = {
|
|
|
16780
16786
|
// return calcVal(retArrVals[0], accuracy);
|
|
16781
16787
|
},
|
|
16782
16788
|
},
|
|
16789
|
+
{
|
|
16790
|
+
funName: 'YJROUNDKX',
|
|
16791
|
+
funDesc: '计算科学计数修约',
|
|
16792
|
+
funDefaultVal: null,
|
|
16793
|
+
funParams: [
|
|
16794
|
+
{
|
|
16795
|
+
name: '数值',
|
|
16796
|
+
repeatable: false,
|
|
16797
|
+
optional: false,
|
|
16798
|
+
},
|
|
16799
|
+
{
|
|
16800
|
+
name: '修约位数',
|
|
16801
|
+
repeatable: false,
|
|
16802
|
+
optional: false,
|
|
16803
|
+
},
|
|
16804
|
+
],
|
|
16805
|
+
funCallback: (spread, sheet, retData) => {
|
|
16806
|
+
let symbol = '/';
|
|
16807
|
+
//如果传递的参数小于2个(第一个参数为修约的数值,第二个参数为修约位数),则返回符号
|
|
16808
|
+
if (retData.allCellVals.length < 2) {
|
|
16809
|
+
return symbol;
|
|
16810
|
+
}
|
|
16811
|
+
//判断要修约的值和精度是否为数字,不是则返回符号
|
|
16812
|
+
if (!FormulaUtils.commFun.isNumber(retData.allCellVals[0]) || !FormulaUtils.commFun.isNumber(retData.allCellVals[1])) {
|
|
16813
|
+
return symbol;
|
|
16814
|
+
}
|
|
16815
|
+
let retArrVals = FormulaUtils.commFun.convertToInt(retData.allCellVals);
|
|
16816
|
+
//修约位数(正式以配置中为优先级获取,如业务系统中就要根据配置来判断)
|
|
16817
|
+
let accuracy = Math.floor(retArrVals[1]);
|
|
16818
|
+
//小于等于0时,返回原始数据
|
|
16819
|
+
if (accuracy <= 0 || retArrVals[0] == 0) {
|
|
16820
|
+
return retArrVals[0];
|
|
16821
|
+
}
|
|
16822
|
+
/**
|
|
16823
|
+
* 将数字转换为统一的标准科学计数法表达字符串
|
|
16824
|
+
* @param {number} num - 需要转换的数字
|
|
16825
|
+
* @param {number} [digits] - 有效数字位数(默认自动推断)
|
|
16826
|
+
* @returns {string} 如 "1.34*10^-2"、"1.34"、"1.34*10³"
|
|
16827
|
+
*/
|
|
16828
|
+
const toScientificNotation = (num, digits) => {
|
|
16829
|
+
if (num === 0)
|
|
16830
|
+
return '0';
|
|
16831
|
+
if (!isFinite(num))
|
|
16832
|
+
return String(num);
|
|
16833
|
+
// 1. 确定有效数字位数:未指定时从原数推断
|
|
16834
|
+
if (digits === undefined) {
|
|
16835
|
+
const str = String(Math.abs(num));
|
|
16836
|
+
// 去除小数点和前导零,剩余即为有效数字
|
|
16837
|
+
digits = str.replace(/^0*\.?0*/, '').replace('.', '').length || 1;
|
|
16838
|
+
}
|
|
16839
|
+
// 2. 利用 toExponential 获取标准化系数和指数
|
|
16840
|
+
// 例如: (134).toExponential(2) => "1.34e+2"
|
|
16841
|
+
const expStr = num.toExponential(digits - 1);
|
|
16842
|
+
const [coefStr, expPart] = expStr.split('e');
|
|
16843
|
+
const exponent = parseInt(expPart, 10);
|
|
16844
|
+
// 3. 清理系数尾部多余的零(如 1.340 → 1.34)
|
|
16845
|
+
const coefficient = parseFloat(coefStr).toString();
|
|
16846
|
+
// 4. 根据指数值格式化输出
|
|
16847
|
+
if (exponent === 0) {
|
|
16848
|
+
// 指数为0:直接返回系数,如 "1.34"
|
|
16849
|
+
return coefficient;
|
|
16850
|
+
}
|
|
16851
|
+
// 上标映射表
|
|
16852
|
+
const superscripts = { '-': '⁻', '0': '⁰', '1': '¹', '2': '²', '3': '³', '4': '⁴', '5': '⁵', '6': '⁶', '7': '⁷', '8': '⁸', '9': '⁹' };
|
|
16853
|
+
const expDisplay = String(exponent)
|
|
16854
|
+
.split('')
|
|
16855
|
+
.map((ch) => superscripts[ch] || ch)
|
|
16856
|
+
.join('');
|
|
16857
|
+
return `${coefficient}*10${expDisplay}`;
|
|
16858
|
+
};
|
|
16859
|
+
return toScientificNotation(retArrVals[0], accuracy);
|
|
16860
|
+
},
|
|
16861
|
+
},
|
|
16783
16862
|
{
|
|
16784
16863
|
funName: 'YJDZ',
|
|
16785
16864
|
funDesc: '按照单元格点选顺序,优先提取最后一个有数据的单元格值',
|