Hi,
Please see the below code and attachment. This code is supposed to be generated dynamically according to the business requirement. The use desings a pattern as shown in the attached figure. I have regenerated the code statically for you. For the horizontal merge, for best result, we add the cell width of the following cells to the first cell and set the width of the following cells to zero if the column span > 1 [for eg: if a cell has colspan 2, if width of the cell is 100 and of next cell is 100, the width of the cell is set to 200 and second cell to 0 , and then merge them]. Height of the rows are not done in this way since height is set for the entire row. Please see the word doc and HTML generated by the below code and see the difference. Please tell us a solution for the height difference if possilble.
Regards,
Ali.
*Code
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.CellFormat.Borders.LineStyle = LineStyle.Single;
// first row
builder.RowFormat.Height = 50;
builder.InsertCell();
builder.CellFormat.Width = 200;
builder.CellFormat.HorizontalMerge = CellMerge.First;
builder.CellFormat.VerticalMerge = CellMerge.First;
builder.InsertCell();
builder.CellFormat.Width = 0;
builder.CellFormat.HorizontalMerge = CellMerge.Previous;
builder.CellFormat.VerticalMerge = CellMerge.First;
builder.InsertCell();
builder.CellFormat.Width = 100;
builder.CellFormat.HorizontalMerge = CellMerge.None;
builder.CellFormat.VerticalMerge = CellMerge.None;
builder.InsertCell();
builder.CellFormat.Width = 100;
builder.CellFormat.HorizontalMerge = CellMerge.None;
builder.CellFormat.VerticalMerge = CellMerge.None;
builder.EndRow();
// second row
builder.RowFormat.Height = 100;
builder.InsertCell();
builder.CellFormat.Width = 200;
builder.CellFormat.HorizontalMerge = CellMerge.First;
builder.CellFormat.VerticalMerge = CellMerge.Previous;
builder.InsertCell();
builder.CellFormat.Width = 0;
builder.CellFormat.HorizontalMerge = CellMerge.Previous;
builder.CellFormat.VerticalMerge = CellMerge.Previous;
builder.InsertCell();
builder.CellFormat.Width = 200;
builder.CellFormat.HorizontalMerge = CellMerge.First;
builder.CellFormat.VerticalMerge = CellMerge.First;
builder.InsertCell();
builder.CellFormat.Width = 0;
builder.CellFormat.HorizontalMerge = CellMerge.Previous;
builder.CellFormat.VerticalMerge = CellMerge.First;
builder.EndRow();
// third row
builder.RowFormat.Height = 50;
builder.InsertCell();
builder.CellFormat.Width = 200;
builder.CellFormat.HorizontalMerge = CellMerge.First;
builder.CellFormat.VerticalMerge = CellMerge.None;
builder.InsertCell();
builder.CellFormat.Width = 0;
builder.CellFormat.HorizontalMerge = CellMerge.Previous;
builder.CellFormat.VerticalMerge = CellMerge.None;
builder.InsertCell();
builder.CellFormat.Width = 200;
builder.CellFormat.HorizontalMerge = CellMerge.First;
builder.CellFormat.VerticalMerge = CellMerge.Previous;
builder.InsertCell();
builder.CellFormat.Width = 0;
builder.CellFormat.HorizontalMerge = CellMerge.Previous;
builder.CellFormat.VerticalMerge = CellMerge.Previous;
builder.EndRow();
builder.EndTable();
// save as doc
// save as HTML