public void RetrievePreferredWidthType() { //ExStart:RetrievePreferredWidthType Document doc = new Document(MyDir + "Tables.docx"); Table table = (Table)doc.GetChild(NodeType.Table, 0, true); //ExStart:AllowAutoFit table.AllowAutoFit = true; //ExEnd:AllowAutoFit Cell firstCell = table.FirstRow.FirstCell; PreferredWidthType type = firstCell.CellFormat.PreferredWidth.Type; double value = firstCell.CellFormat.PreferredWidth.Value; //ExEnd:RetrievePreferredWidthType }
/// <summary> /// Shows how to retrieves the preferred width type of a table cell. /// </summary> private static void RetrievePreferredWidthType(string dataDir) { // ExStart:RetrievePreferredWidthType Document doc = new Document(dataDir + "Table.SimpleTable.doc"); // Retrieve the first table in the document. Table table = (Table)doc.GetChild(NodeType.Table, 0, true); // ExStart:AllowAutoFit table.AllowAutoFit = true; // ExEnd:AllowAutoFit Cell firstCell = table.FirstRow.FirstCell; PreferredWidthType type = firstCell.CellFormat.PreferredWidth.Type; double value = firstCell.CellFormat.PreferredWidth.Value; // ExEnd:RetrievePreferredWidthType Console.WriteLine("\nTable preferred width type value is " + value.ToString()); }
public void GetPreferredWidthTypeAndValue() { Document doc = new Document(MyDir + "Table.Document.doc"); // Find the first table in the document Table table = (Table)doc.GetChild(NodeType.Table, 0, true); //ExStart //ExFor:PreferredWidthType //ExFor:PreferredWidth.Type //ExFor:PreferredWidth.Value //ExId:GetPreferredWidthTypeAndValue //ExSummary:Retrieves the preferred width type of a table cell. Cell firstCell = table.FirstRow.FirstCell; PreferredWidthType type = firstCell.CellFormat.PreferredWidth.Type; double value = firstCell.CellFormat.PreferredWidth.Value; //ExEnd Assert.AreEqual(PreferredWidthType.Percent, type); Assert.AreEqual(11.16, value); }