给你看下我的代码,直接拿过来了,还是不生效,不知道哪里问题,我把我的代码贴出来,你帮忙看下。这样我能更好的理解一些,然后有没有表格编辑器相关的视频可以看啊,我看到的好像都是spreadJS 的视频,这样对于初学者来说,很容易搞混。
- import '@grapecity/spread-sheets/styles/gc.spread.sheets.excel2013white.css'
- import '@grapecity/spread-sheets-designer/styles/gc.spread.sheets.designer.min.css'
- import GC from '@grapecity/spread-sheets'
- import '@grapecity/spread-sheets-shapes'
- import '@grapecity/spread-sheets-charts'
- import '@grapecity/spread-sheets-slicers'
- import '@grapecity/spread-sheets-print'
- import '@grapecity/spread-sheets-barcode'
- import '@grapecity/spread-sheets-tablesheet'
- import '@grapecity/spread-sheets-formula-panel'
- import '@grapecity/spread-sheets-io'
- import '@grapecity/spread-sheets-resources-zh'
- import '@grapecity/spread-sheets-designer-resources-cn'
- import GCDesigner from '@grapecity/spread-sheets-designer'
复制代码- GC.Spread.Common.CultureManager.culture('zh-cn')
- // Designer实例
- let designer = GCDesigner.Spread.Sheets.Designer.Designer
- let spread = GC.Spread.Sheets.Workbook
- onMounted(() => {
- let config = GC.Spread.Sheets.Designer.DefaultConfig;
- config.commandMap = {};
- config.commandMap.batchInsertRowContextMenu = {
- text: '批量插入',
- commandName: "batchInsertRowContextMenu",
- visibleContext: "ClickRowHeader",
- subCommands: [
- "batchInsertRows10",
- "batchInsertRows50",
- "batchInsertRows100"
- ]
- };
- config.commandMap.batchInsertRows10 = {
- text: '插入 10 行',
- commandName: "batchInsertRows10",
- execute: async (context, propertyName, fontItalicChecked) => {
- var commandManager = context.Spread.commandManager();
- commandManager.execute({cmd: "insertRowAndCopyContent", sheetName: context.Spread.getActiveSheet().name(),rowCount:10});
- }
- };
- config.commandMap.batchInsertRows50 = {
- text: '插入 50 行',
- commandName: "batchInsertRows50",
- execute: async (context, propertyName, fontItalicChecked) => {
- var commandManager = context.Spread.commandManager();
- commandManager.execute({cmd: "insertRowAndCopyContent", sheetName: context.Spread.getActiveSheet().name(),rowCount:50});
- }
- };
- config.commandMap.batchInsertRows100 = {
- text: '插入 100 行',
- commandName: "batchInsertRows100",
- execute: async (context, propertyName, fontItalicChecked) => {
- var commandManager = context.Spread.commandManager();
- commandManager.execute({cmd: "insertRowAndCopyContent", sheetName: context.Spread.getActiveSheet().name(),rowCount:100});
- }
- };
-
- config.contextMenu.push("batchInsertRowContextMenu");
-
- config.commandMap["gc.spread.contextMenu.insertRows"] = {
- commandName: "myInsertRows",
- enableContext: "AllowInsertRows && selectFullRows",
- text: "插入",
- visibleContext: "ClickRowHeader && !AllowInsertCopiedCutCells",
- execute: async (context, propertyName) => {
- var commandManager = context.Spread.commandManager();
- commandManager.execute({cmd: "insertRowAndCopyContent", sheetName: context.Spread.getActiveSheet().name(),rowCount:1});
- }
- };
- // designer = new GCDesigner.Spread.Sheets.Designer.Designer('designer-container',config);
- designer = new GC.Spread.Sheets.Designer.Designer(document.getElementById("designer-container"), config);
- spread = designer.getWorkbook();
- var commandManager = spread.commandManager();
- let insertRowAndCopyContent = {
- canUndo: true,
- execute: function (context, options, isUndo) {
- let Commands = GC.Spread.Sheets.Commands;
- options.cmd = "insertRowAndCopyContent";
- console.log(options, '--options---')
- if (isUndo) {
- Commands.undoTransaction(context, options);
- return true;
- } else {
- Commands.startTransaction(context, options);
- context.suspendPaint();
- context.suspendEvent();
- var sheet = context.getSheetFromName(options.sheetName);
- var selections = sheet.getSelections();
-
- for(var i = 0; i < selections.length; i++){
- var row = selections[i].row;
- sheet.addRows(row,options.rowCount);
- var fromRange = [new GC.Spread.Sheets.Range(row + options.rowCount, 0, 1, sheet.getColumnCount())];
- var toRanges = [new GC.Spread.Sheets.Range(row, 0, options.rowCount, sheet.getColumnCount())];
- spread.commandManager().execute({cmd: "clipboardPaste", sheetName: options.sheetName, fromSheet: sheet, fromRanges: fromRange, pastedRanges: toRanges, isCutting: false, clipboardText: "", pasteOption: GC.Spread.Sheets.ClipboardPasteOptions.formulasAndFormatting});
- }
-
- context.resumeEvent();
- context.resumePaint();
- Commands.endTransaction(context, options);
- return true;
- }
- }
- };
- var commandManager = spread.commandManager();
- commandManager.register("insertRowAndCopyContent", insertRowAndCopyContent);
- })
复制代码
我是把这个dome下载下来后,把里面的代码,copy进去,还是没有生效。
|