HotXLS Docs

AutoFit method

Changes the width of the columns in the range or the height of the rows in the range to achieve the best fit.

Syntax

procedure AutoFit(Columns: boolean);
Columns Boolean. True to change the width of the columns; False to change the height of the rows.

Example

This example changes the width of the columns in the used range to achieve the best fit.

Workbook.Sheets[1].UsedRange.AutoFit(True);
This example is the same to the previous.

Workbook.Sheets[1].UsedRange.Columns.AutoFit;
This example changes the height of the rows in the used range to achieve the best fit.

Workbook.Sheets[1].UsedRange.AutoFit(False);
This example is the same to the previous.

Workbook.Sheets[1].UsedRange.Rows.AutoFit;