FDocumentSection
Facade wrapper for an OOXML-compatible traditional document section. Modern documents use ColumnGroup APIs. Unspecified documents must resolve their flavor before using this facade.
Access
Access through:
FDocument.getSections()FDocument.getSection()FDocument.getSectionAt()FDocument.insertSectionBreak()
Example
const fDocument = univerAPI.getActiveDocument()if (fDocument?.isTraditional()) { console.log(fDocument.getSection(0)?.describe())}Setup
Register @univerjs/docs or a preset that includes it. In plugin mode, import @univerjs/docs/facade. Additional methods below require their listed plugin packages. See Facade setup.
@univerjs/docs
FDocumentSection.describe
Returns a compact serializable section summary.
describe(): IFDocumentSectionDescriptionExamples
const fDocument = univerAPI.getActiveDocument()console.log(fDocument?.getSection(0)?.describe())Types: IFDocumentSectionDescription
Package: @univerjs/docs · Type definitions
FDocumentSection.ensureFooter
Ensures a footer segment linked specifically to this section.
ensureFooter(variant?: SectionHeaderFooterVariant): stringParameters
variant— Optional. Default:'default'.
Examples
const fDocument = univerAPI.getActiveDocument()if (fDocument?.isTraditional()) { const segmentId = fDocument.getSection(0)?.ensureFooter('first') if (segmentId) { fDocument.insertText(0, 'Confidential', segmentId) }}Types: SectionHeaderFooterVariant
Package: @univerjs/docs · Type definitions
FDocumentSection.ensureHeader
Ensures a header segment linked specifically to this section.
ensureHeader(variant?: SectionHeaderFooterVariant): stringParameters
variant— Optional. Default:'default'.
Examples
const fDocument = univerAPI.getActiveDocument()if (fDocument?.isTraditional()) { const segmentId = fDocument.getSection(0)?.ensureHeader() if (segmentId) { fDocument.insertText(0, 'Quarterly report', segmentId) }}Types: SectionHeaderFooterVariant
Package: @univerjs/docs · Type definitions
FDocumentSection.getColumns
Returns the explicit columns. An empty array means the normal single-column layout. Column widths and trailing spaces are in 96-DPI layout pixels.
getColumns(): ISectionColumnProperties[]Examples
const fDocument = univerAPI.getActiveDocument()console.log(fDocument?.getSection(0)?.getColumns())Types: ISectionColumnProperties
Package: @univerjs/docs · Type definitions
FDocumentSection.getConfig
Returns the section break snapshot that terminates this section.
getConfig(): ISectionBreakExamples
const fDocument = univerAPI.getActiveDocument()console.log(fDocument?.getSection(0)?.getConfig())Types: ISectionBreak
Package: @univerjs/docs · Type definitions
FDocumentSection.getEffectivePageSetup
Returns nominal page geometry after resolving this section's overrides against document defaults. All geometry values use 96-DPI layout pixels.
This synchronous model-only API works without engine-render. It does not
report physical page count, remaining page space, or final coordinates.
getEffectivePageSetup(): IEffectiveSectionPageSetupReturns
A cloned, serializable page setup.
Examples
const document = univerAPI.getActiveDocument()if (!document) { throw new Error('No active document')}if (!document.isTraditional()) { throw new Error('Traditional document sections are required')}const section = document.getSection(0)if (!section) { throw new Error('The document has no traditional section')}const layout = section.getEffectivePageSetup()console.log({ pageWidth: layout.pageSize.width, pageHeight: layout.pageSize.height, contentWidth: layout.contentSize.width, contentHeight: layout.contentSize.height, margins: layout.margins,})Types: IEffectiveSectionPageSetup
Package: @univerjs/docs · Type definitions
FDocumentSection.getFooterId
Returns the effective footer id after resolving links to previous sections.
getFooterId(variant?: SectionHeaderFooterVariant): string | nullParameters
variant— Optional. Default:'default'.
Examples
const fDocument = univerAPI.getActiveDocument()console.log(fDocument?.getSection(0)?.getFooterId('first'))Types: SectionHeaderFooterVariant
Package: @univerjs/docs · Type definitions
FDocumentSection.getHeaderId
Returns the effective header id after resolving links to previous sections.
getHeaderId(variant?: SectionHeaderFooterVariant): string | nullParameters
variant— Optional. Default:'default'.
Examples
const fDocument = univerAPI.getActiveDocument()console.log(fDocument?.getSection(0)?.getHeaderId('default'))Types: SectionHeaderFooterVariant
Package: @univerjs/docs · Type definitions
FDocumentSection.getId
Returns the persisted section id.
getId(): stringExamples
const fDocument = univerAPI.getActiveDocument()console.log(fDocument?.getSection(0)?.getId())Package: @univerjs/docs · Type definitions
FDocumentSection.getIndex
Returns the current zero-based section index.
getIndex(): numberExamples
const fDocument = univerAPI.getActiveDocument()console.log(fDocument?.getSection(0)?.getIndex())Package: @univerjs/docs · Type definitions
FDocumentSection.getPageSetup
Returns this section's explicit page setup overrides. Missing values inherit from the document style. Geometry values use 96-DPI layout pixels.
Use getEffectivePageSetup() when an agent needs resolved page and content
dimensions rather than only the overrides stored on this section.
getPageSetup(): FDocumentSectionPageSetupReturns
A cloned object containing only explicit section overrides.
Examples
const document = univerAPI.getActiveDocument()const section = document?.getSection(0)console.log(section?.getPageSetup())Types: FDocumentSectionPageSetup
Package: @univerjs/docs · Type definitions
FDocumentSection.getPermission
Returns this Section's permission facade.
getPermission(): FDocumentObjectPermissionReturns
Permission facade combining Document and Section Edit points.
Examples
const section = univerAPI.getActiveDocument()?.getSection(0)if (!section) throw new Error('Section not found.')await section.getPermission().setReadOnly()Types: FDocumentObjectPermission
Package: @univerjs/docs · Type definitions
FDocumentSection.getRange
Returns the section content range, excluding its terminating section-break token.
getRange(): IFDocumentTextRangeExamples
const fDocument = univerAPI.getActiveDocument()console.log(fDocument?.getSection(0)?.getRange())Types: IFDocumentTextRange
Package: @univerjs/docs · Type definitions
FDocumentSection.isFooterLinkedToPrevious
Whether this footer variant inherits the previous section's reference.
isFooterLinkedToPrevious(variant?: SectionHeaderFooterVariant): booleanParameters
variant— Optional. Default:'default'.
Examples
const fDocument = univerAPI.getActiveDocument()console.log(fDocument?.getSection(1)?.isFooterLinkedToPrevious('even'))Types: SectionHeaderFooterVariant
Package: @univerjs/docs · Type definitions
FDocumentSection.isHeaderLinkedToPrevious
Whether this header variant inherits the previous section's reference.
isHeaderLinkedToPrevious(variant?: SectionHeaderFooterVariant): booleanParameters
variant— Optional. Default:'default'.
Examples
const fDocument = univerAPI.getActiveDocument()console.log(fDocument?.getSection(1)?.isHeaderLinkedToPrevious())Types: SectionHeaderFooterVariant
Package: @univerjs/docs · Type definitions
FDocumentSection.remove
Deletes this section break. The final top-level section break cannot be removed.
remove(): booleanExamples
const fDocument = univerAPI.getActiveDocument()if (fDocument?.isTraditional()) { const sections = fDocument.getSections() if (sections.length > 1) { sections[0].remove() }}Package: @univerjs/docs · Type definitions
FDocumentSection.setColumnProperties
Sets explicit OOXML-compatible column width and trailing-space values in 96-DPI layout pixels.
setColumnProperties(columns: ISectionColumnProperties[], separator?: ColumnSeparatorType): booleanParameters
columns— Required.separator— Optional. Default:ColumnSeparatorType.NONE.
Examples
const fDocument = univerAPI.getActiveDocument()if (fDocument?.isTraditional()) { fDocument.getSection(0)?.setColumnProperties( [ { width: 240, paddingEnd: 18 }, { width: 240, paddingEnd: 0 }, ], univerAPI.Enum.ColumnSeparatorType.BETWEEN_EACH_COLUMN, )}Types: ISectionColumnProperties · ColumnSeparatorType
Package: @univerjs/docs · Type definitions
FDocumentSection.setColumns
Sets equal or explicitly sized columns for this traditional section.
Use columnCount = 1 to restore normal single-column layout.
gap and widths are in 96-DPI layout pixels.
setColumns(columnCount: number, options?: IFDocumentSectionColumnOptions): booleanParameters
columnCount— Required.options— Optional. Default:{}.
Examples
const fDocument = univerAPI.getActiveDocument()if (fDocument?.isTraditional()) { fDocument.getSection(0)?.setColumns(2, { gap: 18, separator: true })}Types: IFDocumentSectionColumnOptions
Package: @univerjs/docs · Type definitions
FDocumentSection.setFooterLinkedToPrevious
Links or unlinks this footer variant. Unlinking clones the inherited footer.
setFooterLinkedToPrevious(linkedToPrevious: boolean, variant?: SectionHeaderFooterVariant): booleanParameters
linkedToPrevious— Required.variant— Optional. Default:'default'.
Examples
const fDocument = univerAPI.getActiveDocument()if (fDocument?.isTraditional()) { fDocument.getSection(1)?.setFooterLinkedToPrevious(true, 'even')}Types: SectionHeaderFooterVariant
Package: @univerjs/docs · Type definitions
FDocumentSection.setHeaderFooterOptions
Updates header/footer switches and margins on this section break.
marginHeader and marginFooter are in 96-DPI layout pixels.
setHeaderFooterOptions(options: IHeaderFooterProps): booleanParameters
options— Required.
Examples
const fDocument = univerAPI.getActiveDocument()if (fDocument?.isTraditional()) { fDocument.getSection(0)?.setHeaderFooterOptions({ marginHeader: 36, marginFooter: 36, useFirstPageHeaderFooter: univerAPI.Enum.BooleanNumber.TRUE, })}Types: IHeaderFooterProps
Package: @univerjs/docs · Type definitions
FDocumentSection.setHeaderLinkedToPrevious
Links or unlinks this header variant. Unlinking clones the inherited header.
setHeaderLinkedToPrevious(linkedToPrevious: boolean, variant?: SectionHeaderFooterVariant): booleanParameters
linkedToPrevious— Required.variant— Optional. Default:'default'.
Examples
const fDocument = univerAPI.getActiveDocument()if (fDocument?.isTraditional()) { fDocument.getSection(1)?.setHeaderLinkedToPrevious(false, 'default')}Types: SectionHeaderFooterVariant
Package: @univerjs/docs · Type definitions
FDocumentSection.setPageSetup
Updates this section's page setup through the document section command. Geometry values use 96-DPI layout pixels.
This method changes static page geometry; it does not choose where the
section begins. Use setSectionType() for an existing boundary, or
insertSectionBreak(..., { nextSectionType }) while creating one.
setPageSetup(pageSetup: FDocumentSectionPageSetup): booleanParameters
pageSetup— Required. Explicit section overrides to patch.
Returns
true when the section command was applied.
Examples
const document = univerAPI.getActiveDocument()if (!document?.isTraditional()) { throw new Error('A Traditional document is required')}const section = document.getSection(1)if (!section) { throw new Error('The second section does not exist')}const updated = section.setPageSetup({ pageSize: { width: 816, height: 1056 }, marginTop: 96, marginBottom: 96, marginLeft: 96, marginRight: 96,})if (!updated) { throw new Error('Failed to update section page setup')}console.log(section.getEffectivePageSetup())Types: FDocumentSectionPageSetup
Package: @univerjs/docs · Type definitions
FDocumentSection.setSectionType
Sets how this section begins relative to the previous section.
The first section has no preceding boundary, so setting its type does not
create an initial blank page. Prefer FDocument.insertSectionBreak with
nextSectionType when creating a new boundary; use this method when
updating an existing section after resolving it again from the document.
setSectionType(sectionType: SectionType): booleanParameters
sectionType— Required. How this section begins.
Returns
true when the section command was applied.
Examples
const document = univerAPI.getActiveDocument()if (!document?.isTraditional()) { throw new Error('A Traditional document is required')}const secondSection = document.getSection(1)if (!secondSection) { throw new Error('The second section does not exist')}if (!secondSection.setSectionType(univerAPI.Enum.SectionType.NEXT_PAGE)) { throw new Error('Failed to update the second section')}Types: SectionType
Package: @univerjs/docs · Type definitions
How is this guide?