Class EquationFunction

EquationFunction

องค์ประกอบที่แทนฟังก์ชันใน Equation ทางคณิตศาสตร์ EquationFunction อาจมีองค์ประกอบ EquationFunction, EquationFunctionArgumentSeparator, EquationSymbol และ Text ดูข้อมูลเพิ่มเติมเกี่ยวกับโครงสร้างเอกสารได้ในคู่มือการขยายการใช้งาน Google เอกสาร

วิธีการ

วิธีการประเภทการแสดงผลรายละเอียดแบบย่อ
clear()EquationFunctionล้างเนื้อหาขององค์ประกอบ
copy()EquationFunctionแสดงผลสำเนาแบบเจาะลึกขององค์ประกอบปัจจุบันที่แยกออกมา
editAsText()Textรับองค์ประกอบปัจจุบันเวอร์ชัน Text เพื่อแก้ไข
findElement(elementType)RangeElementค้นหาเนื้อหาขององค์ประกอบสำหรับองค์ประกอบสืบทอดของประเภทที่ระบุ
findElement(elementType, from)RangeElementค้นหาเนื้อหาขององค์ประกอบสำหรับองค์ประกอบสืบทอดของประเภทที่ระบุ โดยเริ่มจาก RangeElement ที่ระบุ
findText(searchPattern)RangeElementค้นหาเนื้อหาขององค์ประกอบสำหรับรูปแบบข้อความที่ระบุโดยใช้นิพจน์ทั่วไป
findText(searchPattern, from)RangeElementค้นหาเนื้อหาขององค์ประกอบสำหรับรูปแบบข้อความที่ระบุ โดยเริ่มจากผลการค้นหาที่ระบุ
getAttributes()Objectเรียกแอตทริบิวต์ขององค์ประกอบ
getChild(childIndex)Elementเรียกองค์ประกอบย่อยที่ดัชนีย่อยที่ระบุ
getChildIndex(child)Integerเรียกดัชนีย่อยสำหรับองค์ประกอบย่อยที่ระบุ
getCode()Stringดึงโค้ดที่เกี่ยวข้องกับฟังก์ชันสมการ
getLinkUrl()Stringเรียก URL ของลิงก์
getNextSibling()Elementเรียกองค์ประกอบข้างเคียงถัดไปขององค์ประกอบ
getNumChildren()Integerดึงจำนวนเด็ก
getParent()ContainerElementเรียกองค์ประกอบระดับบนขององค์ประกอบ
getPreviousSibling()Elementเรียกองค์ประกอบข้างเคียงก่อนหน้าขององค์ประกอบ
getText()Stringเรียกเนื้อหาขององค์ประกอบเป็นสตริงข้อความ
getTextAlignment()TextAlignmentรับการจัดข้อความ
getType()ElementTypeดึงข้อมูล ElementType ขององค์ประกอบ
isAtDocumentEnd()Booleanระบุว่าองค์ประกอบอยู่ที่ส่วนท้ายของ Document หรือไม่
merge()EquationFunctionผสานรวมองค์ประกอบกับข้างเคียงที่อยู่ก่อนหน้าซึ่งเป็นประเภทเดียวกัน
removeFromParent()EquationFunctionนำองค์ประกอบออกจากระดับบนสุด
replaceText(searchPattern, replacement)Elementแทนที่รายการทั้งหมดของรูปแบบข้อความที่ระบุด้วยสตริงการแทนที่หนึ่งๆ โดยใช้นิพจน์ทั่วไป
setAttributes(attributes)EquationFunctionตั้งค่าแอตทริบิวต์ขององค์ประกอบ
setLinkUrl(url)EquationFunctionตั้งค่า URL ของลิงก์
setTextAlignment(textAlignment)EquationFunctionตั้งค่าการจัดข้อความ

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

clear()

ล้างเนื้อหาขององค์ประกอบ

รีเทิร์น

EquationFunction — องค์ประกอบปัจจุบัน


copy()

แสดงผลสำเนาแบบเจาะลึกขององค์ประกอบปัจจุบันที่แยกออกมา

