This project has moved and is read-only. For the latest updates, please go here.

Problems with Tables and Merging Cells

Jun 29, 2016 at 1:20 PM
If you have a table with say 2 columns and add text to the first cell this works fine. However if you merge the 2 cells an extra blank line is added to the cell text. Is there anyway to fix/work around this. My code is :-

table.Rows[table.RowCount - 1].MergeCells(0, 1);
table.Rows[table.RowCount - 1].Cells[0].Paragraphs.First().Append("Notes Here");

What I end up with is 'Notes Here' in Cell 0 but with a line feed after which is not what I want as it leaves a blank line in the table row,
Jun 29, 2016 at 2:08 PM
I'm not yet familiar enough with how this all works but I believe the fault lies within the Row.MergeCells function in Table.cs. This adds the paragraph from each of the cells that are to be merged into the base cell. The problem with this is that if these cells contain aa single empty paragraphs then you end up with a cell with a load of blank paragraphs in them. I have 'fixed' this for my use by simply removing the line which copies the merged paragraphs into the primary cell. The 'correct' fix I feel is to see if the cell only contains a single, empty paragraph and do not copy it if this is the case.