using DocumentFormat.OpenXml.Packaging; using DocumentFormat.OpenXml.Spreadsheet; namespace ExcelManipulation { class Program { static void Main(string[] args) { // Open the Excel workbook using (SpreadsheetDocument document = SpreadsheetDocument.Open("SampleWorkbook.xlsx", true)) { // Get the sheet to be cloned WorksheetPart sourceSheetPart = document.WorkbookPart.GetPartById("Sheet1") as WorksheetPart; // Clone the sheet WorksheetPart clonedSheetPart = document.WorkbookPart.AddNewPartIn this example, we open an existing Excel workbook and retrieve the WorksheetPart of the sheet we want to clone ("Sheet1"). We create a new WorksheetPart and clone the Worksheet object from the source sheet into it. We then rename the cloned sheet and add it to the workbook under a new Sheet object, with the appropriate name and index. The CloneSheet method is a part of the Open XML SDK library, which is a free, open-source library developed by Microsoft for working with Open XML documents like Excel, Word, and PowerPoint files.(); clonedSheetPart.Worksheet = (Worksheet)sourceSheetPart.Worksheet.Clone(); // Rename the cloned sheet clonedSheetPart.Worksheet.Save(); string sheetId = document.WorkbookPart.GetIdOfPart(clonedSheetPart); uint sheetIndex = 2; // Change the index to the new sheet's index string sheetName = "Sheet1 (Copy)"; Sheet sheet = new Sheet() { Id = sheetId, SheetId = sheetIndex, Name = sheetName }; document.WorkbookPart.Workbook.Sheets.Insert(1, sheet); document.WorkbookPart.Workbook.Save(); } } } }