TableConvertToHorizontallyMergedCells Method |
Namespace: Aspose.Words.Tables
Document doc = new Document(MyDir + "Table with merged cells.docx"); // MS Word does not write merge flags anymore, they define merged cells by its width // So AW by default define only 5 cells in a row and all of it didn't have horizontal merge flag Table table = doc.FirstSection.Body.Tables[0]; Row row = table.Rows[0]; Assert.AreEqual(5, row.Cells.Count); // To resolve this inconvenience, we have added new public method to convert cells which are horizontally merged // by its width to the cell horizontally merged by flags. Thus now we have 7 cells and some of them have // horizontal merge value table.ConvertToHorizontallyMergedCells(); row = table.Rows[0]; Assert.AreEqual(7, row.Cells.Count); Assert.AreEqual(CellMerge.None, row.Cells[0].CellFormat.HorizontalMerge); Assert.AreEqual(CellMerge.First, row.Cells[1].CellFormat.HorizontalMerge); Assert.AreEqual(CellMerge.Previous, row.Cells[2].CellFormat.HorizontalMerge); Assert.AreEqual(CellMerge.None, row.Cells[3].CellFormat.HorizontalMerge); Assert.AreEqual(CellMerge.First, row.Cells[4].CellFormat.HorizontalMerge); Assert.AreEqual(CellMerge.Previous, row.Cells[5].CellFormat.HorizontalMerge); Assert.AreEqual(CellMerge.None, row.Cells[6].CellFormat.HorizontalMerge);