DocumentExpandTableStylesToDirectFormatting Method

Converts formatting specified in table styles into direct formatting on tables in the document.

Namespace:  Aspose.Words
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.3
Syntax
public void ExpandTableStylesToDirectFormatting()
Remarks

This method exists because this version of Aspose.Words provides only limited support for table styles (see below). This method might be useful when you load a DOCX or WordprocessingML document that contains tables formatted with table styles and you need to query formatting of tables, cells, paragraphs or text.

This version of Aspose.Words provides limited support for table styles as follows:

  • Table styles defined in DOCX or WordprocessingML documents are preserved as table styles when saving the document as DOCX or WordprocessingML.
  • Table styles defined in DOCX or WordprocessingML documents are automatically converted to direct formatting on tables when saving the document into any other format, rendering or printing.
  • Table styles defined in DOC documents are preserved as table styles when saving the document as DOC only.
Examples
Shows how to expand the formatting from styles onto the rows and cells of the table as direct formatting.
Document doc = new Document(MyDir + "Tables.docx");

// Get the first cell of the first table in the document
Table table = (Table) doc.GetChild(NodeType.Table, 0, true);
Cell firstCell = table.FirstRow.FirstCell;

// First print the color of the cell shading. This should be empty as the current shading
// is stored in the table style
double cellShadingBefore = table.FirstRow.RowFormat.Height;
Console.WriteLine("Cell shading before style expansion: " + cellShadingBefore);

// Expand table style formatting to direct formatting
doc.ExpandTableStylesToDirectFormatting();

// Now print the cell shading after expanding table styles. A blue background pattern color
// should have been applied from the table style
double cellShadingAfter = table.FirstRow.RowFormat.Height;
Console.WriteLine("Cell shading after style expansion: " + cellShadingAfter);

doc.Save(ArtifactsDir + "Document.TableStyleToDirectFormatting.docx");
See Also