Search code examples
c#ms-wordaspose

nested tables in aspose


I need to divide two cells in adjacent columns into X equal cells horizontally. I am given a DocumentBuilder, pointing to the cell. I decided that I can insert a separate table into the cell:

var table = builder.StartTable();

builder.InsertCell();

table.AutoFit(AutoFitBehavior.AutoFitToWindow);

builder.Write("1");
builder.EndRow();

builder.InsertCell();
builder.Write("2");
builder.EndRow();

builder.EndTable();

But still, there is a margin on the sides of the inner table:

enter image description here(ignore the left cell being splitted by horizontal thick line)

I googled that table.AutoFit(AutoFitBehavior.AutoFitToWindow); should solve the problem, but it doesn't. What am I supposed to do, to get desired output:

enter image description here


Solution

  • I managed to split the cell vertically, by setting all other cells in a row cell.CellFormat.VerticalMerge = CellMerge.First, then adding X - 1 rows, in which cells are cell.CellFormat.VerticalMerge = CellMerge.Previous, except cells in columns to de divided.