rapid-spreadjs 1.0.53 → 1.0.55

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
@@ -542,9 +542,10 @@ const SheetUtils = {
542
542
  * 设置当前活动工作表的水印和数据绑定是否显示
543
543
  * @param spread 工作簿实例
544
544
  * @param cells 数据绑定单元格配置集合([{ row: number; col: number; title: string; pathPrev: string; pathField: string }])
545
- * @param isShow 是否显示
545
+ * @param isShow 是否显示水印
546
+ * @param isShowBindPath 是否显示数据绑定路径,默认为:true
546
547
  */
547
- setActiveSheetWatermark: (spread, cells, isShow) => {
548
+ setActiveSheetWatermark: (spread, cells, isShowWatermark, isShowBindPath = true) => {
548
549
  if (cells == null || cells == undefined) {
549
550
  return;
550
551
  }
@@ -553,9 +554,9 @@ const SheetUtils = {
553
554
  sheet.suspendPaint();
554
555
  cells.forEach((cell) => {
555
556
  // 设置或移除水印标签
556
- sheet.getCell(cell.row, cell.col).watermark(isShow ? `{${cell.title}}` : undefined);
557
+ sheet.getCell(cell.row, cell.col).watermark(isShowWatermark ? `{${cell.title}}` : undefined);
557
558
  // 设置或移除绑定路径
558
- sheet.setBindingPath(cell.row, cell.col, isShow ? `${cell.pathPrev}.${cell.pathField}` : undefined);
559
+ sheet.setBindingPath(cell.row, cell.col, isShowBindPath ? `${cell.pathPrev}.${cell.pathField}` : undefined);
559
560
  });
560
561
  // 恢复绘制
561
562
  sheet.resumePaint();
@@ -828,9 +829,11 @@ const BusinessUtils = {
828
829
  * @param cellRange 单元格范围JSON对象,格式为:{row:0, col:0, rowCount:2, colCount:5}
829
830
  * @param curDefaultPointCount 本次默认点数
830
831
  * @param lastDefaultPointCount 上次默认点数,默认为:0(0代表首次创建)
832
+ * @param isAutoFillFirstCellNumber 是否自动填充第一个单元格为序号数字,默认为:false
833
+ * @param created 创建完成后的回调函数,第一个参数为循环后的所有单元格范围对象(格式为:{row:0, col:0, rowCount:10, colCount:5}),第二个参数为所有循环行的单元格二维数组对象
831
834
  * @param rowHeight 创建的行高度,默认为:24(单位为像素)
832
835
  */
833
- dynamicCreateCyclicRows: (GC, spread, cellRange, curDefaultPointCount, lastDefaultPointCount = 0, rowHeight = 24) => {
836
+ dynamicCreateCyclicRows: (GC, spread, cellRange, curDefaultPointCount, lastDefaultPointCount = 0, isAutoFillFirstCellNumber = false, created = null, rowHeight = 24) => {
834
837
  // 不进行动态创建行
835
838
  if ((curDefaultPointCount <= 1 && lastDefaultPointCount == 0) || (curDefaultPointCount == lastDefaultPointCount && lastDefaultPointCount > 0)) {
836
839
  return;
@@ -889,12 +892,41 @@ const BusinessUtils = {
889
892
  else if (curDefaultPointCount > 1 && lastDefaultPointCount == 0) {
890
893
  addRowsFun(cellRange.row + cellRange.rowCount, (curDefaultPointCount - 1) * cellRange.rowCount, curDefaultPointCount - 1);
891
894
  }
895
+ // 循环后的所有单元格范围
896
+ const cyclicCellsRangeObj = sheet.getRange(cellRange.row, cellRange.col, curDefaultPointCount * cellRange.rowCount, cellRange.colCount);
892
897
  // 判断要循环的单元格最后一行是否为表格的末尾行,如果是,则在循环创建单元行的最后一行的时候,下边框线位细线样式
893
898
  if (isCyclicLastRowIsSheetLastRow) {
894
899
  // 设置所有内边框线为细线样式
895
- sheet
896
- .getRange(cellRange.row, cellRange.col, curDefaultPointCount * cellRange.rowCount, cellRange.colCount)
897
- .setBorder(new GC.Spread.Sheets.LineBorder('#000', GC.Spread.Sheets.LineStyle.thin), { inside: true });
900
+ cyclicCellsRangeObj.setBorder(new GC.Spread.Sheets.LineBorder('#000', GC.Spread.Sheets.LineStyle.thin), { inside: true });
901
+ }
902
+ // 循环后的所有单元格范围JSON对象
903
+ const cyclicCellsRange = {
904
+ row: cyclicCellsRangeObj.row,
905
+ col: cyclicCellsRangeObj.col,
906
+ rowCount: cyclicCellsRangeObj.rowCount,
907
+ colCount: cyclicCellsRangeObj.colCount,
908
+ };
909
+ // 自动填充第一个单元格为序号数字
910
+ const allCells = SheetUtils.getAllCellObjsByRanges(sheet, [cyclicCellsRange]);
911
+ const allCellsByRowObj = rapidUtils.groupByJson(allCells, 'row');
912
+ let allCellsByRow = [];
913
+ if (isAutoFillFirstCellNumber) {
914
+ rapidUtils.forEachJson(allCellsByRowObj, (value, key, source) => {
915
+ allCellsByRow.push(value);
916
+ });
917
+ let number = 0;
918
+ allCellsByRow.forEach((rowCells, rowIndex) => {
919
+ rowCells.forEach((rowCell, cellIndex) => {
920
+ if (cellIndex == 0) {
921
+ number++;
922
+ sheet.setValue(rowCell.row, rowCell.col, number);
923
+ }
924
+ });
925
+ });
926
+ }
927
+ // 创建完成后的回调函数
928
+ if (created != null && created != undefined && typeof created === 'function') {
929
+ created(cyclicCellsRange, allCellsByRow);
898
930
  }
899
931
  // 恢复绘制
900
932
  sheet.resumePaint();