ระบบจะคัดลอกองค์ประกอบย่อยที่มีอยู่ในองค์ประกอบนั้นด้วย องค์ประกอบใหม่ไม่มี ระดับบนสุด

รีเทิร์น

EquationFunction — สำเนาใหม่

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

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

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

editAsText()

รับองค์ประกอบปัจจุบันเวอร์ชัน Text เพื่อแก้ไข

ใช้ editAsText เพื่อจัดการเนื้อหาขององค์ประกอบเป็น Rich Text โหมด editAsText จะไม่สนใจองค์ประกอบที่ไม่ใช่ข้อความ (เช่น InlineImage และ HorizontalRule)

ระบบจะนำองค์ประกอบย่อยที่อยู่ในช่วงข้อความที่ลบแล้วออกจากองค์ประกอบ

var body = DocumentApp.getActiveDocument().getBody();

// Insert two paragraphs separated by a paragraph containing an
// horizontal rule.
body.insertParagraph(0, "An editAsText sample.");
body.insertHorizontalRule(0);
body.insertParagraph(0, "An example.");

// Delete " sample.\n\n An" removing the horizontal rule in the process.
body.editAsText().deleteText(14, 25);

รีเทิร์น

Text — เวอร์ชันข้อความขององค์ประกอบปัจจุบัน


findElement(elementType)

ค้นหาเนื้อหาขององค์ประกอบสำหรับองค์ประกอบสืบทอดของประเภทที่ระบุ

พารามิเตอร์

ชื่อTypeคำอธิบาย
elementTypeElementTypeประเภทขององค์ประกอบที่จะค้นหา

รีเทิร์น

RangeElement — ผลการค้นหาที่ระบุตำแหน่งขององค์ประกอบการค้นหา

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

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

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

findElement(elementType, from)

ค้นหาเนื้อหาขององค์ประกอบสำหรับองค์ประกอบสืบทอดของประเภทที่ระบุ โดยเริ่มจาก RangeElement ที่ระบุ

// Get the body section of the active document.
var body = DocumentApp.getActiveDocument().getBody();

// Define the search parameters.
var searchType = DocumentApp.ElementType.PARAGRAPH;
var searchHeading = DocumentApp.ParagraphHeading.HEADING1;
var searchResult = null;

// Search until the paragraph is found.
while (searchResult = body.findElement(searchType, searchResult)) {
  var par = searchResult.getElement().asParagraph();
  if (par.getHeading() == searchHeading) {
    // Found one, update and stop.
    par.setText('This is the first header.');
    return;
  }
}

พารามิเตอร์

ชื่อTypeคำอธิบาย
elementTypeElementTypeประเภทขององค์ประกอบที่จะค้นหา
fromRangeElementผลการค้นหาที่จะค้นหา

รีเทิร์น

RangeElement — ผลการค้นหาที่ระบุตำแหน่งถัดไปขององค์ประกอบการค้นหา

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

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

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

findText(searchPattern)

ค้นหาเนื้อหาขององค์ประกอบสำหรับรูปแบบข้อความที่ระบุโดยใช้นิพจน์ทั่วไป

ระบบไม่รองรับฟีเจอร์นิพจน์ทั่วไปของ JavaScript เพียงบางส่วน เช่น Capture Group และตัวปรับแต่งโหมด

รูปแบบนิพจน์ทั่วไปที่ระบุจะจับคู่กับบล็อกข้อความแต่ละบล็อกที่อยู่ในองค์ประกอบปัจจุบันอย่างอิสระ

พารามิเตอร์

ชื่อTypeคำอธิบาย
searchPatternStringรูปแบบที่ต้องการค้นหา

รีเทิร์น

RangeElement — ผลการค้นหาที่ระบุตำแหน่งของข้อความค้นหา หรือ Null หากไม่พบรายการที่ตรงกัน

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

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

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

findText(searchPattern, from)

ค้นหาเนื้อหาขององค์ประกอบสำหรับรูปแบบข้อความที่ระบุ โดยเริ่มจากผลการค้นหาที่ระบุ

