After Removing column from the table in docio word,table is not autoresized


HI Team,

facing below issue while removing cell from table except first row.
Table is not autoresized



code:

            //Remove cell from each table row except first row

            for (int rowIndex = 1; rowIndex < table.Rows.Count; rowIndex++)
            {
                table.Rows[rowIndex].Cells.RemoveAt(indexToRemove);
            }
            table.TableFormat.IsAutoResized = true;
  



Original table:




1 Reply 1 reply marked as answer

MR Manikandan Ravichandran Syncfusion Team September 8, 2020 05:16 PM UTC

Hi Hardik,

Thank you for contacting Syncfusion support.

From the given details, we have found that your requirement is to remove the particular column from the table except first row in the table and also wants to adjust the cells in the remining rows automatically to the first row. When we remove the particular column from the table except first row, the Microsoft Word application also not automatically readjust the cells based on the first row. So, we did the same in our library. If you want to adjust the cells based on the first row, you can manually resize the cell’s width in remining rows as like below.

 
for (int rowIndex = 1; rowIndex < table.Rows.Count; rowIndex++)
{
   
float width = table.Rows[rowIndex].Cells[indexToRemove].Width;
    table.Rows[rowIndex].Cells.RemoveAt(indexToRemove);
    //Add the removed cell width to adjacent cell
    table.Rows[rowIndex].Cells[indexToRemove].Width += width;
}
table.TableFormat.IsAutoResized =
true; 

Based on the above, we have prepared the sample and it can be downloaded from the below link.
https://www.syncfusion.com/downloads/support/forum/157637/ze/ResizeTable-52492223

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

Please let us know if you have any other questions.

Regards,
Manikandan Ravichandran 


Marked as answer
Loader.
Up arrow icon