TableDescription Property |
Namespace: Aspose.Words.Tables
The default value is an empty string.
This property is meaningful for ISO/IEC 29500 compliant DOCX documents (OoxmlCompliance). When saved to pre-ISO/IEC 29500 formats, the property is ignored.
public void CreateNestedTable() { Document doc = new Document(); // Create the outer table with three rows and four columns Table outerTable = CreateTable(doc, 3, 4, "Outer Table"); // Add it to the document body doc.FirstSection.Body.AppendChild(outerTable); // Create another table with two rows and two columns Table innerTable = CreateTable(doc, 2, 2, "Inner Table"); // Add this table to the first cell of the outer table outerTable.FirstRow.FirstCell.AppendChild(innerTable); doc.Save(ArtifactsDir + "Table.CreateNestedTable.doc"); Assert.AreEqual(2, doc.GetChildNodes(NodeType.Table, true).Count); // ExSkip } /// <summary> /// Creates a new table in the document with the given dimensions and text in each cell. /// </summary> private static Table CreateTable(Document doc, int rowCount, int cellCount, string cellText) { Table table = new Table(doc); // Create the specified number of rows for (int rowId = 1; rowId <= rowCount; rowId++) { Row row = new Row(doc); table.AppendChild(row); // Create the specified number of cells for each row for (int cellId = 1; cellId <= cellCount; cellId++) { Cell cell = new Cell(doc); row.AppendChild(cell); // Add a blank paragraph to the cell cell.AppendChild(new Paragraph(doc)); // Add the text cell.FirstParagraph.AppendChild(new Run(doc, cellText)); } } // You can add title and description to your table only when added at least one row to the table first // This properties are meaningful for ISO / IEC 29500 compliant DOCX documents(see the OoxmlCompliance class) // When saved to pre-ISO/IEC 29500 formats, the properties are ignored table.Title = "Aspose table title"; table.Description = "Aspose table description"; return table; }