TRY NEW VERSION

Try now New API BETA

Try out the new view and capabilities of the API documentation

START

AutoFit

AutoFit(bRows, bCols)

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

Parameters:

Name Type Description
bRows bool

Specifies if the width of the columns will be autofit.

bCols bool

Specifies if the height of the rows will be autofit.

Returns:

This method doesn't return any data.

Example

Copy code
builder.CreateFile("xlsx");
var oWorksheet = Api.GetActiveSheet();
var oRange = oWorksheet.GetRange("A1");
oRange.SetValue("This is an example of the column width autofit.");
oRange.AutoFit(false, true);
builder.SaveFile("xlsx", "AutoFit.xlsx");
builder.CloseFile();

Resulting document