向 onOpen 条目对象中的函数添加参数 [英] Adding arguments to a function in the onOpen entries object
本文介绍了向 onOpen 条目对象中的函数添加参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有一种方法可以向将添加到 Google 电子表格文档的脚本中心菜单中的函数添加参数?这是正常的 onOpen 方法.
Is there are a way I can add arguments to a function that will be added to the Script Center Menu on a Google Spreadsheet document? This is the normal onOpen method.
function onOpen() {
var sheet = SpreadsheetApp.getActiveSpreadsheet();
var entries = [{
name : "Summary",
functionName : "myOnOpen"
}
];
sheet.addMenu("Script Center Menu", entries);
};
我想知道是否有类似以下的内容.
I was wondering if there is something similar to the following.
function onOpen() {
var sheet = SpreadsheetApp.getActiveSpreadsheet();
var entries = [{
name : "Summary",
functionName : "myOnOpen",
arguments : [value: "Some value"]
}
];
sheet.addMenu("Script Center Menu", entries);
};
谢谢!
推荐答案
我不认为这完全像你写的那样可行,但你可以通过以下方式做到:
I don't think that is possible exactly as you have written, but you can do it in the following way:
function onOpen() {
var sheet = SpreadsheetApp.getActiveSpreadsheet();
var entries = [{
name : "Summary",
functionName : "myParameterisedOpen",
}
];
sheet.addMenu("Script Center Menu", entries);
};
function myParameterisedOpen() {
myOnOpen("Some value");
};
这篇关于向 onOpen 条目对象中的函数添加参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文