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.esm.js CHANGED
@@ -803,12 +803,14 @@ const BusinessUtils = {
803
803
  * @param sheet 工作表实例
804
804
  * @param testObjectAttrs 检测对象属性配置集合
805
805
  * @param addRowIndex 添加检测对象属性区域的起始行索引,默认为:0
806
+ * @param deleteRowsCount 删除的行数,默认为:0
806
807
  * @param isVertical 是否为纵表,默认为:true
807
808
  * @param contentColStartIndex 表格内容列起始索引,默认为:1
808
809
  * @param contentTotalColCount 表格内容列总数,默认为:77
809
810
  * @param addRowHeight 添加的表格行高,默认为:24(单位为像素)
811
+ * @returns 返回生成的检测对象属性行数
810
812
  */
811
- createTestObjectAttrsCells: (gc, sheet, testObjectAttrs, addRowIndex = 0, isVertical = true, contentColStartIndex = 1, contentTotalColCount = 77, addRowHeight = 24) => {
813
+ createTestObjectAttrsCells: (gc, sheet, testObjectAttrs, addRowIndex = 0, deleteRowsCount = 0, isVertical = true, contentColStartIndex = 1, contentTotalColCount = 77, addRowHeight = 24) => {
812
814
  if (!testObjectAttrs || testObjectAttrs.length === 0) {
813
815
  return;
814
816
  }
@@ -822,13 +824,15 @@ const BusinessUtils = {
822
824
  const testObjectAttrsChunk = chunkJson(testObjectAttrs, rowTestObjectCount);
823
825
  // 暂停绘制
824
826
  sheet.suspendPaint();
825
- // // 设置工作表行数为0
826
- // sheet.setRowCount(0);
827
827
  // 获取当前Sheet的行数
828
828
  const rowCount = sheet.getRowCount();
829
- // 如果满足如下条件,则将末尾的行全部删除
830
- if (addRowIndex > 0 && addRowIndex < rowCount) {
831
- sheet.deleteRows(addRowIndex, rowCount - addRowIndex);
829
+ // 如果添加检测对象属性区域的起始行索引超过了工作表的行数,则设置addRowIndex为工作表的行数
830
+ if (addRowIndex > rowCount - 1) {
831
+ addRowIndex = rowCount;
832
+ }
833
+ // 删除行
834
+ if (deleteRowsCount > 0) {
835
+ sheet.deleteRows(addRowIndex, deleteRowsCount);
832
836
  }
833
837
  /**
834
838
  * 设置单元格字体和大小
@@ -842,7 +846,7 @@ const BusinessUtils = {
842
846
  for (let i = 0; i < testObjectAttrsChunk.length; i++) {
843
847
  const rowAttrArr = testObjectAttrsChunk[i];
844
848
  // 获取总行数
845
- const totalRowCount = sheet.getRowCount();
849
+ const totalRowCount = addRowIndex + i; //sheet.getRowCount();
846
850
  // 添加一行
847
851
  sheet.addRows(totalRowCount, 1);
848
852
  // 设置添加这一行的行高
@@ -892,6 +896,7 @@ const BusinessUtils = {
892
896
  }
893
897
  // 恢复绘制
894
898
  sheet.resumePaint();
899
+ return testObjectAttrsChunk.length;
895
900
  },
896
901
  /**
897
902
  * 获取检测对象属性值集合