Shading Class
Contains shading attributes for an object.
Inheritance Hierarchy

Namespace: Aspose.Words
Assembly: Aspose.Words (in Aspose.Words.dll) Version: 19.11
public class Shading : InternableComplexAttr

The Shading type exposes the following members.

Public propertyCode exampleBackgroundPatternColor
Gets or sets the color that's applied to the background of the Shading object.
Public propertyCode exampleForegroundPatternColor
Gets or sets the color that's applied to the foreground of the Shading object.
Public propertyCode exampleTexture
Gets or sets the shading texture.
Public methodCode exampleClearFormatting
Removes shading from the object.
Public methodEquals(Object)
Determines whether the specified object is equal in value to the current object.
(Overrides ObjectEquals(Object).)
Public methodEquals(Shading)
Determines whether the specified Shading is equal in value to the current Shading.
Protected methodFinalize (Inherited from Object.)
Public methodGetHashCode
Serves as a hash function for this type.
(Overrides ObjectGetHashCode.)
Public methodGetType (Inherited from Object.)
Protected methodMemberwiseClone (Inherited from Object.)
Protected methodNotifyChanging (Inherited from InternableComplexAttr.)
Public methodToString (Inherited from Object.)
Shows how to apply borders and shading to a paragraph.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Set paragraph borders
BorderCollection borders = builder.ParagraphFormat.Borders;
borders.DistanceFromText = 20;
borders[BorderType.Left].LineStyle = LineStyle.Double;
borders[BorderType.Right].LineStyle = LineStyle.Double;
borders[BorderType.Top].LineStyle = LineStyle.Double;
borders[BorderType.Bottom].LineStyle = LineStyle.Double;

// Set paragraph shading
Shading shading = builder.ParagraphFormat.Shading;
shading.Texture = TextureIndex.TextureDiagonalCross;
shading.BackgroundPatternColor = Color.LightCoral;
shading.ForegroundPatternColor = Color.LightSalmon;

builder.Write("I'm a formatted paragraph with double border and nice shading.");
Shows how to format table and cell with different borders and shadings
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

Table table = builder.StartTable();

// Set the borders for the entire table.
table.SetBorders(LineStyle.Single, 2.0, Color.Black);
// Set the cell shading for this cell.
builder.CellFormat.Shading.BackgroundPatternColor = Color.Red;
builder.Writeln("Cell #1");

// Specify a different cell shading for the second cell.
builder.CellFormat.Shading.BackgroundPatternColor = Color.Green;
builder.Writeln("Cell #2");

// End this row.

// Clear the cell formatting from previous operations.

// Create the second row.

// Create larger borders for the first cell of this row. This will be different
// compared to the borders set for the table.
builder.CellFormat.Borders.Left.LineWidth = 4.0;
builder.CellFormat.Borders.Right.LineWidth = 4.0;
builder.CellFormat.Borders.Top.LineWidth = 4.0;
builder.CellFormat.Borders.Bottom.LineWidth = 4.0;
builder.Writeln("Cell #3");

// Clear the cell formatting from the previous cell.
builder.Writeln("Cell #4");

doc.Save(ArtifactsDir + "Table.SetBordersAndShading.doc");
See Also