Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to copy a sheet with a different name - C# and Excel Interop

Tags:

I would like to simply copy one sheet within my workbook and give it a different name.

var pointName1 = workbook.Worksheets["PointName1"] as Worksheet;
pointName1.Copy(); // How do I access this newly created sheet?

Ideally I would like be able to write a method like this

pointName1.CopyTo("New Sheet");

where 'New Sheet' is a renamed copy of 'PointName1'.

Sometimes PointName1 will be the only sheet in the workbook, other times there will be others.