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

Set cell width to text length

Thread ID:

Created:

Updated:

Platform:

Replies:

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

Hi,
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

GE

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

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:

[C#]

// Autofit Columns
sheet.Range["A1:B1"].AutofitColumns();

Here is the sample for your reference:

http://websamples.syncfusion.com/samples/XlsIO.Web/4.4.0.51/59311/main.htm

Kindly let me know if you have any other questions.

Thanks,
Melba

CONFIRMATION

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.

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.

;