Copying and Moving Worksheets

Moving or Copying Sheets using Microsoft Excel

Following are the steps involved for copying and moving worksheets within or between workbooks.

  1. To move or copy sheets to another workbook, open the workbook that will receive the sheets.
  2. Switch to the workbook that contains the sheets you want to move or copy, and then select the sheets.
  3. On the Edit menu, click Move or Copy Sheet.
  4. In the To book box, click the workbook to receive the sheets.
  5. To move or copy the selected sheets to a new workbook, click new book.
  6. In the Before sheet box, click the sheet before which you want to insert the moved or copied sheets.
  7. To copy the sheets instead of moving them, select the Create a copy checkbox.

Copy Worksheets within a Workbook

Aspose.Cells provides an overloaded method, WorksheetCollection.addCopy(), that is used to add a worksheet to the collection and copy data from an existing worksheet. One version of the method takes the index of the source worksheet as a parameter. The other version takes the name of the source worksheet.

The following example shows how to copy an existing worksheet within a workbook.

Copy Worksheets between Workbooks

Aspose.Cells provides a method, Worksheet.copy(), used to copy data and formatting from a source worksheet to another worksheet within or between the workbooks. The method takes the source worksheet object as a parameter.

The following example shows how to copy a worksheet from one workbook to another workbook.

The following example shows how to copy a worksheet from one workbook to another.

Move Worksheets within Workbook

Aspose.Cells provides a method, Worksheet.moveTo(), used to move a worksheet to another location in the same spreadsheet.

The following example shows how to move a worksheet to another location within the workbook.