Document Solutions for Excel, .NET Edition | Document Solutions
File Operations / Export to PDF / Shrink To Fit With Text Wrap
In This Topic
    Shrink To Fit With Text Wrap
    In This Topic

    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 :

    Using Code

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

    Copy Code
    // 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 = "Documents 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);