Free Support Forum - aspose.com

Document builder and supporting Colspan

Hi Roman,
I’ve started work on a HTML to Word converter and I’ve come across a snag:

How would I code the following HTML:




I’m using version 1.4.5.0

Many thanks

Best regards
Steve

Hi Steve,

If you want one cell to span 5 cells like in the previous row, you need to know the cell widths in the top row and just create one cell whose width is the sum of the previous row cell widths.

It will be a bit more involved to create a cell that spans 5 cells of the following row as you will need to know cell widths of the next row.

The complete solution will probably be to parse all HTML table and build an array of cell widths in memory and output to Word only after that. You will need to specify explicit cell widths for Word table cells in any case - you cannot use relative or percent sizes like in HTML.

Although HTML to Word converter is a feature we plan to implement ourselves, I’m sorry that we cannot start working on it right now and you have to do it yourself. So my advice is try to do as little as possible just to satisfy your requirements.

Hi Roman,

Hmm, sounds reasonable.

My initial results look promising, though my test case (I picked a good one :frowning: ) also includes rowspan cells. How would these port to documentbuilder?

Cheers
Steve

I can add a property to the CellFormat object that specifies if it’s vertically merged with the cell above it.

Actually there is also a property I can add that specifies if the cell is horizontally merged with the previous cell. Although this is not likely to change what I proposed before - you still need to calculate widths of all cells before you add them to a Word table.

I’ll add these in tonight’s hotfix.

Hi Steve,

Check out latest Aspose.Word 1.4.7 for CellFormat.HorizontalMerge and CellFormat.VerticalMerge properties.

Hi Roman,
Thanks for the speedy reponse - that should do what I need.

Only problem is the methods seem to be missing from the build…

I’ve checked the assembly version and it is 1.4.7

Best regards
Steve

I’ve just refreshed it. Please download again.

Thanks Roman…!

S.