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
        }
Example #2
0
        /// <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());
        }
Example #3
0
        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);
        }