# Auto Fit Template Cell

## Content

The auto-fit feature in ReportSheet automatically adjusts column width and row height to fit the content when generating reports. For this, you need to configure the `autoFit` property in the `setTemplateCell` method.
You can set the following enum values for auto-fit operation while working with ReportSheet:

* None
* Row
* Column

### Using Code

The following code sample shows how to set the auto-fit types for the template cell.

```javascript
// Set the autoFit property as Row.
 templateSheet.setTemplateCell(1, 0, {
     type: 'List',
     binding: Orders[orderDate],
     autoFit: 'Row',
 });

 // Set the autoFit property as Column.
 templateSheet.setTemplateCell(1, 2, {
     type: 'List',
     binding: Orders[shipName],
     autoFit: 'Column',
 });

 // Set the autoFit property as None.
 templateSheet.setTemplateCell(1, 3, {
     type: 'List',
     binding: Orders[shipAddress],
     autoFit: 'None',
 });
```

The output of the above code is as follows:

![image](https://gcdocumentsitekrblob.blob.core.windows.net/document-site-files/images/d37fbce1-6a37-43ce-b728-dd79fba68421/image.9104ee.png?width=800)

### Using Designer

You can also set the `autoFit` property of the template cell using the SpreadJS designer's **Auto Fit** option available in the **Report Cell** properties panel.

![image](https://gcdocumentsitekrblob.blob.core.windows.net/document-site-files/images/d37fbce1-6a37-43ce-b728-dd79fba68421/image.0e0928.png?width=300)

> **Note**:
>
> * ReportSheet supports a combination of row and column auto fit within the same report. This means you can apply different auto fit types to different template cells.
> * AutoFit operations will not reduce row heights or column widths when the autoFit property values are less than the dimensions set in the template.
> * In the [Preview](/spreadjs/docs/v17/) mode, if a cell's autoFit property is set as 'Row' and the cell is part of a row merge, it will expand the last row of the span. Similarly, a cell with 'Column' autofit will expand the last column of the span.