We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

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 03:29 AM

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.
Live Chat Icon For mobile
Up arrow icon