ApiExamples.ExTable.MergeCellRange C# (CSharp) Метод

MergeCellRange() приватный Метод

private MergeCellRange ( ) : void
Результат void
        public void MergeCellRange()
        {
            // Open the document
            Document doc = new Document(MyDir + "Table.Document.doc");

            // Retrieve the first table in the body of the first section.
            Table table = doc.FirstSection.Body.Tables[0];

            //ExStart
            //ExId:MergeCellRange
            //ExSummary:Merges the range of cells between the two specified cells.
            // We want to merge the range of cells found inbetween these two cells.
            Cell cellStartRange = table.Rows[2].Cells[2];
            Cell cellEndRange = table.Rows[3].Cells[3];

            // Merge all the cells between the two specified cells into one.
            MergeCells(cellStartRange, cellEndRange);
            //ExEnd

            // Save the document.
            doc.Save(MyDir + @"\Artifacts\Table.MergeCellRange.doc");

            // Verify the cells were merged
            int mergedCellsCount = 0;
            foreach(Cell cell in table.GetChildNodes(NodeType.Cell, true))
                if(cell.CellFormat.HorizontalMerge != CellMerge.None || cell.CellFormat.HorizontalMerge != CellMerge.None)
                    mergedCellsCount++;

            Assert.AreEqual(4, mergedCellsCount);
            Assert.True(table.Rows[2].Cells[2].CellFormat.HorizontalMerge == CellMerge.First);
            Assert.True(table.Rows[2].Cells[2].CellFormat.VerticalMerge == CellMerge.First);
            Assert.True(table.Rows[3].Cells[3].CellFormat.HorizontalMerge == CellMerge.Previous);
            Assert.True(table.Rows[3].Cells[3].CellFormat.VerticalMerge == CellMerge.Previous);
        }