Help with RowSpan


#1

When I was implementing column span, any cell tagged as
HorizontalMerge.Previous needed a width of 0. Are there any
special cases for cells tagged as VerticalMerge.Previous? Right
now each cell tagged as VerticalMerge.Previous pushes the table border
out a few pixels.



Thanks, Natan.


#2

I may have answered my own question. I’m guessing any cell marked
as VerticalMerge.Previous should get a width equal to the cell above
it. In fact, it seems that all cells with the VerticalMerge
property set should have equal widths.



One more question. If the pointer is located in the third and
last cell of a row, and I call MoveToCell() to position the pointer in
the first cell, what happens when I call InsertCell()? Does it
insert a cell where the pointer is located, or will it add a cell to
the end of a row?



If it’s not too much trouble, could you post some sample code of how to
do rowspan correctly with a 2x2 table? I can’t find any sample
code in your documentation.



Thanks, Natan.


#3

Here is a workable example. We will add it to the product documentation in the next release.

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

// Make Horizontal Merge

builder.InsertCell();

builder.CellFormat.HorizontalMerge = CellMerge.First;

builder.Write("Text in the merged cells.");

builder.InsertCell();

builder.CellFormat.HorizontalMerge = CellMerge.Previous;

builder.EndRow();

builder.InsertCell();

builder.CellFormat.HorizontalMerge = CellMerge.None;

builder.Write("Text in one cell.");

builder.InsertCell();

builder.Write("Text in another cell.");

builder.EndRow();

// Make Vertical Merge

builder.InsertCell();

builder.CellFormat.VerticalMerge = CellMerge.First;

builder.Write("Text in the merged cells.");

builder.InsertCell();

builder.CellFormat.VerticalMerge = CellMerge.None;

builder.Write("Text in one cell");

builder.EndRow();

builder.InsertCell();

//This cell is vertically merged to the cell above and shoudl be empty.

builder.CellFormat.VerticalMerge = CellMerge.Previous;

builder.InsertCell();

builder.CellFormat.VerticalMerge = CellMerge.None;

builder.Write("Text in another cell");

builder.EndRow();

doc.Save(Application.StartupPath + @"\testCellMerge Out.doc");

Here is also a note from API Reference on VerticalMerge:

Cells can only be merged vertically if their left and right boundaries are identical.

When cells are vertically merged, the display areas of the merged cells are consolidated. The consolidated area is used to display the contents of the first vertically merged cell and all other vertically merged cells must be empty.

The same is true on HorizontalMerge.