NativeExcel for .Net Developer's Reference

IRangeRows.Autofit Method 

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

[Visual Basic]
Sub Autofit()
[C#]
void Autofit();
[C++]
void Autofit();
[JScript]
function Autofit();

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();
[Visual Basic]
 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