本帖最后由 高阳0910 于 2024-8-26 15:08 编辑
vue版本 3.2.33。 业务就是自定义右键菜单 进行sheetTab的操作,现在插入以后空白页。
<div class="excel-container" v-resize="handleResize">
<gc-spread-sheets
class="spread-container"
@workbookInitialized="initSpread"
/>
<div id="statusBar"></div>
</div>
initSpread (spread) {
this.spread = GC.Spread.Sheets.findControl(spread.getHost());
this.initStatusBar()
this.spread.suspendPaint()
this.initFirstSheet()
this.spread.options.tabEditable = false;
this.spread.options.newTabVisible = false;
this.spread.resumePaint()
this.setEvent()
this.getCWBBGSRightMenu(this.spread, '')
},
getCWBBGSRightMenu (spread, type) {
const that = this
spread
.commandManager()
.register(
'insertSheet',
{
canUndo: true,
execute: function (context, options, isUndo) {
var Commands = GC.Spread.Sheets.Commands;
// 在此加cmd
options.cmd = 'insertSheet';
if (isUndo) {
Commands.undoTransaction(context, options);
return true;
} else {
Commands.startTransaction(context, options);
that.$Message.info('新增sheet,弹框新增')
spread.suspendPaint()
let sheetCount = spread.getSheetCount()
spread.addSheet(sheetCount + 1, new GC.Spread.Sheets.Worksheet('报表2'))
spread.resumePaint()
console.log(sheetCount)
// that.initFirstSheet(sheetCount + 1, '报表2')
Commands.endTransaction(context, options);
return true;
}
}
});
let insertSheet = {
command: 'insertSheet',
text: '添加报表',
name: 'insertSheet',
iconClass: 'gc-spread-custom-icon',
workArea: 'sheetTab'
};
spread.contextMenu.menuData = [insertSheet]
},
|
-
|