rapid-spreadjs 1.0.54 → 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
@@ -542,9 +542,10 @@ const SheetUtils = {
542
542
  * 设置当前活动工作表的水印和数据绑定是否显示
543
543
  * @param spread 工作簿实例
544
544
  * @param cells 数据绑定单元格配置集合([{ row: number; col: number; title: string; pathPrev: string; pathField: string }])
545
- * @param isShow 是否显示
545
+ * @param isShow 是否显示水印
546
+ * @param isShowBindPath 是否显示数据绑定路径,默认为:true
546
547
  */
547
- setActiveSheetWatermark: (spread, cells, isShow) => {
548
+ setActiveSheetWatermark: (spread, cells, isShowWatermark, isShowBindPath = true) => {
548
549
  if (cells == null || cells == undefined) {
549
550
  return;
550
551
  }
@@ -553,9 +554,9 @@ const SheetUtils = {
553
554
  sheet.suspendPaint();
554
555
  cells.forEach((cell) => {
555
556
  // 设置或移除水印标签
556
- sheet.getCell(cell.row, cell.col).watermark(isShow ? `{${cell.title}}` : undefined);
557
+ sheet.getCell(cell.row, cell.col).watermark(isShowWatermark ? `{${cell.title}}` : undefined);
557
558
  // 设置或移除绑定路径
558
- sheet.setBindingPath(cell.row, cell.col, isShow ? `${cell.pathPrev}.${cell.pathField}` : undefined);
559
+ sheet.setBindingPath(cell.row, cell.col, isShowBindPath ? `${cell.pathPrev}.${cell.pathField}` : undefined);
559
560
  });
560
561
  // 恢复绘制
561
562
  sheet.resumePaint();
@@ -19138,6 +19139,44 @@ const FormulaUtils = {
19138
19139
  return bzc;
19139
19140
  },
19140
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
+ },
19141
19180
  {
19142
19181
  funName: 'YJTREND',
19143
19182
  funDesc: '返回线性回归拟合线的一组纵坐标值(y值)',