[]
        
(Showing Draft Content)

GrapeCity.Documents.Excel.IRange.AutoFit

AutoFit Method

AutoFit()

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

Declaration
void AutoFit()
Sub AutoFit()
Examples
IRange range = worksheet.Range["A:A"];
worksheet.Range["A1"].Value = "Long text for autofit";
range.AutoFit();
double width = range.ColumnWidth;

AutoFit(bool)

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

Declaration
void AutoFit(bool considerMergedCell)
Sub AutoFit(considerMergedCell As Boolean)
Parameters
Type Name Description
bool considerMergedCell

Indicates whether to consider merged cells in a single row.

Examples
IRange range = worksheet.Range["A:A"];
worksheet.Range["A1"].Value = "Long text for autofit";
range.AutoFit();
double width = range.ColumnWidth;