Class Tab

แท็บ

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

// Get all of the first-level tabs (tabs that are not nested within a parent tab) in the
// document.
var tabs = DocumentApp.openById('abc123456').getTabs();

// Get a specific tab based on the tab ID.
var tab = DocumentApp.openById('abc123456').getTab('t.0');

เมธอด

วิธีการประเภทการแสดงผลรายละเอียดแบบย่อ
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()

var tab = DocumentApp.getActiveDocument().getTab('t.0');
// 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