Take a look at the attached table.docx.
It seems like Aspose.Words is supposed to give you one cell for every possible position in the grid. The top position of a merged cell will be marked “First” for VerticalMerge. The left position of a merged cell will be marked “First” for HorizontalMerge. All other positions in the merged cell will be marked as “Previous”. So in my test table from table.docx it should be (as pairs of (Horizontal, Vertical) where F=First, P=Previous, N=None):
(F, F) (P, F) (N, N) (N, F)
(F, P) (P, P) (N, N) (N, P)
(N, N) (F, N) (P, N) (N, N)
(N, N) (N, N) (N, N) (N, N)
but instead Aspose.Words gives me
(N, F) (N, N) (N, F)
(N, P) (N, N) (N, P)
(N, N) (N, N) (N, N)
(N, N) (N, N) (N, N) (N, N)
So basically, take out all the cells that have Horizontal=Previous and change all the Horizontal=First cells to have Horizontal=None.
You can create the above output with:
var doc = new Aspose.Words.Document("table.docx");
var section = doc.ChildNodes[0] as Aspose.Words.Section;
var body = section.ChildNodes[0] as Aspose.Words.Body;
var table = body.ChildNodes[1] as Aspose.Words.Tables.Table;
foreach (Aspose.Words.Tables.Row row in table.Rows)
{
string line = "";
foreach (Aspose.Words.Tables.Cell cell in row.Cells)
{
line += "(" + cell.CellFormat.HorizontalMerge.ToString()[0] + ", ";
line += cell.CellFormat.VerticalMerge.ToString()[0] + ") ";
}
Console.WriteLine(line);
}