BorderCollection class

BorderCollection class

A collection of Border objects. To learn more, visit the Programming with Documents documentation article.


Different document elements have different borders. For example, ParagraphFormat has BorderCollection.bottom, BorderCollection.left, BorderCollection.right and borders. You can specify different formatting for each border independently or enumerate through all borders and apply same formatting.


__getitem__(index)Retrieves a Border object by index.


bottomGets the bottom border.
colorGets or sets the border color.
countGets the number of borders in the collection.
distance_from_textGets or sets distance of the border from text in points.
horizontalGets the horizontal border that is used between cells or conforming paragraphs.
leftGets the left border.
line_styleGets or sets the border style.
line_widthGets or sets the border width in points.
rightGets the right border.
shadowGets or sets a value indicating whether the border has a shadow.
topGets the top border.
verticalGets the vertical border that is used between cells.


clear_formatting()Removes all borders of an object.
equals(br_coll)Compares collections of borders.
get_by_border_type(border_type)Retrieves a Border object by border type.


Shows how to insert a paragraph with a top border.

doc = aw.Document()
builder = aw.DocumentBuilder(doc)

top_border =
top_border.line_width = 4.0
top_border.line_style = aw.LineStyle.DASH_SMALL_GAP
# Set ThemeColor only when LineWidth or LineStyle setted.
top_border.theme_color = awthemes.ThemeColor.ACCENT1
top_border.tint_and_shade = 0.25

builder.writeln("Text with a top border.") + "Border.paragraph_top_border.docx")

See Also