Szukaj…


Składnia

  1. addMenu (nazwa, podmenu)

Parametry

Nazwa Opis
Nazwa nazwa menu, które ma zostać utworzone
subMenus tablica map JavaScript

Uwagi

Zwykle będziesz chciał wywołać addMenu z funkcji onOpen, aby menu było tworzone automatycznie po załadowaniu arkusza kalkulacyjnego.

 // The onOpen function is executed automatically every time a Spreadsheet is loaded
 function onOpen() {
   var activeSheet = SpreadsheetApp.getActiveSpreadsheet();
   var menuItems = [];
   // When the user clicks on "addMenuExample" then "Menu 1", the function Myfunction1 is executed.
   menuItems.push({name: "Menu 1", functionName: "Myfunction1"});
   menuItems.push(null); // adding line separator
   menuItems.push({name: "Menu 2", functionName: "Myfunction2"});

   activeSheet.addMenu("addMenuExample", menuEntries);
 }

Utwórz nowe menu

Tworzy nowe menu w interfejsie użytkownika arkusza kalkulacyjnego. Każda pozycja menu uruchamia funkcję zdefiniowaną przez użytkownika.

   var activeSheet = SpreadsheetApp.getActiveSpreadsheet();
   var menuItems = [];
   // When the user clicks on "addMenuExample" then "Menu 1", the function Myfunction1 is executed.
   menuItems.push({name: "Menu 1", functionName: "Myfunction1"});
   menuItems.push(null); // adding line separator
   menuItems.push({name: "Menu 2", functionName: "Myfunction2"});

   activeSheet.addMenu("addMenuExample", menuEntries);

Utwórz własne menu

/ *


Metoda: Aby utworzyć niestandardowe menu Jest to pierwsza funkcja wywoływana podczas ładowania aplikacji


* /

function onOpen() {
  var ui = SpreadsheetApp.getUi();
  // Or DocumentApp or FormApp.
  ui.createMenu('My HR')
      .addItem('Send Form to All', 'sendIDPForm_All')
      .addItem('Trigger IDP System', 'applyCategory')
      .addToUi();
}


Modified text is an extract of the original Stack Overflow Documentation
Licencjonowany na podstawie CC BY-SA 3.0
Nie związany z Stack Overflow