Syncfusion.XlsIO.Base
Example 


Syncfusion.XlsIO Namespace > IWorksheet Interface : UsedRangeIncludesFormatting Property

UsedRangeIncludesFormatting Property

Gets or sets whether used range should include cells with formatting.
Syntax
'Declaration
 
Property UsedRangeIncludesFormatting As Boolean
'Usage
 
Dim instance As IWorksheet
Dim value As Boolean
 
instance.UsedRangeIncludesFormatting = value
 
value = instance.UsedRangeIncludesFormatting
bool UsedRangeIncludesFormatting {get; set;}
Remarks
There are two different algorithms to create UsedRange object: 1) Default. This property = true. The cell is included into UsedRange, even data is empty (maybe some formatting changed, maynot be - cell was accessed and record was created). 2) This property = false. In this case XlsIO tries to remove empty rows and columns from all sides to make UsedRange smaller.
Example
The following code illustrates how to set UsedRangeIncludesFormatting property.
using Syncfusion.XlsIO;
using System;
            
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];
            
            //Set text
            worksheet["C2"].Text = "Text";
            
            //Add format
            worksheet["D3"].CellStyle.ColorIndex = ExcelKnownColors.Red;
            
            //Set used range includes formatting
            worksheet.UsedRangeIncludesFormatting = false;
            
            //Get used range
            Console.Write(worksheet.UsedRange.AddressLocal);
            
            //Save and dispose
            workbook.SaveAs("CellFormats.xlsx");
            workbook.Close();
            Console.ReadKey();
        }
    }
}
//Output will be
//C2
AssemblyVersion

Syncfusion.XlsIO.Base: 16.3460.0.29

See Also