# SizeToFit

Use the SizeToFit method to set the column width to the size of the largest text in the column. Learn its syntax and parameters in documentation.

## Content

Sets the column width to the size of the largest text in the column.

## Syntax

[JavaScript]

```javascript
FpSpread1.SizeToFit();
```

## Parameters

***columnIndex***
Integer, column index (optional)

## Return Type

None

## Remarks

This method sets the width of each column to the maximum text width in that column. The optional columnIndex parameter allows the width to be set for a specific column. This method does not cause a postback to occur.

## Example 1

This is a sample that contains the method.

```javascript
<script type="text/javascript">
   function FitSpread()
   {
      FpSpread1.SizeToFit()
   }
</script>
```

## Example 2

This is a sample that uses the method.

```javascript
<script type="text/javascript">
   function FitSpread()
   {
      var s=document.getElementById("FpSpread1");
if(document.all)
s.SizeToFit(s.ActiveCol);
else
s.SizeToFit(s.GetActiveCol());
   }
</script>
```

## See Also

[SetColWidth](/spreadnet/docs/latest/online-asp/overview/spweb-clientscriptref/clientscript-members/clientscript-allmeths/CSSR-setColWidth)
[Scripting Members](/spreadnet/docs/latest/online-asp/overview/spweb-clientscriptref/clientscript-members)