FDocumentColumn
Facade object for a single column inside a docs column group.
Columns in this facade belong to the modern-document ColumnGroup model. Read methods return empty values in traditional mode; mutation methods throw a flavor-specific error.
The column wrapper resolves its range from persisted column ids every time a method is called, so it stays useful after edits insert content before the column group.
Access
Access through:
Example
const fDocument = univerAPI.getActiveDocument()const group = fDocument.findColumnGroupByText('Launch')console.log(group?.describe())const column = group?.getColumn(0)console.log(column?.getText())console.log(column?.getInsertOffset())Setup
Register @univerjs-pro/docs-column or a preset that includes it. In plugin mode, import @univerjs-pro/docs-column/facade. Additional methods below require their listed plugin packages. See Facade setup.
@univerjs-pro/docs-column
FDocumentColumn.appendParagraph
Appends a plain-text paragraph inside this column.
appendParagraph(text?: string): FDocumentParagraphParameters
text— Optional. Default:''. The paragraph text. Defaults to an empty paragraph.
Returns
The appended paragraph facade.
Examples
const fDocument = univerAPI.getActiveDocument()const column = fDocument?.findColumnGroupByText('Launch')?.getColumn(0)const paragraph = column?.appendParagraph('Next steps')console.log(paragraph?.getText())Types: FDocumentParagraph
Package: @univerjs-pro/docs-column · Type definitions
FDocumentColumn.getColumnGroupId
Returns the parent column group id.
getColumnGroupId(): stringReturns
The persisted column group id.
Examples
const fDocument = univerAPI.getActiveDocument()const group = fDocument.findColumnGroupByText('Launch')const column = group?.getColumn(0)console.log(column?.getColumnGroupId())Package: @univerjs-pro/docs-column · Type definitions
FDocumentColumn.getContentRange
Returns the editable content range inside this column.
The range excludes the column structural tokens and stops before the trailing
paragraph or section-break token that keeps the column editable. Use this range
for text replacement and getInsertOffset() for inserting blocks, such as tables.
getContentRange(): IDocsColumnContentRange | nullReturns
The editable range, or null if the column no longer exists.
Examples
const fDocument = univerAPI.getActiveDocument()const group = fDocument.findColumnGroupByText('Launch')const column = group?.getColumn(0)console.log(column?.getContentRange())Types: IDocsColumnContentRange
Package: @univerjs-pro/docs-column · Type definitions
FDocumentColumn.getId
Returns the column id stored in the parent column group config.
getId(): stringReturns
The persisted column id.
Examples
const fDocument = univerAPI.getActiveDocument()const group = fDocument.findColumnGroupByText('Launch')const column = group?.getColumn(0)console.log(column?.getId())Package: @univerjs-pro/docs-column · Type definitions
FDocumentColumn.getIndex
Returns the current zero-based column index inside the parent group.
getIndex(): numberReturns
The column index, or -1 when the column no longer exists.
Examples
const fDocument = univerAPI.getActiveDocument()const group = fDocument.findColumnGroupByText('Launch')const column = group?.getColumn(0)console.log(column?.getIndex())Package: @univerjs-pro/docs-column · Type definitions
FDocumentColumn.getInsertOffset
Returns the safest insertion offset for adding content at the end of this column.
This offset is intentionally placed before the trailing paragraph or section-break token when one exists. Keeping that trailing token after inserted tables prevents the table from being parsed as content outside the column group.
getInsertOffset(): number | nullReturns
The insertion offset, or null if the column no longer exists.
Examples
const fDocument = univerAPI.getActiveDocument()const group = fDocument.findColumnGroupByText('Launch')const thirdColumn = group?.getColumn(2)const offset = thirdColumn?.getInsertOffset()if (offset != null) { fDocument?.insertTableFromData( [ ['Metric', 'Now', 'Next'], ['Adoption', '68%', '80%'], ], { offset, }, )}Package: @univerjs-pro/docs-column · Type definitions
FDocumentColumn.getParagraphs
Returns paragraph facades whose paragraph marks are contained in this column.
getParagraphs(): FDocumentParagraph[]Returns
Paragraphs in column-local order.
Examples
const fDocument = univerAPI.getActiveDocument()const column = fDocument?.findColumnGroupByText('Launch')?.getColumn(0)const paragraphs = column?.getParagraphs() ?? []console.log(paragraphs.map((paragraph) => paragraph.getText()))Types: FDocumentParagraph
Package: @univerjs-pro/docs-column · Type definitions
FDocumentColumn.getRange
Returns the structural data-stream range for this column. The range includes the column start and end structural tokens.
getRange(): IDocsColumnOffsetRange | nullReturns
The column range, or null if the column no longer exists.
Examples
const fDocument = univerAPI.getActiveDocument()const group = fDocument.findColumnGroupByText('Launch')const column = group?.getColumn(0)console.log(column?.getRange())Types: IDocsColumnOffsetRange
Package: @univerjs-pro/docs-column · Type definitions
FDocumentColumn.getText
Returns plain text inside the column.
Paragraph breaks are normalized to \n, and trailing structural breaks are omitted.
getText(): stringReturns
The column text, or an empty string if the column no longer exists.
Examples
const fDocument = univerAPI.getActiveDocument()const group = fDocument.findColumnGroupByText('Launch')const column = group?.getColumn(0)console.log(column?.getText())Package: @univerjs-pro/docs-column · Type definitions
FDocumentColumn.getTextRange
Returns an editable text-range facade for the column content.
getTextRange(): FDocumentTextRange | nullReturns
The editable range, or null if the column no longer exists.
Examples
const fDocument = univerAPI.getActiveDocument()const column = fDocument?.findColumnGroupByText('Launch')?.getColumn(0)console.log(column?.getTextRange()?.getText())Types: FDocumentTextRange
Package: @univerjs-pro/docs-column · Type definitions
FDocumentColumn.insertParagraph
Inserts a plain-text paragraph at a column-local paragraph index.
The index is relative to this column, not the whole document. Passing the
current paragraph count appends inside the column, before COLUMN_END.
insertParagraph(index: number, text?: string): FDocumentParagraphParameters
index— Required. The zero-based column-local paragraph insertion index.text— Optional. Default:''. The paragraph text. Defaults to an empty paragraph.
Returns
The inserted paragraph facade.
Throws
If the index is outside 0..getParagraphs().length.
Examples
const fDocument = univerAPI.getActiveDocument()const column = fDocument?.findColumnGroupByText('Launch')?.getColumn(0)// The index is relative to this column. This inserts before its first paragraph.const paragraph = column?.insertParagraph(0, 'Executive summary')console.log(paragraph?.getText())Types: FDocumentParagraph
Package: @univerjs-pro/docs-column · Type definitions
FDocumentColumn.setText
Replaces the editable column content with plain text.
setText(text: string): booleanParameters
text— Required. The replacement text.
Returns
true if the edit was applied.
Examples
const fDocument = univerAPI.getActiveDocument()const column = fDocument?.findColumnGroupByText('Launch')?.getColumn(0)column?.setText('Launch plan\nOwner: Product')Package: @univerjs-pro/docs-column · Type definitions
FDocumentColumn.setTextStyle
Applies a text-style patch across the editable column content.
style.fs is a font size in points (pt), not CSS pixels.
setTextStyle(style: ITextStyle): booleanParameters
style— Required. The text-style patch to apply.
Returns
true if the edit was applied.
Examples
const fDocument = univerAPI.getActiveDocument()const column = fDocument?.findColumnGroupByText('Launch')?.getColumn(0)column?.setTextStyle({ fs: 10.5, bl: univerAPI.Enum.BooleanNumber.TRUE })Types: ITextStyle
Package: @univerjs-pro/docs-column · Type definitions
你觉得这篇文档如何?