using IronXL;
WorkBook firstBook = WorkBook.Load("sample.xlsx");
WorkBook secondBook = WorkBook.Create();
// Select first worksheet in the workbook
WorkSheet workSheet = firstBook.DefaultWorkSheet;
// Duplicate the worksheet to the same workbook
workSheet.CopySheet("Copied Sheet");
// Duplicate the worksheet to another workbook with the specified name
workSheet.CopyTo(secondBook, "Copied Sheet");
firstBook.Save();
secondBook.SaveAs("copyExcelWorksheet.xlsx");
Imports IronXL
Private firstBook As WorkBook = WorkBook.Load("sample.xlsx")
Private secondBook As WorkBook = WorkBook.Create()
' Select first worksheet in the workbook
Private workSheet As WorkSheet = firstBook.DefaultWorkSheet
' Duplicate the worksheet to the same workbook
workSheet.CopySheet("Copied Sheet")
' Duplicate the worksheet to another workbook with the specified name
workSheet.CopyTo(secondBook, "Copied Sheet")
firstBook.Save()
secondBook.SaveAs("copyExcelWorksheet.xlsx")