ระบบไม่รองรับฟีเจอร์นิพจน์ทั่วไปของ JavaScript เพียงบางส่วน เช่น Capture Group และตัวปรับแต่งโหมด

รูปแบบนิพจน์ทั่วไปที่ระบุจะจับคู่กับบล็อกข้อความแต่ละบล็อกที่อยู่ในองค์ประกอบปัจจุบันอย่างอิสระ

พารามิเตอร์

ชื่อTypeคำอธิบาย
searchPatternStringรูปแบบที่ต้องการค้นหา
fromRangeElementผลการค้นหาที่จะค้นหา

รีเทิร์น

RangeElement — ผลการค้นหาที่ระบุตำแหน่งถัดไปของข้อความค้นหา หรือ Null หากไม่พบรายการที่ตรงกัน

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

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

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

getAttributes()

เรียกแอตทริบิวต์ขององค์ประกอบ

ผลลัพธ์คือออบเจ็กต์ที่มีพร็อพเพอร์ตี้สำหรับแอตทริบิวต์ขององค์ประกอบที่ถูกต้องแต่ละรายการ โดยที่ชื่อพร็อพเพอร์ตี้แต่ละรายการสอดคล้องกับรายการในการแจงนับ DocumentApp.Attribute

var body = DocumentApp.getActiveDocument().getBody();

// Append a styled paragraph.
var par = body.appendParagraph('A bold, italicized paragraph.');
par.setBold(true);
par.setItalic(true);

// Retrieve the paragraph's attributes.
var atts = par.getAttributes();

// Log the paragraph attributes.
for (var att in atts) {
  Logger.log(att + ":" + atts[att]);
}

รีเทิร์น

Object — แอตทริบิวต์ขององค์ประกอบ

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

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

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

getChild(childIndex)

เรียกองค์ประกอบย่อยที่ดัชนีย่อยที่ระบุ

// Get the body section of the active document.
var body = DocumentApp.getActiveDocument().getBody();

// Obtain the first element in the document.
var firstChild = body.getChild(0);

// If it's a paragraph, set its contents.
if (firstChild.getType() == DocumentApp.ElementType.PARAGRAPH) {
  firstChild.asParagraph().setText("This is the first paragraph.");
}

พารามิเตอร์

ชื่อTypeคำอธิบาย
childIndexIntegerดัชนีขององค์ประกอบย่อยที่จะดึงข้อมูล

รีเทิร์น

Element — องค์ประกอบย่อยที่ดัชนีที่ระบุ

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

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

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

getChildIndex(child)

เรียกดัชนีย่อยสำหรับองค์ประกอบย่อยที่ระบุ

พารามิเตอร์

ชื่อTypeคำอธิบาย
childElementองค์ประกอบย่อยที่จะดึงข้อมูลดัชนี

รีเทิร์น

Integer — ดัชนีย่อย

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

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

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

getCode()

ดึงโค้ดที่เกี่ยวข้องกับฟังก์ชันสมการ

รีเทิร์น

String — โค้ดฟังก์ชัน

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

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

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

getLinkUrl()

เรียก URL ของลิงก์

รีเทิร์น

String — URL ของลิงก์หรือ Null หากองค์ประกอบมีค่าหลายค่าสำหรับแอตทริบิวต์นี้

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

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

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

getNextSibling()

เรียกองค์ประกอบข้างเคียงถัดไปขององค์ประกอบ

องค์ประกอบข้างเคียงถัดไปมีระดับบนสุดเดียวกันและอยู่หลังองค์ประกอบปัจจุบัน

รีเทิร์น

Element — องค์ประกอบข้างเคียงถัดไป

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

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

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

getNumChildren()

ดึงจำนวนเด็ก

// Get the body section of the active document.
var body = DocumentApp.getActiveDocument().getBody();

// Log the number of elements in the document.
Logger.log("There are " + body.getNumChildren() +
    " elements in the document body.");

รีเทิร์น

