Syncfusion.XlsIO.Base
Example 


ShrinkToFit Property

True - shrink content to fit into cell.
Syntax
'Declaration
 
Property ShrinkToFit As Boolean
'Usage
 
Dim instance As IExtendedFormat
Dim value As Boolean
 
instance.ShrinkToFit = value
 
value = instance.ShrinkToFit
bool ShrinkToFit {get; set;}
Example
The following code illustrates how to set ShrinkToFit property for IStyle.
using Syncfusion.XlsIO;
            
class Program
{
    static void Main()
    {
        using (ExcelEngine excelEngine = new ExcelEngine())
        {
            //Create worksheet
            IApplication application = excelEngine.Excel;
            application.DefaultVersion = ExcelVersion.Excel2013;
            IWorkbook workbook = application.Workbooks.Create(1);
            IWorksheet worksheet = workbook.Worksheets[0];
            
            //Add text
            worksheet["C2"].Text = "This is a sample text";
            worksheet["E2"].Text = "This is a sample text";
            
            //Create style
            IStyle style = workbook.Styles.Add("CustomStyle");
            
            //Set style
            worksheet["C2"].CellStyle = style;
            
            //Set shrink to fit
            style.ShrinkToFit = true;
            
            //Get extended format
            IExtendedFormat format = worksheet["E2"].CellStyle;
            
            //Set shrink to fit
            format.ShrinkToFit = true;
            
            //Save and dispose
            workbook.SaveAs("CellFormats.xlsx");
            workbook.Close();
        }
    }
}
AssemblyVersion

Syncfusion.XlsIO.Base: 17.2460.0.34

See Also