NetOffice icon indicating copy to clipboard operation
NetOffice copied to clipboard

Worksheet.Copy Method Issue

Open jamesdbrown79 opened this issue 5 years ago • 1 comments

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.

jamesdbrown79 avatar Sep 25 '20 14:09 jamesdbrown79

Hi, do you have sample project which replicates the issue?

jozefizso avatar Oct 03 '20 21:10 jozefizso