Integer — จำนวนเด็ก

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

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

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

getParent()

เรียกองค์ประกอบระดับบนขององค์ประกอบ

องค์ประกอบระดับบนประกอบด้วยองค์ประกอบปัจจุบัน

รีเทิร์น

ContainerElement — องค์ประกอบระดับบน

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

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

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

getPreviousSibling()

เรียกองค์ประกอบข้างเคียงก่อนหน้าขององค์ประกอบ

องค์ประกอบข้างเคียงก่อนหน้ามีระดับบนสุดเดียวกันและอยู่ก่อนองค์ประกอบปัจจุบัน

รีเทิร์น

Element — องค์ประกอบข้างเคียงก่อนหน้า

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

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

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

getText()

เรียกเนื้อหาขององค์ประกอบเป็นสตริงข้อความ

รีเทิร์น

String — เนื้อหาขององค์ประกอบเป็นสตริงข้อความ

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

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

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

getTextAlignment()

รับการจัดข้อความ ประเภทการจัดเรียงที่ใช้ได้คือ DocumentApp.TextAlignment.NORMAL, DocumentApp.TextAlignment.SUBSCRIPT และ DocumentApp.TextAlignment.SUPERSCRIPT

รีเทิร์น

TextAlignment — ประเภทการจัดแนวข้อความ หรือ null หากข้อความมีการจัดแนวข้อความหลายประเภทหรือไม่เคยตั้งค่าการจัดข้อความไว้

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

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

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

getType()

ดึงข้อมูล ElementType ขององค์ประกอบ

ใช้ getType() เพื่อระบุประเภทองค์ประกอบที่เฉพาะเจาะจง

var body = DocumentApp.getActiveDocument().getBody();

// Obtain the first element in the document body.

var firstChild = body.getChild(0);

// Use getType() to determine the element's type.
if (firstChild.getType() == DocumentApp.ElementType.PARAGRAPH) {
  Logger.log('The first element is a paragraph.');
} else {
  Logger.log('The first element is not a paragraph.');
}

รีเทิร์น

ElementType — ประเภทองค์ประกอบ

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

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

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

isAtDocumentEnd()

ระบุว่าองค์ประกอบอยู่ที่ส่วนท้ายของ Document หรือไม่

รีเทิร์น

Boolean — องค์ประกอบอยู่ท้ายเอกสารหรือไม่

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

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

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

merge()

ผสานรวมองค์ประกอบกับข้างเคียงที่อยู่ก่อนหน้าซึ่งเป็นประเภทเดียวกัน

รวมได้เฉพาะองค์ประกอบของ ElementType เดียวกัน องค์ประกอบย่อยที่อยู่ในองค์ประกอบปัจจุบันจะย้ายไปยังองค์ประกอบระดับข้างเคียงที่อยู่ก่อนหน้า

องค์ประกอบปัจจุบันจะถูกนำออกจากเอกสาร

var body = DocumentApp.getActiveDocument().getBody();
// Example 1: Merge paragraphs
// Append two paragraphs to the document.
var par1 = body.appendParagraph('Paragraph 1.');
var par2 = body.appendParagraph('Paragraph 2.');
// Merge the newly added paragraphs into a single paragraph.
par2.merge();

// Example 2: Merge table cells
// Create a two-dimensional array containing the table's cell contents.
var cells = [
['Row 1, Cell 1', 'Row 1, Cell 2'],
['Row 2, Cell 1', 'Row 2, Cell 2']
];
// Build a table from the array.
var table = body.appendTable(cells);
// Get the first row in the table.
 var row = table.getRow(0);
// Get the two cells in this row.
var cell1 = row.getCell(0);
var cell2 = row.getCell(1);
// Merge the current cell into its preceding sibling element.
var merged = cell2.merge();

รีเทิร์น

EquationFunction — องค์ประกอบที่รวมกัน

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

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

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

removeFromParent()

นำองค์ประกอบออกจากระดับบนสุด

var body = DocumentApp.getActiveDocument().getBody();

