Syncfusion.XlsIO.Base
Example 


Syncfusion.XlsIO Namespace > IRange Interface > CopyTo Method : CopyTo(IRange,ExcelCopyRangeOptions,Boolean) Method
Represents the destination Range to copy.
Represents the copy Range options.
Skip blank cells while copying the range from source to destination.

CopyTo(IRange,ExcelCopyRangeOptions,Boolean) Method

Copies the Range to the specified destination Range with copy options and skip blanks option.
Syntax
'Declaration
 
Overloads Function CopyTo( _
   ByVal destination As IRange, _
   ByVal options As ExcelCopyRangeOptions, _
   ByVal skipBlanks As Boolean _
) As IRange
'Usage
 
Dim instance As IRange
Dim destination As IRange
Dim options As ExcelCopyRangeOptions
Dim skipBlanks As Boolean
Dim value As IRange
 
value = instance.CopyTo(destination, options, skipBlanks)

Parameters

destination
Represents the destination Range to copy.
options
Represents the copy Range options.
skipBlanks
Skip blank cells while copying the range from source to destination.

Return Value

Returns the copied Range.
Remarks
This method can be used to prevent copying blank cells in the destination range. If "true", then blank cells are not copied from source range.
Example
The following code illustrates how to copy the Range with skip blanks option.
class Example
{
    static void Main()
    {
        using(ExcelEngine engine = new ExcelEngine())
        {
            //Create worksheet
            IApplication application = excelEngine.Excel;
            application.DefaultVersion = ExcelVersion.Excel2013;
            IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
            IWorksheet worksheet = workbook.Worksheets[0];
            
            //Load Data
            worksheet["A1"].Value = "A";
            worksheet["A3"].Value = "B";
            worksheet["A5"].Value = "C";
            worksheet["A7"].Value = "D";
            worksheet["B1"].Value = "E";
            worksheet["B2"].Value = "F";
            worksheet["B4"].Value = "G";
            worksheet["B6"].Value = "H";
            
            //Apply styles
            worksheet["A1:A7"].CellStyle.ColorIndex = ExcelKnownColors.Yellow;
            
            //Skip blanks while copying
            worksheet["A1:A7"].CopyTo(worksheet["B1"], ExcelCopyRangeOptions.All, true);
            
            workbook.SaveAs("SkipBlanks.xlsx");
            workbook.Close();
        }
    }
}
AssemblyVersion

Syncfusion.XlsIO.Base: 16.4460.0.40

See Also