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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to Autofit to Contents in a Word table?

Thread ID:





148395 Oct 17,2019 04:59 PM UTC Oct 18,2019 09:26 AM UTC ASP.NET Web Forms (Classic) 1
Tags: DocIO
Bert Sirkin
Asked On October 17, 2019 08:48 PM UTC

Is there a way to autofit to contents all of the table columns in a Word document created with DocIO?

Poorani Rajendran [Syncfusion]
Replied On October 18, 2019 09:26 AM UTC

Hi Bert,

Thank you for contacting Syncfusion support.

To meet your requirement, we suggest you use IsAutoResized API to auto resize of table to automatically resize all cell width based on its content. Please use the below highlighted code snippet in your sample application.

//Creates an instance of WordDocument class (Empty Word Document)
WordDocument document = new WordDocument();
//Opens an existing Word document into DocIO instance
document.Open("Table.docx", FormatType.Docx);
//Accesses the instance of the first section in the Word document
WSection section = document.Sections[0];
//Accesses the instance of the first table in the section
WTable table = section.Tables[0] as WTable;
//Specifies the auto resize of table to automatically resize all cell width based on its content
table.TableFormat.IsAutoResized = true;
//Saves and closes the document instance
document.Save("TableFormatting.docx", FormatType.Docx);

Please refer the below UG documentation link to know more about working with table and apply formatting to table in Word document using DocIO:

Please let us know if you have any other questions.

Poorani Rajendran


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon