Class Tab

แท็บ

แท็บภายในเอกสาร Google เอกสาร

// Get all of the first-level tabs (tabs that are not nested within a parent // tab) in the document. // TODO(developer): Replace the ID with your own. const tabs = DocumentApp.openById('123abc').getTabs();  // Get a specific tab based on the tab ID. // TODO(developer): Replace the IDs with your own. const tab = DocumentApp.openById('123abc').getTab('123abc');

เมธอด

วิธีการประเภทการแสดงผลรายละเอียดแบบย่อ
asDocumentTab()DocumentTabดึงข้อมูลเนื้อหาแท็บเป็น DocumentTab
getChildTabs()Tab[]ดึงข้อมูลแท็บย่อยที่ฝังอยู่ในแท็บนี้
getId()Stringดึงข้อมูลรหัสของแท็บ
getIndex()Integerดึงข้อมูลดัชนีฐาน 0 ของแท็บภายในรายการหลัก
getTitle()Stringดึงข้อมูลชื่อแท็บ
getType()TabTypeดึงข้อมูลประเภทแท็บ

เอกสารประกอบโดยละเอียด

asDocumentTab()

ดึงข้อมูลเนื้อหาแท็บเป็น DocumentTab

รีเทิร์น

DocumentTab — แท็บเป็น DocumentTab


getChildTabs()

ดึงข้อมูลแท็บย่อยที่ฝังอยู่ในแท็บนี้

รีเทิร์น

Tab[] — แท็บย่อยที่ฝังอยู่ในแท็บนี้

การให้สิทธิ์

สคริปต์ที่ใช้วิธีการนี้ต้องได้รับอนุญาตด้วยขอบเขตต่อไปนี้อย่างน้อย 1 รายการ

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

getId()

ดึงข้อมูลรหัสของแท็บ

รีเทิร์น

String — รหัสของแท็บ

การให้สิทธิ์

สคริปต์ที่ใช้วิธีการนี้ต้องได้รับอนุญาตด้วยขอบเขตต่อไปนี้อย่างน้อย 1 รายการ

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

getIndex()

ดึงข้อมูลดัชนีฐาน 0 ของแท็บภายในรายการหลัก

รีเทิร์น

Integer — ดัชนีของแท็บภายในแท็บหลัก

การให้สิทธิ์

สคริปต์ที่ใช้วิธีการนี้ต้องได้รับอนุญาตด้วยขอบเขตต่อไปนี้อย่างน้อย 1 รายการ

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

getTitle()

ดึงข้อมูลชื่อแท็บ

รีเทิร์น

String — ชื่อของแท็บ

การให้สิทธิ์

สคริปต์ที่ใช้วิธีการนี้ต้องได้รับอนุญาตด้วยขอบเขตต่อไปนี้อย่างน้อย 1 รายการ

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

getType()

ดึงข้อมูลประเภทแท็บ

ใช้วิธีนี้เพื่อระบุประเภทเนื้อหาของ Tab นี้ก่อนที่จะแคสต์ไปยังประเภทที่เฉพาะเจาะจงมากขึ้นโดยใช้ asDocumentTab()

const tab = DocumentApp.getActiveDocument().getActiveTab(); // Use getType() to determine the tab's type before casting. if (tab.getType() === DocumentApp.TabType.DOCUMENT_TAB) {   // It's a document tab, write some text to it.   tab.asDocumentTab().setText('Hello World!'); } else {   // There are currently no types other than DOCUMENT_TAB. }

รีเทิร์น

TabType — ประเภทของแท็บ

การให้สิทธิ์

สคริปต์ที่ใช้วิธีการนี้ต้องได้รับอนุญาตด้วยขอบเขตต่อไปนี้อย่างน้อย 1 รายการ

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents