TextColumnCollection class

TextColumnCollection class

A collection of TextColumn objects that represent all the columns of text in a section of a document. To learn more, visit the Working with Sections documentation article.

Remarks

Use TextColumnCollection.set_count() to set the number of text columns.

To make all columns equal width and spaced evenly, set TextColumnCollection.evenly_spaced to True and specify the amount of space between the columns in TextColumnCollection.spacing. MS Word will automatically calculate column widths.

If you have TextColumnCollection.evenly_spaced set to False, you need to specify width and spacing for each column individually. Use the indexer to access individual TextColumn objects.

When using custom column widths, make sure the sum of all column widths and spacings between them equals page width minus left and right page margins.

Indexers

NameDescription
__getitem__(index)Returns a text column at the specified index.

Properties

NameDescription
countGets the number of columns in the section of a document.
evenly_spacedTrue if text columns are of equal width and evenly spaced.
line_betweenWhen True, adds a vertical line between columns.
spacingWhen columns are evenly spaced, gets or sets the amount of space between each column in points.
widthWhen columns are evenly spaced, gets the width of the columns.

Methods

NameDescription
set_count(new_count)Arranges text into the specified number of text columns.

Examples

Shows how to create multiple evenly spaced columns in a section.

doc = aw.Document()
builder = aw.DocumentBuilder(doc)
columns = builder.page_setup.text_columns
columns.spacing = 100
columns.set_count(2)
builder.writeln('Column 1.')
builder.insert_break(aw.BreakType.COLUMN_BREAK)
builder.writeln('Column 2.')
doc.save(file_name=ARTIFACTS_DIR + 'PageSetup.ColumnsSameWidth.docx')

See Also