Copy rows from 1 sheet to another

I'm trying to merge several Excel files into 1 cleanup file.

I have this code:

        private void ProcessWorksheet(IWorksheet worksheet)
        {
            worksheet.UsedRangeIncludesFormatting = false;
            var range = worksheet.UsedRange;
            var migrantRange = worksheet.MigrantRange;
            var regex = new Regex(@"\d{8,9}");
            for (var i = 0; i < range.LastRow; i++)
            {
                migrantRange.ResetRowColumn(i, 1);
                if (migrantRange.HasNumber && regex.Match(migrantRange.Number.ToString(CultureInfo.InvariantCulture)).Success)
                {
                    // Correct row
                    Debug.WriteLine(migrantRange.Number);
                    --> How to copy complete row to new sheet called _workSheetResult
                }
            }
        }

I know when I have the row I need to copy, but how do I copy a whole row or range?
Do I need to do it cell by cell?

1 Reply

SA Sivaneswaran Amsu Syncfusion Team May 15, 2019 11:29 AM UTC

Hi Paul, 

Thank you for contacting Syncfusion support. 

We have shared the sample for copy from range one worksheet to another worksheet which can be downloaded from the following link. 


To know more about the copy option please refer the following UG documentation link. 



Please let us know if this helpful for your requirement. 


Regards, 
Sivaneswaran . A

Loader.
Up arrow icon