[英]Display message Google Sheets from Apps Script
I want to display a message on a google sheet.我想在谷歌表格上显示一条消息。 But I don't get it, and, after research here, in documentation, I don't get the answer.
但我不明白,而且,在这里研究之后,在文档中,我没有得到答案。
I think that the problem is in "activate" the spreadsheet, where i need to display.我认为问题在于“激活”电子表格,我需要在其中显示。
var SEGUIMIENTO = SpreadsheetApp.openById("MyTestediD");
var INF = SEGUIMIENTO.getSheetByName("NameOfSheet");
function TestMessage() {
INF.activate();
Browser.msgBox("Hello")
}
When i run.. nothing happen当我跑步时..什么也没发生
I need the definition of Spreadsheet outside the function because I'm working in 2 Spreadsheet's by ID in more that one function.我需要在函数外部定义电子表格,因为我在不止一个函数中按 ID 使用 2 个电子表格。
i only need the correction in my code for display a simple message in the spreadsheet.我只需要更正我的代码即可在电子表格中显示一条简单的消息。
PD. PD。 i really cant find a simple example of that,
我真的找不到一个简单的例子,
Update更新
This code it's part of a macro recorder of a Spreadsheet, the same "SpreadsheetApp.openById("MyTestediD");"此代码是电子表格宏记录器的一部分,相同的“SpreadsheetApp.openById("MyTestediD");"
I don't know why you try to 'activate' a sheet.我不知道你为什么要“激活”一张纸。 If you want display a message I assume you want to do it in the user's current sheet, so:
如果你想显示一条消息,我假设你想在用户的当前工作表中这样做,所以:
SpreadsheetApp.getUi().alert('Confirmation received.');
From https://developers.google.com/apps-script/reference/base/browser来自https://developers.google.com/apps-script/reference/base/browser
The methods in this class are only available for use in the context of a Google Spreadsheet.
此类中的方法只能在 Google 电子表格的上下文中使用。 Please use G Suite dialogs instead.
请改用G Suite 对话框。
As you can see, Google is nicely asking you to use G Suite dialogs instead of Class Browser, so be nice too and follow their request.如您所见,Google 很友好地要求您使用G Suite 对话框而不是类浏览器,所以也请您听从他们的要求。
When you say you want a message in a spreeadsheet, do you mean an alert message?当您说您想要电子表格中的消息时,您是指警告消息吗? If so, the answer is to use the code SpreadsheetApp.getUi().alert('Hello.');
如果是这样,答案是使用代码 SpreadsheetApp.getUi().alert('Hello.'); when the TestMessage function is executed
当执行 TestMessage 函数时
var SEGUIMIENTO = SpreadsheetApp.openById("My TestediD");
var INF = SEGUIMIENTO.getSheetByName("NameOfSheet");
function TestMessage() {
INF.activate();
SpreadsheetApp.getUi().alert('Hello.');
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.