rapid-spreadjs 1.0.128 → 1.0.130
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 +88 -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 +88 -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 +11 -0
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1355,6 +1355,94 @@ const BusinessUtils = {
|
|
|
1355
1355
|
spread.resumeCalcService();
|
|
1356
1356
|
spread.resumePaint();
|
|
1357
1357
|
},
|
|
1358
|
+
/**
|
|
1359
|
+
* 动态加载行(动态显示数据行和序号值)
|
|
1360
|
+
* @param GC GC对象
|
|
1361
|
+
* @param spread 工作簿实例
|
|
1362
|
+
* @param dynamicLoadRangeJson 动态加载的“试验结果”JSON数组范围,格式如:[{row: 1, col: 1, rowCount: 1, colCount: 1}]
|
|
1363
|
+
* @returns 返回所有需要显示和隐藏的行索引结果对象,格式如:{hasValueIndex: [1, 2, 3], noValueIndex: [4, 5, 6]},hasValueIndex代表所有显示的行索引,noValueIndex代表所有隐藏的行索引
|
|
1364
|
+
*/
|
|
1365
|
+
dynamicLoadRows: (GC, spread, dynamicLoadRangeJson) => {
|
|
1366
|
+
const sheet = spread.getActiveSheet();
|
|
1367
|
+
// 暂停绘制
|
|
1368
|
+
sheet.suspendPaint();
|
|
1369
|
+
// 获取所有单元格对象
|
|
1370
|
+
const cells = SheetUtils.getAllCellObjsByRanges(sheet, dynamicLoadRangeJson);
|
|
1371
|
+
// 设置所有行可见,原因是:如果再次执行的时候,第一次隐藏的行没有还原
|
|
1372
|
+
cells.forEach((item, index) => {
|
|
1373
|
+
sheet.setRowVisible(item.row, true);
|
|
1374
|
+
});
|
|
1375
|
+
// 获取按照row分组后的数据,格式如:{"1":[{row: 1, col: 43, rowCount: 1, colCount: 24}]}
|
|
1376
|
+
const cellsGroupByRow = rapidUtils.groupByJson(cells, 'row');
|
|
1377
|
+
// 获取序号列的跨列数
|
|
1378
|
+
let seqColSpanCount = null;
|
|
1379
|
+
// 最终行索引Key对应的单元格对象集合(跨行的索引)
|
|
1380
|
+
let rowCells = [];
|
|
1381
|
+
rapidUtils.forEachJson(cellsGroupByRow, (cellItems, rowIndexKey, source) => {
|
|
1382
|
+
if (seqColSpanCount == null) {
|
|
1383
|
+
const seqSpans = sheet.getSpans(sheet.getCell(parseInt(rowIndexKey), 1));
|
|
1384
|
+
seqColSpanCount = seqSpans[0].colCount;
|
|
1385
|
+
}
|
|
1386
|
+
// 得到序号列的跨行单元格对象
|
|
1387
|
+
const seqColSpanObj = sheet.getSpans({ row: parseInt(rowIndexKey), col: 1, rowCount: cellItems[0].rowCount, colCount: seqColSpanCount })[0];
|
|
1388
|
+
// 当前序号跨行单元格对应的所有单元格中是否有值
|
|
1389
|
+
let curRowHasValue = false;
|
|
1390
|
+
for (let i = 0; i < cellItems.length; i++) {
|
|
1391
|
+
// 获取当前单元格对象
|
|
1392
|
+
const cell = cellItems[i];
|
|
1393
|
+
// 获取当前单元格的值
|
|
1394
|
+
const cellValue = sheet.getValue(cell.row, cell.col);
|
|
1395
|
+
// 验证是否有值
|
|
1396
|
+
if (cellValue !== null &&
|
|
1397
|
+
cellValue !== undefined &&
|
|
1398
|
+
cellValue !== '' &&
|
|
1399
|
+
cellValue !== '/' &&
|
|
1400
|
+
!(cellValue instanceof GC.Spread.CalcEngine.CalcError)) {
|
|
1401
|
+
curRowHasValue = true;
|
|
1402
|
+
break;
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
let rowObjs = { row: parseInt(rowIndexKey), cells: cellItems, hasValue: curRowHasValue };
|
|
1406
|
+
if (!rowCells.some((x) => x.rowSpan == seqColSpanObj.row)) {
|
|
1407
|
+
rowCells.push({
|
|
1408
|
+
rowSpan: seqColSpanObj.row,
|
|
1409
|
+
rows: [rowObjs],
|
|
1410
|
+
});
|
|
1411
|
+
}
|
|
1412
|
+
else {
|
|
1413
|
+
let curRow = rowCells.find((x) => x.rowSpan == seqColSpanObj.row);
|
|
1414
|
+
curRow.rows.push(rowObjs);
|
|
1415
|
+
}
|
|
1416
|
+
});
|
|
1417
|
+
// 有值和没有值的行索引集合
|
|
1418
|
+
let hasValueRows = [], noValueRows = [];
|
|
1419
|
+
rowCells.forEach((rowObj, index) => {
|
|
1420
|
+
if (rowObj.rows.some((x) => x.hasValue)) {
|
|
1421
|
+
hasValueRows.push(rowObj.rowSpan);
|
|
1422
|
+
}
|
|
1423
|
+
else {
|
|
1424
|
+
rowObj.rows.forEach((x) => {
|
|
1425
|
+
x.cells.forEach((cell) => {
|
|
1426
|
+
noValueRows.push(cell.row);
|
|
1427
|
+
});
|
|
1428
|
+
});
|
|
1429
|
+
noValueRows.push(rowObj.rowSpan);
|
|
1430
|
+
}
|
|
1431
|
+
});
|
|
1432
|
+
hasValueRows.forEach((rowIndex, index) => {
|
|
1433
|
+
// 设置行可见
|
|
1434
|
+
sheet.setRowVisible(rowIndex, true);
|
|
1435
|
+
// 设置序号列单元格的值(1、2、3...的格式)
|
|
1436
|
+
sheet.setValue(rowIndex, 1, index + 1);
|
|
1437
|
+
});
|
|
1438
|
+
noValueRows.forEach((rowIndex) => {
|
|
1439
|
+
// 设置行不可见
|
|
1440
|
+
sheet.setRowVisible(rowIndex, false);
|
|
1441
|
+
});
|
|
1442
|
+
// 恢复绘制
|
|
1443
|
+
sheet.resumePaint();
|
|
1444
|
+
return { hasValueIndex: hasValueRows, noValueIndex: noValueRows };
|
|
1445
|
+
},
|
|
1358
1446
|
};
|
|
1359
1447
|
|
|
1360
1448
|
/**
|