Enum VerticalAlignment

  • VerticalAlignment is used to define how content is vertically aligned within a table cell.

  • It offers three options: TOP, CENTER, and BOTTOM for aligning content to the top, center, or bottom of the cell, respectively.

  • You can set the vertical alignment of a table cell using DocumentApp.VerticalAlignment and the desired alignment property within your Apps Script code.

VerticalAlignment

An enumeration of the supported vertical alignment types.

To call an enum, you call its parent class, name, and property. For example, DocumentApp.VerticalAlignment.BOTTOM.

Use the VerticalAlignment enumeration to set the vertical alignment of table cells.

const body =
    DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().getBody();

// Append table containing two cells.
const table = body.appendTable([['Top', 'Center', 'Bottom']]);

// Align the first cell's contents to the top.
table.getCell(0, 0).setVerticalAlignment(DocumentApp.VerticalAlignment.TOP);

// Align the second cell's contents to the center.
table.getCell(0, 1).setVerticalAlignment(DocumentApp.VerticalAlignment.CENTER);

// Align the third cell's contents to the bottom.
table.getCell(0, 2).setVerticalAlignment(DocumentApp.VerticalAlignment.BOTTOM);

Properties

PropertyTypeDescription
BOTTOMEnumThe bottom-alignment option.
CENTEREnumThe center-alignment option.
TOPEnumThe top-alignment option.