# Adjust Column Width and Row Height

Learn how to adjust column width or row height with DsExcel through a sample code.

## Content

DsExcel provides [BestFitColumns](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.IPageSetup.BestFitColumns.html) and [BestFitRows](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.IPageSetup.BestFitRows.html) properties in the [IPageSetup](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.IPageSetup.html) interface to properly display long or large-size font texts in cells while printing PDF documents. These properties support SSJSON I/O and are consistent with SpreadJS. The **BestFitColumns** property when set to True, resizes the column width to fit the text with the longest width for printing. Similarly, the **BestFitRows** property when set to True, resizes the row height to fit the text with the tallest height for printing.

> !type=note
> **Note:** DsExcel preserves useMax property during JSON I/O. In case a file contains large amount of data, these properties may not work as expected.

## Using Code

Refer to the following example code to adjust column width or row height.

```csharp
// Set bestFitColumns/bestFitRows as true
worksheet.PageSetup.BestFitColumns = true;
worksheet.PageSetup.BestFitRows = true;
```