Hello,
We discovered a problem on a Aspose test where are used properties VerticalMerge and HorizontalMerge. These properties are not evaluated correctly. I attached the test file.
Best regards,
Adriana Minea
Software Developer
IBM Romania
I’m attaching the unit test used when we discovered the problem.
TestFile.docx is the document attached to this thread.
[TestMethod]
public void ThenMergeStatusAreCorrect()
{
const string testFile = “TestFile.docx”;
var document = new Document(EmbeddedResourceHelper.GetStream(testFile, Assembly.GetExecutingAssembly()));
var firstTable = document.FirstSection.Body.Tables.ToArray().First();
var lastTable = document.FirstSection.Body.Tables.ToArray().Last();
Assert.IsNotNull(firstTable);
Assert.AreNotEqual(CellMerge.None, firstTable.FirstRow.Cells[0].CellFormat.HorizontalMerge);
Assert.IsNotNull(lastTable);
Assert.AreNotEqual(CellMerge.None, lastTable.FirstRow.Cells[0].CellFormat.VerticalMerge);
}
Hi Adriana,
foreach (Table tbl in doc.GetChildNodes(NodeType.Table, true))
{
foreach (Row row in tbl)
{
foreach (Cell cell in row.Cells)
{
Console.WriteLine(PrintCellMergeType(cell));
}
}
Console.WriteLine("---------------");
}
public static string PrintCellMergeType(Cell cell)
{
bool isHorizontallyMerged = cell.CellFormat.HorizontalMerge != CellMerge.None;
bool isVerticallyMerged = cell.CellFormat.VerticalMerge != CellMerge.None;
string cellLocation = string.Format("R{0}, C{1}", cell.ParentRow.ParentTable.IndexOf(cell.ParentRow) + 1, cell.ParentRow.IndexOf(cell) + 1);
if (isHorizontallyMerged && isVerticallyMerged)
return string.Format("The cell at {0} is both horizontally and vertically merged", cellLocation);
else if (isHorizontallyMerged)
return string.Format("The cell at {0} is horizontally merged.", cellLocation);
else if (isVerticallyMerged)
return string.Format("The cell at {0} is vertically merged", cellLocation);
else
return string.Format("The cell at {0} is not merged", cellLocation);
}