SpreadsheetGear
AutoFit Method
See Also  Example Send Feedback
SpreadsheetGear Namespace > IRange Interface : AutoFit Method

Automatically sets the width of the specified columns or the height of the specified rows.

Syntax

Visual Basic (Declaration) 
Sub AutoFit() 
C# 
void AutoFit()

Example

C#Copy Code
// Automatically set the width on columns B and C.
worksheet.Cells["B:C"].Columns.AutoFit();

// Set the row height to automatic on rows 7 through 9.
worksheet.Cells["7:9"].Rows.AutoFit();
    
Visual BasicCopy Code
' Automatically set the width on columns B and C.
worksheet.Cells("B:C").Columns.AutoFit()

' Set the row height to automatic on rows 7 through 9.
worksheet.Cells("7:9").Rows.AutoFit()

Remarks

Whan IRange.AutoFit is used on columns, the width of the columns is set to the appropriate width immediately. However, for rows, the height is set to the default height and a flag is set indicating that the row height is automatic, and Excel will actually set the height when the row is displayed.

Requirements

Platforms: Windows 2000, Windows XP, Windows Vista, Windows Server 2003 and Windows Server 2008. SpreadsheetGear 2008 requires the Microsoft .NET Framework 2.0 and supports .NET 3.0 and .NET 3.5.

See Also

Copyright © 2003-2009 SpreadsheetGear LLC. All Rights Reserved.Help Powered by Innovasys   
SpreadsheetGear is a registered trademark of SpreadsheetGear LLC.
Microsoft, Microsoft Excel and Visual Studio are trademarks or registered trademarks of Microsoft Corporation.