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.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { groupByJson, forEachJson, orderByJson, chunkJson } from 'rapid-utils';
1
+ import { groupByJson, forEachJson, orderByJson, chunkJson, preciseCalc } from 'rapid-utils';
2
2
  import * as echarts from 'echarts';
3
3
  import * as math from 'mathjs';
4
4
  import { saveAs } from 'file-saver';
@@ -662,12 +662,13 @@ const BusinessUtils = {
662
662
  * @param gc GC对象
663
663
  * @param sheet 工作表实例
664
664
  * @param testObjectAttrs 检测对象属性配置集合
665
+ * @param addRowIndex 添加检测对象属性区域的起始行索引,默认为:0
665
666
  * @param isVertical 是否为纵表,默认为:true
666
667
  * @param contentColStartIndex 表格内容列起始索引,默认为:1
667
668
  * @param contentTotalColCount 表格内容列总数,默认为:77
668
- * @param addRowHeight 添加的表格行高,默认为:24
669
+ * @param addRowHeight 添加的表格行高,默认为:24(单位为像素)
669
670
  */
670
- createTestObjectAttrsCells: (gc, sheet, testObjectAttrs, isVertical = true, contentColStartIndex = 1, contentTotalColCount = 77, addRowHeight = 24) => {
671
+ createTestObjectAttrsCells: (gc, sheet, testObjectAttrs, addRowIndex = 0, isVertical = true, contentColStartIndex = 1, contentTotalColCount = 77, addRowHeight = 24) => {
671
672
  if (!testObjectAttrs || testObjectAttrs.length === 0) {
672
673
  return;
673
674
  }
@@ -681,8 +682,14 @@ const BusinessUtils = {
681
682
  const testObjectAttrsChunk = chunkJson(testObjectAttrs, rowTestObjectCount);
682
683
  // 暂停绘制
683
684
  sheet.suspendPaint();
684
- // 设置工作表行数为0
685
- sheet.setRowCount(0);
685
+ // // 设置工作表行数为0
686
+ // sheet.setRowCount(0);
687
+ // 获取当前Sheet的行数
688
+ const rowCount = sheet.getRowCount();
689
+ // 如果满足如下条件,则将末尾的行全部删除
690
+ if (addRowIndex > 0 && addRowIndex < rowCount) {
691
+ sheet.deleteRows(addRowIndex, rowCount - addRowIndex);
692
+ }
686
693
  /**
687
694
  * 设置单元格字体和大小
688
695
  * @param row
@@ -750,11 +757,12 @@ const BusinessUtils = {
750
757
  * 获取检测对象属性值集合
751
758
  * @param sheet 工作表实例
752
759
  * @param testObjectAttrs 检测对象属性配置集合
760
+ * @param addRowIndex 添加检测对象属性区域的起始行索引,默认为:0
753
761
  * @param isVertical 是否为纵表,默认为:true
754
762
  * @param contentColStartIndex 表格内容列起始索引,默认为:1
755
763
  * @param contentTotalColCount 表格内容列总数,默认为:77
756
764
  */
757
- getTestObjectAttrsVals: (sheet, testObjectAttrs, isVertical = true, contentColStartIndex = 1, contentTotalColCount = 77) => {
765
+ getTestObjectAttrsVals: (sheet, testObjectAttrs, addRowIndex = 0, isVertical = true, contentColStartIndex = 1, contentTotalColCount = 77) => {
758
766
  // 一行中检测对象属性的个数(纵表为2个,横表为3个)
759
767
  const rowTestObjectCount = isVertical ? 2 : 3;
760
768
  // 将测试对象属性数据进行分块
@@ -763,7 +771,7 @@ const BusinessUtils = {
763
771
  sheet.suspendPaint();
764
772
  // 所有单元格对象
765
773
  const allCells = SheetUtils.getAllCellObjsByRange(sheet, {
766
- row: 0,
774
+ row: addRowIndex,
767
775
  col: contentColStartIndex,
768
776
  rowCount: sheet.getRowCount(),
769
777
  colCount: contentTotalColCount,
@@ -12849,10 +12857,10 @@ const FormulaUtils = {
12849
12857
  }
12850
12858
  }
12851
12859
  //系数
12852
- let coefficient = 1 / accuracy;
12860
+ let coefficient = preciseCalc(1, accuracy, 'div'); // 1 / accuracy;
12853
12861
  //换算后的修约值(=修约值*系数)
12854
12862
  //注意:此处使用到了toFixed,目的是可能会存在精度的问题
12855
- let roundingValCal = Number((roundingVal * coefficient).toFixed(8));
12863
+ let roundingValCal = preciseCalc(roundingVal, coefficient, 'mul'); // Number((roundingVal * coefficient).toFixed(8));
12856
12864
  /**
12857
12865
  * 计算修约结果函数
12858
12866
  * @param inputVal 换算后的修约值
@@ -12889,7 +12897,7 @@ const FormulaUtils = {
12889
12897
  return inputVal;
12890
12898
  };
12891
12899
  //返回最终修约结果(=修约结果/系数)
12892
- const retNum = calcRoundingRet(roundingValCal) / coefficient;
12900
+ const retNum = preciseCalc(calcRoundingRet(roundingValCal), coefficient, 'div'); // calcRoundingRet(roundingValCal) / coefficient;
12893
12901
  //获取修约精度中的小数位数
12894
12902
  let accuracyStr = accuracy + '';
12895
12903
  //如果修约精度中没有小数,则直接返回