rapid-spreadjs 1.0.51 → 1.0.53
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 +26 -9
- 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 +27 -10
- 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/dist/utils/business.d.ts +5 -3
- package/package.json +1 -1
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:
|
|
774
|
+
row: addRowIndex,
|
|
767
775
|
col: contentColStartIndex,
|
|
768
776
|
rowCount: sheet.getRowCount(),
|
|
769
777
|
colCount: contentTotalColCount,
|
|
@@ -807,6 +815,8 @@ const BusinessUtils = {
|
|
|
807
815
|
}
|
|
808
816
|
// 获取当前工作表
|
|
809
817
|
const sheet = spread.getActiveSheet();
|
|
818
|
+
// 判断要循环的单元格最后一行是否为表格的末尾行,如果是,则在循环创建单元行的最后一行的时候,下边框线位细线样式
|
|
819
|
+
const isCyclicLastRowIsSheetLastRow = cellRange.row + cellRange.rowCount == sheet.getRowCount();
|
|
810
820
|
/**
|
|
811
821
|
* 添加行
|
|
812
822
|
* @param addRowIndex 添加行的索引位置
|
|
@@ -857,6 +867,13 @@ const BusinessUtils = {
|
|
|
857
867
|
else if (curDefaultPointCount > 1 && lastDefaultPointCount == 0) {
|
|
858
868
|
addRowsFun(cellRange.row + cellRange.rowCount, (curDefaultPointCount - 1) * cellRange.rowCount, curDefaultPointCount - 1);
|
|
859
869
|
}
|
|
870
|
+
// 判断要循环的单元格最后一行是否为表格的末尾行,如果是,则在循环创建单元行的最后一行的时候,下边框线位细线样式
|
|
871
|
+
if (isCyclicLastRowIsSheetLastRow) {
|
|
872
|
+
// 设置所有内边框线为细线样式
|
|
873
|
+
sheet
|
|
874
|
+
.getRange(cellRange.row, cellRange.col, curDefaultPointCount * cellRange.rowCount, cellRange.colCount)
|
|
875
|
+
.setBorder(new GC.Spread.Sheets.LineBorder('#000', GC.Spread.Sheets.LineStyle.thin), { inside: true });
|
|
876
|
+
}
|
|
860
877
|
// 恢复绘制
|
|
861
878
|
sheet.resumePaint();
|
|
862
879
|
},
|
|
@@ -12849,10 +12866,10 @@ const FormulaUtils = {
|
|
|
12849
12866
|
}
|
|
12850
12867
|
}
|
|
12851
12868
|
//系数
|
|
12852
|
-
let coefficient = 1 / accuracy;
|
|
12869
|
+
let coefficient = preciseCalc(1, accuracy, 'div'); // 1 / accuracy;
|
|
12853
12870
|
//换算后的修约值(=修约值*系数)
|
|
12854
12871
|
//注意:此处使用到了toFixed,目的是可能会存在精度的问题
|
|
12855
|
-
let roundingValCal = Number((roundingVal * coefficient).toFixed(8));
|
|
12872
|
+
let roundingValCal = preciseCalc(roundingVal, coefficient, 'mul'); // Number((roundingVal * coefficient).toFixed(8));
|
|
12856
12873
|
/**
|
|
12857
12874
|
* 计算修约结果函数
|
|
12858
12875
|
* @param inputVal 换算后的修约值
|
|
@@ -12889,7 +12906,7 @@ const FormulaUtils = {
|
|
|
12889
12906
|
return inputVal;
|
|
12890
12907
|
};
|
|
12891
12908
|
//返回最终修约结果(=修约结果/系数)
|
|
12892
|
-
const retNum = calcRoundingRet(roundingValCal) / coefficient;
|
|
12909
|
+
const retNum = preciseCalc(calcRoundingRet(roundingValCal), coefficient, 'div'); // calcRoundingRet(roundingValCal) / coefficient;
|
|
12893
12910
|
//获取修约精度中的小数位数
|
|
12894
12911
|
let accuracyStr = accuracy + '';
|
|
12895
12912
|
//如果修约精度中没有小数,则直接返回
|