rapid-spreadjs 1.0.121 → 1.0.122

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
@@ -825,12 +825,14 @@ const BusinessUtils = {
825
825
  * @param sheet 工作表实例
826
826
  * @param testObjectAttrs 检测对象属性配置集合
827
827
  * @param addRowIndex 添加检测对象属性区域的起始行索引,默认为:0
828
+ * @param deleteRowsCount 删除的行数,默认为:0
828
829
  * @param isVertical 是否为纵表,默认为:true
829
830
  * @param contentColStartIndex 表格内容列起始索引,默认为:1
830
831
  * @param contentTotalColCount 表格内容列总数,默认为:77
831
832
  * @param addRowHeight 添加的表格行高,默认为:24(单位为像素)
833
+ * @returns 返回生成的检测对象属性行数
832
834
  */
833
- createTestObjectAttrsCells: (gc, sheet, testObjectAttrs, addRowIndex = 0, isVertical = true, contentColStartIndex = 1, contentTotalColCount = 77, addRowHeight = 24) => {
835
+ createTestObjectAttrsCells: (gc, sheet, testObjectAttrs, addRowIndex = 0, deleteRowsCount = 0, isVertical = true, contentColStartIndex = 1, contentTotalColCount = 77, addRowHeight = 24) => {
834
836
  if (!testObjectAttrs || testObjectAttrs.length === 0) {
835
837
  return;
836
838
  }
@@ -844,13 +846,15 @@ const BusinessUtils = {
844
846
  const testObjectAttrsChunk = rapidUtils.chunkJson(testObjectAttrs, rowTestObjectCount);
845
847
  // 暂停绘制
846
848
  sheet.suspendPaint();
847
- // // 设置工作表行数为0
848
- // sheet.setRowCount(0);
849
849
  // 获取当前Sheet的行数
850
850
  const rowCount = sheet.getRowCount();
851
- // 如果满足如下条件,则将末尾的行全部删除
852
- if (addRowIndex > 0 && addRowIndex < rowCount) {
853
- sheet.deleteRows(addRowIndex, rowCount - addRowIndex);
851
+ // 如果添加检测对象属性区域的起始行索引超过了工作表的行数,则设置addRowIndex为工作表的行数
852
+ if (addRowIndex > rowCount - 1) {
853
+ addRowIndex = rowCount;
854
+ }
855
+ // 删除行
856
+ if (deleteRowsCount > 0) {
857
+ sheet.deleteRows(addRowIndex, deleteRowsCount);
854
858
  }
855
859
  /**
856
860
  * 设置单元格字体和大小
@@ -864,7 +868,7 @@ const BusinessUtils = {
864
868
  for (let i = 0; i < testObjectAttrsChunk.length; i++) {
865
869
  const rowAttrArr = testObjectAttrsChunk[i];
866
870
  // 获取总行数
867
- const totalRowCount = sheet.getRowCount();
871
+ const totalRowCount = addRowIndex + i; //sheet.getRowCount();
868
872
  // 添加一行
869
873
  sheet.addRows(totalRowCount, 1);
870
874
  // 设置添加这一行的行高
@@ -914,6 +918,7 @@ const BusinessUtils = {
914
918
  }
915
919
  // 恢复绘制
916
920
  sheet.resumePaint();
921
+ return testObjectAttrsChunk.length;
917
922
  },
918
923
  /**
919
924
  * 获取检测对象属性值集合