We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to calculate merged cell width using .NET

Hi there,

I’m going to add a table to a Word file with some merged cells and then I need to put an image inside one of the merged cells.
I was wondering how to calculate the spanning cell width in order to get the image with the correct size inserted inside the cell?
I attached a word file showing the expected output.

nested_image.zip (553.9 KB)

Thanks,

@behrouz

There is no column concept in MS Word’s table. By Microsoft Word design, rows in a table in a Microsoft Word document are completely independent. It means each row can have any number of cells of any width. So, if you imagine first row with one wide cell and second row with two narrow cells, then looking at this document the cell in the first row will appear horizontally merged. But it is not a merged cell; it is just a single wide cell.

Another perfectly valid scenario is when the first row has two cells. First cell has CellMerge.First and second cell has CellMerge.Previous, in this case it is a merged cell. In both cases, the visual appearance in MS Word is exactly the same. Both cases are valid.

To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word document.
  • Please attach the output Word file that shows the undesired behavior.
  • Please create a standalone console application ( source code without compilation errors ) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.