rapid-spreadjs 1.0.52 → 1.0.54

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
@@ -806,15 +806,19 @@ const BusinessUtils = {
806
806
  * @param cellRange 单元格范围JSON对象,格式为:{row:0, col:0, rowCount:2, colCount:5}
807
807
  * @param curDefaultPointCount 本次默认点数
808
808
  * @param lastDefaultPointCount 上次默认点数,默认为:0(0代表首次创建)
809
+ * @param isAutoFillFirstCellNumber 是否自动填充第一个单元格为序号数字,默认为:false
810
+ * @param created 创建完成后的回调函数,第一个参数为循环后的所有单元格范围对象(格式为:{row:0, col:0, rowCount:10, colCount:5}),第二个参数为所有循环行的单元格二维数组对象
809
811
  * @param rowHeight 创建的行高度,默认为:24(单位为像素)
810
812
  */
811
- dynamicCreateCyclicRows: (GC, spread, cellRange, curDefaultPointCount, lastDefaultPointCount = 0, rowHeight = 24) => {
813
+ dynamicCreateCyclicRows: (GC, spread, cellRange, curDefaultPointCount, lastDefaultPointCount = 0, isAutoFillFirstCellNumber = false, created = null, rowHeight = 24) => {
812
814
  // 不进行动态创建行
813
815
  if ((curDefaultPointCount <= 1 && lastDefaultPointCount == 0) || (curDefaultPointCount == lastDefaultPointCount && lastDefaultPointCount > 0)) {
814
816
  return;
815
817
  }
816
818
  // 获取当前工作表
817
819
  const sheet = spread.getActiveSheet();
820
+ // 判断要循环的单元格最后一行是否为表格的末尾行,如果是,则在循环创建单元行的最后一行的时候,下边框线位细线样式
821
+ const isCyclicLastRowIsSheetLastRow = cellRange.row + cellRange.rowCount == sheet.getRowCount();
818
822
  /**
819
823
  * 添加行
820
824
  * @param addRowIndex 添加行的索引位置
@@ -865,6 +869,42 @@ const BusinessUtils = {
865
869
  else if (curDefaultPointCount > 1 && lastDefaultPointCount == 0) {
866
870
  addRowsFun(cellRange.row + cellRange.rowCount, (curDefaultPointCount - 1) * cellRange.rowCount, curDefaultPointCount - 1);
867
871
  }
872
+ // 循环后的所有单元格范围
873
+ const cyclicCellsRangeObj = sheet.getRange(cellRange.row, cellRange.col, curDefaultPointCount * cellRange.rowCount, cellRange.colCount);
874
+ // 判断要循环的单元格最后一行是否为表格的末尾行,如果是,则在循环创建单元行的最后一行的时候,下边框线位细线样式
875
+ if (isCyclicLastRowIsSheetLastRow) {
876
+ // 设置所有内边框线为细线样式
877
+ cyclicCellsRangeObj.setBorder(new GC.Spread.Sheets.LineBorder('#000', GC.Spread.Sheets.LineStyle.thin), { inside: true });
878
+ }
879
+ // 循环后的所有单元格范围JSON对象
880
+ const cyclicCellsRange = {
881
+ row: cyclicCellsRangeObj.row,
882
+ col: cyclicCellsRangeObj.col,
883
+ rowCount: cyclicCellsRangeObj.rowCount,
884
+ colCount: cyclicCellsRangeObj.colCount,
885
+ };
886
+ // 自动填充第一个单元格为序号数字
887
+ const allCells = SheetUtils.getAllCellObjsByRanges(sheet, [cyclicCellsRange]);
888
+ const allCellsByRowObj = groupByJson(allCells, 'row');
889
+ let allCellsByRow = [];
890
+ if (isAutoFillFirstCellNumber) {
891
+ forEachJson(allCellsByRowObj, (value, key, source) => {
892
+ allCellsByRow.push(value);
893
+ });
894
+ let number = 0;
895
+ allCellsByRow.forEach((rowCells, rowIndex) => {
896
+ rowCells.forEach((rowCell, cellIndex) => {
897
+ if (cellIndex == 0) {
898
+ number++;
899
+ sheet.setValue(rowCell.row, rowCell.col, number);
900
+ }
901
+ });
902
+ });
903
+ }
904
+ // 创建完成后的回调函数
905
+ if (created != null && created != undefined && typeof created === 'function') {
906
+ created(cyclicCellsRange, allCellsByRow);
907
+ }
868
908
  // 恢复绘制
869
909
  sheet.resumePaint();
870
910
  },