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();
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.
[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()
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
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.