Copy Excel Worksheets
The code example above shows how to use IronXL to duplicate and copy WorkSheets
within and between Excel WorkBooks
. Copy and paste sheets to and from other workbooks. Create duplicate sheets within the same workbook.
The CopySheet
method is used to duplicate a worksheet within the same workbook or spreadsheet. The name of the new worksheet is required as a parameter.
Use the CopyTo
method to duplicate a sheet to or from another workbook. A WorkBook
is required as the first parameter and is followed by the name of the new worksheet.
You can download a file project from this link.
How to Copy Excel Worksheets in C#
- Install an Excel library to copy worksheets.
- Load an Excel workbook and create a new sheet.
- Use the
CopyTo
method to copy data to the new worksheet. - Save the new Excel worksheet.
Discover Advanced Techniques for Copying Excel Cells with C#