# Shrink To Fit With Text Wrap

DsExcel allows you to implement the shrink to fit feature in a cell along with the wrapped text.

## Content

DsExcel .NET enables users to implement the shrink to fit feature in a cell along with the wrapped text. The Shrink to Fit feature automatically reduces the font size of the text so that it fits inside the cells of the spreadsheet without wrapping.

## Advantage of Using Shrink To Fit Feature

The Shrink to Fit feature implemented with wrapped text is useful especially when you need to deal with spreadsheets possessing tightly constrained layouts with vertical spaces and wrapped text. Also, this feature can be used when users don't want to opt for Auto fit row height and column width option to adjust the column width and row height as per their preferred worksheet layout.
The following points should be kept in mind while working with the shrink to fit feature :

* If you're exporting your Excel files to a pdf file or stream, the [PdfSaveOptions](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.PdfSaveOptions.html) class can be used to configure the save settings.
* In order to get or set the settings about enabling the shrink to fit feature on the wrapped text, you can use the the [ShrinkToFitSettings](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.PdfSaveOptions.ShrinkToFitSettings.html) property of the **PdfSaveOptions** class.
* The [CanShrinkToFitWrappedText](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.IShrinkToFitSettings.CanShrinkToFitWrappedText.html) property of the [IShrinkToFitSettings](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.IShrinkToFitSettings.html) interface can be used to get or set whether to apply shrink to fit feature on the wrapped text. If the value is true, the font size of the wrapped text may be reduced so that the wrapped text can be fully displayed.
* The [MinimumFont](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.IShrinkToFitSettings.MinimumFont.html) property of the **IShrinkToFitSettings** interface can be used to get or set the minimum font size while enabling the shrink to fit feature.
* The [Ellipsis](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.IShrinkToFitSettings.Ellipsis.html) property of the **IShrinkToFitSettings** interface can be used to get or set the omitted string if the wrapped text is not fully displayed. This can be used with the **MinimumFont** property.

## Using Code

Refer to the following example code to allow users to use the shrink to fit feature with text wrap.

```csharp
// Initialize workbook
Workbook workbook = new Workbook();
        
// Fetch default worksheet 
IWorksheet worksheet = workbook.Worksheets[0];

// Configure page settings
worksheet.PageSetup.PrintGridlines = true;
worksheet.Range["A1"].RowHeightInPixel = 10;
worksheet.Range["A1"].ColumnWidthInPixel = 70;
worksheet.Range["A1"].WrapText = true;
worksheet.Range["A1"].ShrinkToFit = true;
worksheet.Range["A1"].Value = "Document Solutions for Excel";

// Setting PdfSaveOptions
PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
pdfSaveOptions.ShrinkToFitSettings.CanShrinkToFitWrappedText = true;
pdfSaveOptions.ShrinkToFitSettings.MinimumFont = 12;
pdfSaveOptions.ShrinkToFitSettings.Ellipsis = "~";

// Saving the workbook to PDF
workbook.Save("ShrinkToFitWrappedText.pdf", pdfSaveOptions);
```