Class Menu
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
메뉴
Google 앱의 사용자 인터페이스 인스턴스에 있는 맞춤 메뉴입니다. 스크립트는 열려 있는 문서 또는 양식의 현재 인스턴스에 대한 UI와만 상호작용할 수 있으며, 스크립트가 문서 또는 양식에 컨테이너 결합된 경우에만 상호작용할 수 있습니다. 자세한 내용은 메뉴 가이드를 참고하세요.
// Add a custom menu to the active spreadsheet, including a separator and a
// sub-menu.
function onOpen(e) {
SpreadsheetApp.getUi()
.createMenu('My Menu')
.addItem('My Menu Item', 'myFunction')
.addSeparator()
.addSubMenu(
SpreadsheetApp.getUi()
.createMenu('My Submenu')
.addItem('One Submenu Item', 'mySecondFunction')
.addItem('Another Submenu Item', 'myThirdFunction'),
)
.addToUi();
}
자세한 문서
addItem(caption, functionName)
메뉴에 항목을 추가합니다. 메뉴 항목의 라벨은 문장 첫 글자 대문자 (첫 단어만 대문자)로 표시해야 합니다.
매개변수
이름 | 유형 | 설명 |
caption | String | 메뉴 항목의 라벨로, 첫 단어만 대문자로 표시됩니다. |
functionName | String | 사용자가 항목을 선택할 때 호출할 함수의 이름입니다. 포함된 라이브러리(예: Library.libFunction1 )의 함수를 사용할 수 있습니다. |
리턴
Menu
— 체이닝을 위한 이 Menu
addSeparator()
메뉴에 시각적 구분 기호를 추가합니다.
리턴
Menu
— 체이닝을 위한 이 Menu
addToUi()
편집기 사용자 인터페이스의 인스턴스에 메뉴를 삽입합니다.
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-07-26(UTC)
[null,null,["최종 업데이트: 2025-07-26(UTC)"],[[["\u003cp\u003eThe \u003ccode\u003eMenu\u003c/code\u003e class allows you to create custom menus in Google Apps Script, adding items, separators, and submenus.\u003c/p\u003e\n"],["\u003cp\u003eMenus can be used to provide users with easy access to script functionalities within the active document or form.\u003c/p\u003e\n"],["\u003cp\u003eMenu items are linked to specific functions within your script using the \u003ccode\u003eaddItem()\u003c/code\u003e method.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eaddToUi()\u003c/code\u003e inserts the created menu into the user interface of the current Google App instance.\u003c/p\u003e\n"],["\u003cp\u003eThe provided code example demonstrates creating a basic custom menu with a submenu.\u003c/p\u003e\n"]]],[],null,["# Class Menu\n\nMenu\n\nA custom menu in an instance of the user interface for a Google App. A script can only interact\nwith the UI for the current instance of an open document or form, and only if the script is [container-bound](/apps-script/scripts_containers) to the document or form. For more\ninformation, see the [guide to menus](/apps-script/guides/menus).\n\n```javascript\n// Add a custom menu to the active spreadsheet, including a separator and a\n// sub-menu.\nfunction onOpen(e) {\n SpreadsheetApp.getUi()\n .createMenu('My Menu')\n .addItem('My Menu Item', 'myFunction')\n .addSeparator()\n .addSubMenu(\n SpreadsheetApp.getUi()\n .createMenu('My Submenu')\n .addItem('One Submenu Item', 'mySecondFunction')\n .addItem('Another Submenu Item', 'myThirdFunction'),\n )\n .addToUi();\n}\n``` \n\n### Methods\n\n| Method | Return type | Brief description |\n|-----------------------------------------------------------|-------------|--------------------------------------------------------------------|\n| [addItem(caption, functionName)](#addItem(String,String)) | [Menu](#) | Adds an item to the menu. |\n| [addSeparator()](#addSeparator()) | [Menu](#) | Adds a visual separator to the menu. |\n| [addSubMenu(menu)](#addSubMenu(Menu)) | [Menu](#) | Adds a sub-menu to the menu. |\n| [addToUi()](#addToUi()) | `void` | Inserts the menu into the instance of the editor's user interface. |\n\nDetailed documentation\n----------------------\n\n### `add``Item(caption, functionName)`\n\nAdds an item to the menu. The label for a menu item should be in sentence case (only the first\nword capitalized).\n\n#### Parameters\n\n| Name | Type | Description |\n|------------------|----------|---------------------------------------------------------------------------------------------------------------------------------------------------|\n| `caption` | `String` | The label for the menu item, with only the first word capitalized. |\n| `function``Name` | `String` | The name of the function to invoke when the user selects the item. You can use functions from included libraries, such as `Library.libFunction1`. |\n\n#### Return\n\n\n[Menu](#) --- This [Menu](#), for chaining.\n\n*** ** * ** ***\n\n### `add``Separator()`\n\nAdds a visual separator to the menu.\n\n#### Return\n\n\n[Menu](#) --- This [Menu](#), for chaining.\n\n*** ** * ** ***\n\n### `add``Sub``Menu(menu)`\n\nAdds a sub-menu to the menu.\n\n#### Parameters\n\n| Name | Type | Description |\n|--------|-----------|--------------------------------------------------|\n| `menu` | [Menu](#) | The sub-menu, constructed like a top-level menu. |\n\n#### Return\n\n\n[Menu](#) --- This [Menu](#), for chaining.\n\n*** ** * ** ***\n\n### `add``To``Ui()`\n\nInserts the menu into the instance of the editor's user interface."]]