Hi there,
I would like to create a table using Aspose.Words API which might have cells spanning more than one row or column. HTML code of these types of tables can be described as follows:
<table>
<tr>
<td rowspan="2" width="30%">This is cell spans two rows</td>
<td valign="top" width="45%">This is just a regular cell</td>
<td valign="top" width="45%" colspan="2">This cell spans two columns</td>
</tr>
<tr>
<td> Second Row Cell number 1</td>
<td> Second Row Cell number 2</td>
<td> Second Row Cell number 3</td>
</tr>
</table>
Now using Aspose.Words I can ofcourse create a table using insertCell() method of DocumentBuilder. I can set style/formatting to the content of the cells, but I could not find any method in any class like RowFormat or **CellFormat **using which I can write code to generate table like above. Please let me know if Aspose.Words have any solution to resolve this issue.
One more issue is with the width of a table cell. Is there anyways we can set the width of a table cell that is specified in percentage just like the above example using Aspose.Words? I can only find the method called setWidth from CellFormat class. But this only accepts double valued parameters in points. As I am trying to convert HTML to Word Document, I dont know what would be the exact width of my table cells in points. So please check this issue as well.
Thanks a lot.
Nafi Y Haque
Hi
Thanks for your inquiry. I think that you should use CellFormat.verticalMerge and CellFormat.HorizontalMerge. For example see the following code in C#.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.