This project has moved. For the latest updates, please go here.

Error with rowspan=1

Dec 1, 2012 at 3:56 PM

The following html produces an incorrect Word table:

<table>
  <tbody>
    <tr >
      <td rowspan="1" colspan="1">a</td>
      <td rowspan="1" colspan="1">b</td>
    </tr>
    <tr >
      <td rowspan="1" colspan="1">c</td>
      <td rowspan="1" colspan="1">d</td>
    </tr>
  </tbody>
</table>

I am using build 79962 and Word 2010.

Jan 15, 2013 at 11:20 PM

Can this please be registered as an issue? I have no control over the HTML I'm getting and this has become an issue for me

Jan 15, 2013 at 11:34 PM
Edited Jan 15, 2013 at 11:38 PM

I've made the following fix for this issue. 

On HtmlConverterProcessTag.cs I made these changes starting on line 946:

ORIGINAL

 

			int? colspan = en.Attributes.GetAsInt("colspan");
			if (colspan.HasValue)
			{
				styleAttributes.Add(new GridSpan() { Val = colspan });
			}

			int? rowspan = en.Attributes.GetAsInt("rowspan");
			if (rowspan.HasValue)
			{
				styleAttributes.Add(new VerticalMerge() { Val = MergedCellValues.Restart });
				tables.RowSpan[tables.CellPosition] = rowspan.Value - 1;
			}

 

REVISED

 

			int? colspan = en.Attributes.GetAsInt("colspan");
			if (colspan.HasValue && colspan!=1)
			{
				styleAttributes.Add(new GridSpan() { Val = colspan });
			}

			int? rowspan = en.Attributes.GetAsInt("rowspan");
			if (rowspan.HasValue && rowspan!=1)
			{
				styleAttributes.Add(new VerticalMerge() { Val = MergedCellValues.Restart });
				tables.RowSpan[tables.CellPosition] = rowspan.Value - 1;
			}

 

I suspect the problem is with that (something)=rowspan.Value -1 on the last line, can't really tell, so I took the safest approach and avoided both colspan and rowspan when equal to one. 

This fix has worked consistently for me

Coordinator
Feb 22, 2013 at 3:17 PM
Thank you very much for the feedback and the solution !
Sorry for the delay... but now it's committed.
Again thank you