// Remove all images in the document body.
var imgs = body.getImages();
for (var i = 0; i < imgs.length; i++) {
  imgs[i].removeFromParent();
}

รีเทิร์น

EquationFunction — องค์ประกอบที่นำออก

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

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

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

replaceText(searchPattern, replacement)

แทนที่รายการทั้งหมดของรูปแบบข้อความที่ระบุด้วยสตริงการแทนที่หนึ่งๆ โดยใช้นิพจน์ทั่วไป

รูปแบบการค้นหาจะส่งเป็นสตริง ไม่ใช่ออบเจ็กต์นิพจน์ทั่วไปของ JavaScript ด้วยเหตุนี้คุณจึงต้องหลีกเลี่ยงแบ็กสแลชในรูปแบบดังกล่าว

เมธอดนี้ใช้ไลบรารีนิพจน์ทั่วไป RE2 ของ Google ซึ่งจะจำกัดไวยากรณ์ที่รองรับ

รูปแบบนิพจน์ทั่วไปที่ระบุจะจับคู่กับบล็อกข้อความแต่ละบล็อกที่อยู่ในองค์ประกอบปัจจุบันอย่างอิสระ

var body = DocumentApp.getActiveDocument().getBody();

// Clear the text surrounding "Apps Script", with or without text.
body.replaceText("^.*Apps ?Script.*$", "Apps Script");

พารามิเตอร์

ชื่อTypeคำอธิบาย
searchPatternStringรูปแบบนิพจน์ทั่วไปที่จะค้นหา
replacementStringข้อความที่จะใช้แทนข้อความ

รีเทิร์น

Element — องค์ประกอบปัจจุบัน

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

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

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

setAttributes(attributes)

ตั้งค่าแอตทริบิวต์ขององค์ประกอบ

พารามิเตอร์แอตทริบิวต์ที่ระบุต้องเป็นออบเจ็กต์ที่ชื่อพร็อพเพอร์ตี้แต่ละชื่อเป็นรายการในการแจงนับ DocumentApp.Attribute และค่าพร็อพเพอร์ตี้แต่ละค่าคือค่าใหม่ที่จะใช้

var body = DocumentApp.getActiveDocument().getBody();

// Define a custom paragraph style.
var style = {};
style[DocumentApp.Attribute.HORIZONTAL_ALIGNMENT] =
    DocumentApp.HorizontalAlignment.RIGHT;
style[DocumentApp.Attribute.FONT_FAMILY] = 'Calibri';
style[DocumentApp.Attribute.FONT_SIZE] = 18;
style[DocumentApp.Attribute.BOLD] = true;

// Append a plain paragraph.
var par = body.appendParagraph('A paragraph with custom style.');

// Apply the custom style.
par.setAttributes(style);

พารามิเตอร์

ชื่อTypeคำอธิบาย
attributesObjectแอตทริบิวต์ขององค์ประกอบ

รีเทิร์น

EquationFunction — องค์ประกอบปัจจุบัน

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

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

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

setLinkUrl(url)

ตั้งค่า URL ของลิงก์

พารามิเตอร์

ชื่อTypeคำอธิบาย
urlStringURL ของลิงก์

รีเทิร์น

EquationFunction — องค์ประกอบปัจจุบัน

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

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

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

setTextAlignment(textAlignment)

ตั้งค่าการจัดข้อความ ประเภทการจัดเรียงที่ใช้ได้คือ DocumentApp.TextAlignment.NORMAL, DocumentApp.TextAlignment.SUBSCRIPT และ DocumentApp.TextAlignment.SUPERSCRIPT

// Make the entire first paragraph be superscript.
var text = DocumentApp.getActiveDocument().getBody().getParagraphs()[0].editAsText();
text.setTextAlignment(DocumentApp.TextAlignment.SUPERSCRIPT);

พารามิเตอร์

ชื่อTypeคำอธิบาย
textAlignmentTextAlignmentประเภทการจัดข้อความที่จะใช้

รีเทิร์น

EquationFunction — องค์ประกอบปัจจุบัน

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

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

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