本帖最后由 王公子-_- 于 2025-12-30 16:17 编辑
目前是找到问题是哪里导致的了但是原理不清楚,是为其他普通sheet设置了条件格式、数据验证、公式等操作,去掉这个操作就一直隐藏
- this.workbook.suspendPaint();
- this.workbook.fromJSON(templateContent, {
- doNotRecalculateAfterLoad: true
- });
- this.workbook.options.highlightInvalidData = true; // 当单元格中的数据无效时,单元格中会显示一个红色的圆圈
- this.workbook.options.allowCopyPasteExcelStyle = false;
- const sheetCount = this.workbook.getSheetCount();
- const activeIndex = this.workbook.getActiveSheetIndex();
- if (-1 !== activeIndex) {
- this.initActiveSheet(this.workbook.getActiveSheet());
- }
- for (let sheetIndex = 0; sheetIndex < sheetCount; sheetIndex++) {
- if (activeIndex === sheetIndex) {
- continue;
- }
- const sheet = this.workbook.getSheet(sheetIndex);
- this.initActiveSheet(sheet);
- }
- // 隐藏报表模版sheet
- const reportSheetCnt = this.workbook.getSheetTabCount();
- for (let index = 0; index < reportSheetCnt; index++) {
- const reportSheet = this.workbook.getSheetTab(index);
- reportSheet.visible(GC.Spread.Sheets.SheetTabVisible.veryHidden);
- }
- this.workbook.resumePaint();
复制代码- initActiveSheet(sheet) {
- if (!sheet) {
- return;
- }
- const sheetTag = sheet.tag();
- sheet.options.isProtected = false;
- sheet.options.clipBoardOptions = GC.Spread.Sheets.ClipboardPasteOptions.values;
- if (sheet.isReportSheetPaginatedWorksheet || (sheetTag && sheetTag.isReportSheetPaginatedWorksheet)) {
- return; // 报表分页sheet不处理数据源等
- }
- const source = new GC.Spread.Sheets.Bindings.CellBindingSource(this.dataJson);
- // setSheetValidation(sheet, this.documentInfo, this.structFieldsMap);
复制代码 目前有哪些已知的操作比如设置条件格式、数据验证、公式等会影响sheet的显示/隐藏么,如果没有我继续定位我的代码吧 |