Copy Excel Worksheets
WorkBook
s.Copy and paste sheets to and from other workbooks or to new locations within your workbook. Create duplicate sheets within your workbook.
You can download a file project from this link.
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")
Install-Package IronXL.Excel
WorkBook
s.Copy and paste sheets to and from other workbooks or to new locations within your workbook. Create duplicate sheets within your workbook.
You can download a file project from this link.