rapid-spreadjs 1.0.50 → 1.0.51
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 +69 -0
- 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 +69 -0
- 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 +15 -0
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -791,6 +791,75 @@ const BusinessUtils = {
|
|
|
791
791
|
sheet.resumePaint();
|
|
792
792
|
return retData;
|
|
793
793
|
},
|
|
794
|
+
/**
|
|
795
|
+
* 动态创建循环行
|
|
796
|
+
* @param GC GC对象
|
|
797
|
+
* @param spread 工作簿实例
|
|
798
|
+
* @param cellRange 单元格范围JSON对象,格式为:{row:0, col:0, rowCount:2, colCount:5}
|
|
799
|
+
* @param curDefaultPointCount 本次默认点数
|
|
800
|
+
* @param lastDefaultPointCount 上次默认点数,默认为:0(0代表首次创建)
|
|
801
|
+
* @param rowHeight 创建的行高度,默认为:24(单位为像素)
|
|
802
|
+
*/
|
|
803
|
+
dynamicCreateCyclicRows: (GC, spread, cellRange, curDefaultPointCount, lastDefaultPointCount = 0, rowHeight = 24) => {
|
|
804
|
+
// 不进行动态创建行
|
|
805
|
+
if ((curDefaultPointCount <= 1 && lastDefaultPointCount == 0) || (curDefaultPointCount == lastDefaultPointCount && lastDefaultPointCount > 0)) {
|
|
806
|
+
return;
|
|
807
|
+
}
|
|
808
|
+
// 获取当前工作表
|
|
809
|
+
const sheet = spread.getActiveSheet();
|
|
810
|
+
/**
|
|
811
|
+
* 添加行
|
|
812
|
+
* @param addRowIndex 添加行的索引位置
|
|
813
|
+
* @param addRowCount 添加行的数量
|
|
814
|
+
* @param copyPointCount 复制点数的数量
|
|
815
|
+
* @param targetRowIndex 循环复制的时候,需要加上的行索引,默认为0
|
|
816
|
+
*/
|
|
817
|
+
const addRowsFun = (addRowIndex, addRowCount, copyPointCount, targetRowIndex = 0) => {
|
|
818
|
+
// 添加需要循环的总行数
|
|
819
|
+
sheet.addRows(addRowIndex, addRowCount);
|
|
820
|
+
// 设置添加行的行高
|
|
821
|
+
for (let i = addRowIndex; i <= addRowIndex + addRowCount; i++) {
|
|
822
|
+
sheet.setRowHeight(i, rowHeight, GC.Spread.Sheets.SheetArea.viewport);
|
|
823
|
+
}
|
|
824
|
+
// 复制次数,每次复制到下方相邻位置
|
|
825
|
+
for (let i = 1; i <= copyPointCount; i++) {
|
|
826
|
+
// 计算目标起始行
|
|
827
|
+
const targetRow = cellRange.row + targetRowIndex + i * cellRange.rowCount;
|
|
828
|
+
// 使用sheet.copyTo方法进行复制
|
|
829
|
+
sheet.copyTo(cellRange.row, // 源起始行
|
|
830
|
+
cellRange.col, // 源起始列
|
|
831
|
+
targetRow, // 目标起始行
|
|
832
|
+
cellRange.col, // 目标起始列
|
|
833
|
+
cellRange.rowCount, // 源行数
|
|
834
|
+
cellRange.colCount, // 源列数
|
|
835
|
+
GC.Spread.Sheets.CopyToOptions.all // 复制内容类型(值、样式、公式等)
|
|
836
|
+
);
|
|
837
|
+
}
|
|
838
|
+
};
|
|
839
|
+
// 暂停绘制
|
|
840
|
+
sheet.suspendPaint();
|
|
841
|
+
// 当前默认点数<=1并且上一次默认点数>0的时候,则删除所有循环的行
|
|
842
|
+
if (curDefaultPointCount <= 1 && lastDefaultPointCount > 0) {
|
|
843
|
+
sheet.deleteRows(cellRange.row + cellRange.rowCount, (curDefaultPointCount - 1) * cellRange.rowCount);
|
|
844
|
+
}
|
|
845
|
+
// 当前默认点数>1并且上次默认点数>1的时候
|
|
846
|
+
else if (curDefaultPointCount > 1 && lastDefaultPointCount > 1) {
|
|
847
|
+
// 当前默认点数>上次默认点数时,则需要增加curDefaultPointCount-lastDefaultPointCount次循环
|
|
848
|
+
if (curDefaultPointCount > lastDefaultPointCount) {
|
|
849
|
+
addRowsFun(cellRange.row + cellRange.rowCount + (curDefaultPointCount - lastDefaultPointCount - 1) * cellRange.rowCount, (curDefaultPointCount - lastDefaultPointCount) * cellRange.rowCount, curDefaultPointCount - lastDefaultPointCount, (curDefaultPointCount - lastDefaultPointCount - 1) * cellRange.rowCount);
|
|
850
|
+
}
|
|
851
|
+
// 当前默认点数<上次默认点数时,则需要删除lastDefaultPointCount-curDefaultPointCount次循环所在的行
|
|
852
|
+
else if (curDefaultPointCount < lastDefaultPointCount) {
|
|
853
|
+
sheet.deleteRows(cellRange.row + cellRange.rowCount + (curDefaultPointCount - 1) * cellRange.rowCount, (lastDefaultPointCount - curDefaultPointCount) * cellRange.rowCount);
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
// 循环添加所有行
|
|
857
|
+
else if (curDefaultPointCount > 1 && lastDefaultPointCount == 0) {
|
|
858
|
+
addRowsFun(cellRange.row + cellRange.rowCount, (curDefaultPointCount - 1) * cellRange.rowCount, curDefaultPointCount - 1);
|
|
859
|
+
}
|
|
860
|
+
// 恢复绘制
|
|
861
|
+
sheet.resumePaint();
|
|
862
|
+
},
|
|
794
863
|
};
|
|
795
864
|
|
|
796
865
|
/**
|