Shading class

Shading class

Contains shading attributes for an object. To learn more, visit the Programming with Documents documentation article.

Inheritance: ShadingInternableComplexAttr


background_pattern_colorGets or sets the color that’s applied to the background of the Shading object.
background_pattern_theme_colorGets or sets the background pattern theme color in the applied color scheme that is associated with this Shading object.
background_tint_and_shadeGets or sets a double value that lightens or darkens a background theme color.
foreground_pattern_colorGets or sets the color that’s applied to the foreground of the Shading object.
foreground_pattern_theme_colorGets or sets the foreground pattern theme color in the applied color scheme that is associated with this Shading object.
foreground_tint_and_shadeGets or sets a double value that lightens or darkens a foreground theme color.
textureGets or sets the shading texture.


clear_formatting()Removes shading from the object.
equals(rhs)Determines whether the specified Shading is equal in value to the current Shading.


Shows how to apply border and shading color while building a table.

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

# Start a table and set a default color/thickness for its borders.
table = builder.start_table()
table.set_borders(aw.LineStyle.SINGLE, 2.0,

# Create a row with two cells with different background colors.
builder.cell_format.shading.background_pattern_color = drawing.Color.light_sky_blue
builder.writeln("Row 1, Cell 1.")
builder.cell_format.shading.background_pattern_color =
builder.writeln("Row 1, Cell 2.")

# Reset cell formatting to disable the background colors
# set a custom border thickness for all new cells created by the builder,
# then build a second row.
builder.cell_format.borders.left.line_width = 4.0
builder.cell_format.borders.right.line_width = 4.0 = 4.0
builder.cell_format.borders.bottom.line_width = 4.0

builder.writeln("Row 2, Cell 1.")
builder.writeln("Row 2, Cell 2.") + "DocumentBuilder.table_borders_and_shading.docx")

Shows how to decorate text with borders and shading.

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

borders = builder.paragraph_format.borders
borders.distance_from_text = 20
borders.left.line_style = aw.LineStyle.DOUBLE
borders.right.line_style = aw.LineStyle.DOUBLE = aw.LineStyle.DOUBLE
borders.bottom.line_style = aw.LineStyle.DOUBLE

shading = builder.paragraph_format.shading
shading.texture = aw.TextureIndex.TEXTURE_DIAGONAL_CROSS
shading.background_pattern_color = drawing.Color.light_coral
shading.foreground_pattern_color = drawing.Color.light_salmon

builder.write("This paragraph is formatted with a double border and shading.") + "DocumentBuilder.apply_borders_and_shading.docx")

See Also