NativeExcel for .Net Developer's Reference

IRangeRows.AutofitMethod

Changes the height of the rows in the specified range to achieve the best fit.

[Visual Basic]
SubAutofit()
[C#]
voidAutofit();
[C++]
voidAutofit();
[JScript]
functionAutofit();

Remarks

Use IRange.Autofit method to change the width of the columns in order to achieve the best fit.

Example

This example changes the height of the rows in the used range to achieve the best fit.

[C#]
 book.Worksheets[1].UsedRange.Rows.Autofit();
[VisualBasic]
 book.Worksheets(1).UsedRange.Rows.Autofit()
[C++]
 book->Worksheets->Item[1]->UsedRange->Rows->Autofit();

See Also

IRangeRows Interface | NativeExcel Namespace | IRange.Autofit Method | UsedRange Property