See Also

IRange Interface  | IRange Members  | Rows Property  | Columns Property

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Language

Visual Basic

C#

C++

C++/CLI

Show All

See Also Languages SpreadsheetGear The Performance Spreadsheet Component Company 

AutoFit Method

SpreadsheetGear Namespace > IRange Interface : AutoFit Method

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

[Visual Basic]
Overridable Sub AutoFit()
[C#]
virtual void AutoFit();
[C++]
virtual void AutoFit();
[C++/CLI]
virtual void 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.

Example

[C#] 

// 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 Basic] 

' 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()

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

IRange Interface  | IRange Members  | Rows Property  | Columns Property

 

 


See our live Excel Reporting, Excel Charting, Excel to DataGrid and Excel Calculation Samples.

Copyright © 2003-2007 SpreadsheetGear LLC. All Rights Reserved.

SpreadsheetGear and Spreadsheet Gear are trademarks of SpreadsheetGear LLC.