Worksheet.Copy Method Issue
I'm attempting to copy multiple worksheets from a source workbook to a target workbook using the below code within a foreach loop.
sourceWorksheet.Copy(null, targetWorkbook.Worksheets[targetWorkbook.Worksheets.Count]);
The code works, but the performance degrades almost exponentially for each worksheet. The first worksheet is copied instantly, the second then takes a couple of seconds, the third 4 seconds etc. When I step through the code in debug mode the above line takes longer to execute for each subsequent worksheet, but once it's finished executing my machine also then hangs for a few seconds before I can continue stepping through.
If I only attempt to copy a single worksheet then the process completes instantly without any performance issues.
Hi, do you have sample project which replicates the issue?