rapid-spreadjs 1.0.51 → 1.0.52

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
@@ -684,12 +684,13 @@ const BusinessUtils = {
684
684
  * @param gc GC对象
685
685
  * @param sheet 工作表实例
686
686
  * @param testObjectAttrs 检测对象属性配置集合
687
+ * @param addRowIndex 添加检测对象属性区域的起始行索引,默认为:0
687
688
  * @param isVertical 是否为纵表,默认为:true
688
689
  * @param contentColStartIndex 表格内容列起始索引,默认为:1
689
690
  * @param contentTotalColCount 表格内容列总数,默认为:77
690
- * @param addRowHeight 添加的表格行高,默认为:24
691
+ * @param addRowHeight 添加的表格行高,默认为:24(单位为像素)
691
692
  */
692
- createTestObjectAttrsCells: (gc, sheet, testObjectAttrs, isVertical = true, contentColStartIndex = 1, contentTotalColCount = 77, addRowHeight = 24) => {
693
+ createTestObjectAttrsCells: (gc, sheet, testObjectAttrs, addRowIndex = 0, isVertical = true, contentColStartIndex = 1, contentTotalColCount = 77, addRowHeight = 24) => {
693
694
  if (!testObjectAttrs || testObjectAttrs.length === 0) {
694
695
  return;
695
696
  }
@@ -703,8 +704,14 @@ const BusinessUtils = {
703
704
  const testObjectAttrsChunk = rapidUtils.chunkJson(testObjectAttrs, rowTestObjectCount);
704
705
  // 暂停绘制
705
706
  sheet.suspendPaint();
706
- // 设置工作表行数为0
707
- sheet.setRowCount(0);
707
+ // // 设置工作表行数为0
708
+ // sheet.setRowCount(0);
709
+ // 获取当前Sheet的行数
710
+ const rowCount = sheet.getRowCount();
711
+ // 如果满足如下条件,则将末尾的行全部删除
712
+ if (addRowIndex > 0 && addRowIndex < rowCount) {
713
+ sheet.deleteRows(addRowIndex, rowCount - addRowIndex);
714
+ }
708
715
  /**
709
716
  * 设置单元格字体和大小
710
717
  * @param row
@@ -772,11 +779,12 @@ const BusinessUtils = {
772
779
  * 获取检测对象属性值集合
773
780
  * @param sheet 工作表实例
774
781
  * @param testObjectAttrs 检测对象属性配置集合
782
+ * @param addRowIndex 添加检测对象属性区域的起始行索引,默认为:0
775
783
  * @param isVertical 是否为纵表,默认为:true
776
784
  * @param contentColStartIndex 表格内容列起始索引,默认为:1
777
785
  * @param contentTotalColCount 表格内容列总数,默认为:77
778
786
  */
779
- getTestObjectAttrsVals: (sheet, testObjectAttrs, isVertical = true, contentColStartIndex = 1, contentTotalColCount = 77) => {
787
+ getTestObjectAttrsVals: (sheet, testObjectAttrs, addRowIndex = 0, isVertical = true, contentColStartIndex = 1, contentTotalColCount = 77) => {
780
788
  // 一行中检测对象属性的个数(纵表为2个,横表为3个)
781
789
  const rowTestObjectCount = isVertical ? 2 : 3;
782
790
  // 将测试对象属性数据进行分块
@@ -785,7 +793,7 @@ const BusinessUtils = {
785
793
  sheet.suspendPaint();
786
794
  // 所有单元格对象
787
795
  const allCells = SheetUtils.getAllCellObjsByRange(sheet, {
788
- row: 0,
796
+ row: addRowIndex,
789
797
  col: contentColStartIndex,
790
798
  rowCount: sheet.getRowCount(),
791
799
  colCount: contentTotalColCount,
@@ -12871,10 +12879,10 @@ const FormulaUtils = {
12871
12879
  }
12872
12880
  }
12873
12881
  //系数
12874
- let coefficient = 1 / accuracy;
12882
+ let coefficient = rapidUtils.preciseCalc(1, accuracy, 'div'); // 1 / accuracy;
12875
12883
  //换算后的修约值(=修约值*系数)
12876
12884
  //注意:此处使用到了toFixed,目的是可能会存在精度的问题
12877
- let roundingValCal = Number((roundingVal * coefficient).toFixed(8));
12885
+ let roundingValCal = rapidUtils.preciseCalc(roundingVal, coefficient, 'mul'); // Number((roundingVal * coefficient).toFixed(8));
12878
12886
  /**
12879
12887
  * 计算修约结果函数
12880
12888
  * @param inputVal 换算后的修约值
@@ -12911,7 +12919,7 @@ const FormulaUtils = {
12911
12919
  return inputVal;
12912
12920
  };
12913
12921
  //返回最终修约结果(=修约结果/系数)
12914
- const retNum = calcRoundingRet(roundingValCal) / coefficient;
12922
+ const retNum = rapidUtils.preciseCalc(calcRoundingRet(roundingValCal), coefficient, 'div'); // calcRoundingRet(roundingValCal) / coefficient;
12915
12923
  //获取修约精度中的小数位数
12916
12924
  let accuracyStr = accuracy + '';
12917
12925
  //如果修约精度中没有小数,则直接返回