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.esm.js
CHANGED
|
@@ -1215,16 +1215,20 @@ const BusinessUtils = {
|
|
|
1215
1215
|
});
|
|
1216
1216
|
return itemExp;
|
|
1217
1217
|
};
|
|
1218
|
-
//将1~
|
|
1218
|
+
//将1~100这些数字替换为具体的设置条件
|
|
1219
1219
|
const replaceNum = (itemExp, conJsonArr) => {
|
|
1220
1220
|
const nums = [];
|
|
1221
|
-
for (let iNum = 1; iNum <=
|
|
1221
|
+
for (let iNum = 1; iNum <= 100; iNum++) {
|
|
1222
1222
|
nums.push(iNum);
|
|
1223
1223
|
}
|
|
1224
1224
|
nums.forEach((num) => {
|
|
1225
1225
|
if (itemExp.indexOf(num) > -1 && num <= conJsonArr.length) {
|
|
1226
1226
|
//将条件公式【1 || (2 && 3)】中的数组替换为#1#的形式
|
|
1227
|
-
|
|
1227
|
+
/**
|
|
1228
|
+
* 如下正则替换的原理为:将字符串中独立的数字66替换为Y
|
|
1229
|
+
* '78ab5c66d5566e4566f66g'.replace(new RegExp(`(?<!\\d)${66}(?!\\d)`, 'g'), 'Y') → '78ab5cYd5566e4566fYg'
|
|
1230
|
+
*/
|
|
1231
|
+
itemExp = itemExp.replace(new RegExp(`(?<!\\d)${num}(?!\\d)`, 'g'), `#${num}#`);
|
|
1228
1232
|
}
|
|
1229
1233
|
});
|
|
1230
1234
|
nums.forEach((num) => {
|
|
@@ -1277,6 +1281,8 @@ const BusinessUtils = {
|
|
|
1277
1281
|
//记录是否所有前置公式对应的条件都没有超差
|
|
1278
1282
|
let isAllNotCc = true;
|
|
1279
1283
|
for (let j = 0; j < qzGsJsonArr.length; j++) {
|
|
1284
|
+
// if (j == 11) debugger;
|
|
1285
|
+
// debugger;
|
|
1280
1286
|
const itemQzgs = qzGsJsonArr[j];
|
|
1281
1287
|
//当前公式中的前置条件
|
|
1282
1288
|
let curGsQz = itemQzgs.qzFor.replaceAll('jd(', '精度开始').replaceAll(')jd', '精度结束').replaceAll('abs', '[###]');
|
|
@@ -1323,7 +1329,7 @@ const BusinessUtils = {
|
|
|
1323
1329
|
}
|
|
1324
1330
|
}
|
|
1325
1331
|
}
|
|
1326
|
-
break;
|
|
1332
|
+
// break;
|
|
1327
1333
|
}
|
|
1328
1334
|
}
|
|
1329
1335
|
catch (error) {
|
|
@@ -16758,6 +16764,79 @@ const FormulaUtils = {
|
|
|
16758
16764
|
// return calcVal(retArrVals[0], accuracy);
|
|
16759
16765
|
},
|
|
16760
16766
|
},
|
|
16767
|
+
{
|
|
16768
|
+
funName: 'YJROUNDKX',
|
|
16769
|
+
funDesc: '计算科学计数修约',
|
|
16770
|
+
funDefaultVal: null,
|
|
16771
|
+
funParams: [
|
|
16772
|
+
{
|
|
16773
|
+
name: '数值',
|
|
16774
|
+
repeatable: false,
|
|
16775
|
+
optional: false,
|
|
16776
|
+
},
|
|
16777
|
+
{
|
|
16778
|
+
name: '修约位数',
|
|
16779
|
+
repeatable: false,
|
|
16780
|
+
optional: false,
|
|
16781
|
+
},
|
|
16782
|
+
],
|
|
16783
|
+
funCallback: (spread, sheet, retData) => {
|
|
16784
|
+
let symbol = '/';
|
|
16785
|
+
//如果传递的参数小于2个(第一个参数为修约的数值,第二个参数为修约位数),则返回符号
|
|
16786
|
+
if (retData.allCellVals.length < 2) {
|
|
16787
|
+
return symbol;
|
|
16788
|
+
}
|
|
16789
|
+
//判断要修约的值和精度是否为数字,不是则返回符号
|
|
16790
|
+
if (!FormulaUtils.commFun.isNumber(retData.allCellVals[0]) || !FormulaUtils.commFun.isNumber(retData.allCellVals[1])) {
|
|
16791
|
+
return symbol;
|
|
16792
|
+
}
|
|
16793
|
+
let retArrVals = FormulaUtils.commFun.convertToInt(retData.allCellVals);
|
|
16794
|
+
//修约位数(正式以配置中为优先级获取,如业务系统中就要根据配置来判断)
|
|
16795
|
+
let accuracy = Math.floor(retArrVals[1]);
|
|
16796
|
+
//小于等于0时,返回原始数据
|
|
16797
|
+
if (accuracy <= 0 || retArrVals[0] == 0) {
|
|
16798
|
+
return retArrVals[0];
|
|
16799
|
+
}
|
|
16800
|
+
/**
|
|
16801
|
+
* 将数字转换为统一的标准科学计数法表达字符串
|
|
16802
|
+
* @param {number} num - 需要转换的数字
|
|
16803
|
+
* @param {number} [digits] - 有效数字位数(默认自动推断)
|
|
16804
|
+
* @returns {string} 如 "1.34*10^-2"、"1.34"、"1.34*10³"
|
|
16805
|
+
*/
|
|
16806
|
+
const toScientificNotation = (num, digits) => {
|
|
16807
|
+
if (num === 0)
|
|
16808
|
+
return '0';
|
|
16809
|
+
if (!isFinite(num))
|
|
16810
|
+
return String(num);
|
|
16811
|
+
// 1. 确定有效数字位数:未指定时从原数推断
|
|
16812
|
+
if (digits === undefined) {
|
|
16813
|
+
const str = String(Math.abs(num));
|
|
16814
|
+
// 去除小数点和前导零,剩余即为有效数字
|
|
16815
|
+
digits = str.replace(/^0*\.?0*/, '').replace('.', '').length || 1;
|
|
16816
|
+
}
|
|
16817
|
+
// 2. 利用 toExponential 获取标准化系数和指数
|
|
16818
|
+
// 例如: (134).toExponential(2) => "1.34e+2"
|
|
16819
|
+
const expStr = num.toExponential(digits - 1);
|
|
16820
|
+
const [coefStr, expPart] = expStr.split('e');
|
|
16821
|
+
const exponent = parseInt(expPart, 10);
|
|
16822
|
+
// 3. 清理系数尾部多余的零(如 1.340 → 1.34)
|
|
16823
|
+
const coefficient = parseFloat(coefStr).toString();
|
|
16824
|
+
// 4. 根据指数值格式化输出
|
|
16825
|
+
if (exponent === 0) {
|
|
16826
|
+
// 指数为0:直接返回系数,如 "1.34"
|
|
16827
|
+
return coefficient;
|
|
16828
|
+
}
|
|
16829
|
+
// 上标映射表
|
|
16830
|
+
const superscripts = { '-': '⁻', '0': '⁰', '1': '¹', '2': '²', '3': '³', '4': '⁴', '5': '⁵', '6': '⁶', '7': '⁷', '8': '⁸', '9': '⁹' };
|
|
16831
|
+
const expDisplay = String(exponent)
|
|
16832
|
+
.split('')
|
|
16833
|
+
.map((ch) => superscripts[ch] || ch)
|
|
16834
|
+
.join('');
|
|
16835
|
+
return `${coefficient}*10${expDisplay}`;
|
|
16836
|
+
};
|
|
16837
|
+
return toScientificNotation(retArrVals[0], accuracy);
|
|
16838
|
+
},
|
|
16839
|
+
},
|
|
16761
16840
|
{
|
|
16762
16841
|
funName: 'YJDZ',
|
|
16763
16842
|
funDesc: '按照单元格点选顺序,优先提取最后一个有数据的单元格值',
|