您好,您可以通过自定义右键菜单,并将excute中放入您的逻辑代码即可
var commandManager = spread.commandManager();
var getSelectionsMenu = {
text: "获取单元格坐标",
name: "getCellDistinction",
workArea: "viewport",
command: "getSelections"
};
spread.contextMenu.menuData.push(getSelectionsMenu);
var getSelectionsCommand = {
canUndo: false,
execute: function (spread, options) {
var range = new GC.Spread.Sheets.Range(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex(), 1, 1)
// 坐标转换
var value = GC.Spread.Sheets.CalcEngine.rangeToFormula(range, 0, 0, GC.Spread.Sheets.CalcEngine.RangeReferenceRelative.allRelative);
console.log(value);
},
};
commandManager.register(
"getSelections",
getSelectionsCommand,
null,
false,
false,
false,
false
); |