We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Cell width after ApplyHorizontalMerge

Hi
Product DocIO, v15.3.0.29

Say you have a table with 2 columns; for some rows, there is a call to ApplyHorizontalMerge.
So far, everything's fine.

In each row, I add an image to the cells in that row, scaling the image if necessary, comparing cell.Width to the width of the image (see sample code)

      var image = (WPicture) para.AppendPicture(File.ReadAllBytes(filename));
      var w = cell.Width;
      if (image.Width > w) {
      ...     
    
As long as the cell have not been merged, everything is fine, but for merged cells, cell.Width returns the initial width of the cell, not the one resulting after adiacent cells in that row were merged.

I've seen there are two properties, CellStartPosition and CellEndPosition, but they're internal, so they're not available.

Is there a way to get the final width of a cell resulting from merging more cells horizontally?

TIA

3 Replies

SY Sethumanikkam Yogendran Syncfusion Team September 4, 2017 11:52 AM UTC

Hi Riccardo,

Thank you for contacting Syncfusion support.

Is there a way to get the final width of a cell resulting from merging more cells horizontally?
Currently it’s not possible to get the final width of merged cells from particular cell. But, you can get the final width of cell by getting sum of merged cells width. We have prepared a sample to meet your requirement and in this sample, we have done the following.

     1. Created Word document and added table with 3 rows and 2 columns.
     2. Horizontal merge applied to second row.
     3. Inserted image in each cell and resized width of image by comparing with final width of cell.

Please find the sample from below which illustrates the same, and let us know if this helps you.

Sample link:
http://www.syncfusion.com/downloads/support/forum/132460/ze/Sample-F132460--604983782.zip
Note: Kindly refer the input used and output document inside the sample application.

If we misunderstood any of your requirement, then kindly provide us your sample or modified above sample and screenshot/output Word document of the expected result along with input if any which will be helpful for us to provide you the appropriate solution at the earliest.

Please let us know if you have any other questions.

Regards,
Sethumanikkam.Y



RD Riccardo Dozzo September 5, 2017 09:16 PM UTC

Thanks, that sample solved my problem.

To get a general solution, I've created 3 extension methods for WTableCell, based on your sample, to get actual width and the index of the first and last column in merge set for merged column.

Cheers




SY Sethumanikkam Yogendran Syncfusion Team September 6, 2017 04:40 AM UTC

Hi Riccardo,

Thank you for your update.

We are happy to hear that the provided sample resolved your requirement. Please let us know if you need any further assistance on this. We will be happy to assist you as always.

Please let us know if you have any other questions.

Regards,
Sethumanikkam.Y


Loader.
Live Chat Icon For mobile
Up arrow icon