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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Set cell width to text length

Thread ID:





59311 Apr 10,2007 07:50 PM UTC Apr 12,2007 10:11 AM UTC ASP.NET Web Forms (Classic) 1
Tags: XlsIO
Asked On April 10, 2007 07:50 PM UTC

Is there a way to set the column width of cells to the length of the text within the cells?
I am copying a portion of sheet from one to another but it does not maintain the cell width when I use IRange copyTo method? Is there a way this can be handled?

Thanks a lot


Melba Winshia [Syncfusion]
Replied On April 12, 2007 10:11 AM UTC

Hi Emperor,

Yes, it is possible to set the column width of cells to the length of the text within the cells by using AutofitColumns. By using this property we can auto Size the width of a cell according to its content. Please use the following code snippet to achieve this:


// Autofit Columns

Here is the sample for your reference:


Kindly let me know if you have any other questions.



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