This is a migrated thread and some comments may be shown as answers.

Resize only 'used' columns

1 Answer 131 Views
SpreadProcessing
This is a migrated thread and some comments may be shown as answers.
Evelyn
Top achievements
Rank 1
Evelyn asked on 10 Feb 2016, 12:42 PM
I am using the RadSpreadsheet component and I am filling it with data from code behind. I would like to resize only the 'used' columns to a width that fits the content from each column. Something like the AutoFitWidth(). 

I tried to use this method (AutoFitWidth()) in a ColumnSelection, however I could only use in all columns, not just the ones I used and I took more than 2 minutes to open my window... I don't want this... As I fill my spreadsheet from code behind, I don't know how many columns I am using... It depends on the settings the user chose before the window opens...

Is there any solution for this?

1 Answer, 1 is accepted

Sort by
0
Deyan
Telerik team
answered on 15 Feb 2016, 09:42 AM
Hello Evelyn,

Thank you for contacting us.

You may use the UsedCellRange property in order to select only the columns in the used range. The following code snippet shows how to autofit the columns in the used range of some Worksheet instance:
worksheet.Columns[worksheet.UsedCellRange].AutoFitWidth();

I hope this is helpful. If you have any other questions or concerns please do not hesitate to contact us again.

Regards,
Deyan
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
SpreadProcessing
Asked by
Evelyn
Top achievements
Rank 1
Answers by
Deyan
Telerik team
Share this question
or