rapid-spreadjs 1.0.55 → 1.0.56

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 CHANGED
@@ -19139,6 +19139,44 @@ const FormulaUtils = {
19139
19139
  return bzc;
19140
19140
  },
19141
19141
  },
19142
+ {
19143
+ funName: 'YJFRAC',
19144
+ funDesc: '根据小数返回分数(1/x)形式的文本(如:1/300、1/478)',
19145
+ funDefaultVal: null,
19146
+ isAcceptArea: true,
19147
+ funParams: [
19148
+ {
19149
+ name: '被除数',
19150
+ repeatable: false,
19151
+ optional: false,
19152
+ },
19153
+ {
19154
+ name: '除数',
19155
+ repeatable: false,
19156
+ optional: false,
19157
+ },
19158
+ ],
19159
+ funCallback: (spread, sheet, retData) => {
19160
+ //如果传递的参数小于2个,则返回空字符串
19161
+ if (retData.allCellVals.length < 2) {
19162
+ return '';
19163
+ }
19164
+ const a = retData.allCellVals[0], b = retData.allCellVals[0];
19165
+ // 计算商 d = a / b
19166
+ const d = rapidUtils.preciseCalc(a, b, 'div');
19167
+ // 计算绝对值的倒数 |b/a|,并四舍五入取整
19168
+ const absX0 = Math.abs(rapidUtils.preciseCalc(b, a, 'div'));
19169
+ let x = Math.round(absX0);
19170
+ // 确保分母至少为1
19171
+ if (x < 1) {
19172
+ x = 1;
19173
+ }
19174
+ // 根据商的符号返回分数字符串
19175
+ const sign = d < 0 ? '-' : '';
19176
+ sheet.getCell(retData.cellObj.row, retData.cellObj.col).formatter(`${sign}1/${x}`);
19177
+ return d;
19178
+ },
19179
+ },
19142
19180
  {
19143
19181
  funName: 'YJTREND',
19144
19182
  funDesc: '返回线性回归拟合线的一组纵坐标值(y值)',