Word.Section
Word.Section is an object type of the Word module (Office.word(iframe)). 15 methods.
Word · 14 object types · 259 methods · namespace Word. This reference is generated from the API document artifact (sdk-api-doc.html) produced with the SDK build. Descriptions are the editor's API comments as published. Pin the SDK and Office versions together and regenerate when either changes.
Remarks
- Module: Word ·
Office.word(iframe)· namespaceWord - Obtained from:
Document.getSection(index),Document.getSections(),Range.getParentSection() - Every method returns a
Promise; signatures use TypeScript notation.
Methods
| Method | Description |
|---|---|
deleteBreak() | Removes the break of this section and merges it with the next section. |
getBody() | Returns the section body. |
getColumns() | Returns the column (multi-column) layout of this section. |
getFooter(type) | Returns the footer area of this section. |
getHeader(type) | Returns the header area of this section. |
getIndex() | Returns the index of this section. |
getNext() | Returns the next section in document order. |
getPageSetup() | Returns the page setup of this section. |
getPrevious() | Returns the previous section in document order. |
setBreakType(type) | Changes the break type of this section (continuous, next page, etc.). |
setColumns(layout) | Changes the column (multi-column) layout of this section. |
setPageMargin(margins) | Sets the page margins of this section. |
setPageNumbering(options) | Changes the page numbering settings of this section. |
setPageSize(size, orientation) | Sets the paper size and orientation of this section. |
setTitlePage(enabled) | Enables a separate header/footer for the first page of this section. |
Method details
deleteBreak()
Removes the break of this section and merges it with the next section. - The last section has no break to remove.
deleteBreak(): Promise<void>;
Returns
Promise<void>
getBody()
Returns the section body. - The body is shared by all sections, so calling this on any section returns the same body.
getBody(): Promise<Body>;
Returns
Promise<Body> - body area
getColumns()
Returns the column (multi-column) layout of this section.
count, equalWidth, space and separator are always included; widths is added only when the column widths differ.
A single column is always reported as equal width, so the result is { count: 1, equalWidth: true, space, separator } with no widths.
The return value can be passed to setColumns() as is.
getColumns(): Promise<ColumnLayout>;
Returns
Promise<ColumnLayout> - column layout (same shape as the setColumns input)
getFooter(type)
Returns the footer area of this section. - An area that does not exist yet is created on first content insertion.
getFooter(type?: HeaderFooterType | HeaderFooterVariant): Promise<Body>;
Parameters
| Name | Type | Description |
|---|---|---|
type (optional) | HeaderFooterType | HeaderFooterVariant | kind: HeaderFooterType (primary/firstPage/evenPages) or HeaderFooterVariant (default/first/even) (default: HeaderFooterType.PRIMARY) |
Returns
Promise<Body> - footer area of the given kind
getHeader(type)
Returns the header area of this section. - An area that does not exist yet is created on first content insertion.
getHeader(type?: HeaderFooterType | HeaderFooterVariant): Promise<Body>;
Parameters
| Name | Type | Description |
|---|---|---|
type (optional) | HeaderFooterType | HeaderFooterVariant | kind: HeaderFooterType (primary/firstPage/evenPages) or HeaderFooterVariant (default/first/even) (default: HeaderFooterType.PRIMARY) |
Returns
Promise<Body> - header area of the given kind
getIndex()
Returns the index of this section.
getIndex(): Promise<number>;
Returns
Promise<number> - 0-based section index
getNext()
Returns the next section in document order.
getNext(): Promise<Section>;
Returns
Promise<Section> - the next section; null if this is the last section
getPageSetup()
Returns the page setup of this section. - Paper size and margins are returned in pt.
getPageSetup(): Promise<PageSetupInfo>;
Returns
Promise<PageSetupInfo> - page setup of this section
getPrevious()
Returns the previous section in document order.
getPrevious(): Promise<Section>;
Returns
Promise<Section> - the previous section; null if this is the first section
setBreakType(type)
Changes the break type of this section (continuous, next page, etc.). Does nothing if the value equals the current one. - Same as the value read via getPageSetup().breakType.
setBreakType(type: SectionBreakType): Promise<void>;
Parameters
| Name | Type | Description |
|---|---|---|
type | SectionBreakType | break type (continuous/nextPage/evenPage/oddPage) |
Returns
Promise<void>
setColumns(layout)
Changes the column (multi-column) layout of this section.
Only the specified fields are changed; the rest keep their current values. Does nothing if the value equals the current one. The unit is pt.
To give each column a different width, specify widths; otherwise all columns share the same width. When count is 1, equalWidth and widths are ignored.
Check the setting via getColumns(); its return value can be passed back as is.
setColumns(layout: ColumnLayout): Promise<void>;
Parameters
| Name | Type | Description |
|---|---|---|
layout | ColumnLayout | column layout |
Returns
Promise<void>
setPageMargin(margins)
Sets the page margins of this section. - Only the specified sides are changed; the unit is pt.
setPageMargin(margins: PageMargins): Promise<void>;
Parameters
| Name | Type | Description |
|---|---|---|
margins | PageMargins | margins (pt) |
Returns
Promise<void>
setPageNumbering(options)
Changes the page numbering settings of this section.
Only the specified fields are changed; null removes the whole setting. Does nothing if the value equals the current one.
Check the setting via getPageSetup().pageNumber.
setPageNumbering(options: PageNumbering | null): Promise<void>;
Parameters
| Name | Type | Description |
|---|---|---|
options | PageNumbering | null | page numbering settings, or null (remove) |
Returns
Promise<void>
setPageSize(size, orientation)
Sets the paper size and orientation of this section.
Specify a paper preset or a width/height in pt. Unspecified dimensions are kept.
When an orientation is given, width and height are aligned to it. Changing only the preset keeps the current orientation.
setPageSize(size: Size | PaperSize | null, orientation?: PageOrientation): Promise<void>;
Parameters
| Name | Type | Description |
|---|---|---|
size | Size | PaperSize | null | paper dimensions (pt; an omitted axis keeps its current value) or a paper preset name (A3/A4/A5/Letter/Legal/Executive). null keeps the size (changes orientation only) |
orientation (optional) | PageOrientation | orientation (portrait/landscape) |
Returns
Promise<void>
setTitlePage(enabled)
Enables a separate header/footer for the first page of this section.
Does nothing if the value equals the current one. After enabling, enter the first-page content separately.
Check the setting via getPageSetup().titlePage.
setTitlePage(enabled: boolean): Promise<void>;
Parameters
| Name | Type | Description |
|---|---|---|
enabled | boolean | enable (true) / disable (false) |
Returns
Promise<void>