We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

AddCopy() worksheet

Hi, I am trying to copy a worksheet, and then add this copied worksheet in my workbook. For example,

Excel.Cells.Worksheet wsNew = workbook.Worksheets[workbook.Worksheets.AddCopy(“Positions”)];

Let the worksheet of which name is “Positions” has several named ranges, such as “Positions.Data”.
In this case, it seems that wsNew does not really have the same named range as the “positions”. It seems only the cell datas in the worksheet “Positions” are copied into wsNew, but not the ranges.
Is there any way that I can copy all the named ranges into a new worksheet automatically?

@SYum,

Thanks for providing us some details.

I am afraid, we need your template file to evaluate your issue on our end, please provide us your template file to check your issue on our end.

By the way, I have evaluated your scenario/case manually in MS Excel a bit. For example, I open a template file and click on a worksheet in MS Excel manually. I created a few named ranges in the sheet. Now I right-click on the sheet and select “Move or Copy…” to copy that sheet (making the “Create a copy” checkbox checked). Now, I analyzed the ranges using Name Manager, I found the the ranges in the copied sheet have become local (from global) to stay valid in the workbook. No two named ranges having same name with same scope can exist in the workbook. I would recommend you to kindly do perform your steps in MS Excel manually and evaluate if Aspose.Cells is doing something different. if you find Aspose.Cells is not doing well as opposed to MS Excel, please provide us template file and sample code (runnable) to reproduce the issue on our end, we will check it soon.

Thank you.