Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Excerpt

Copies a worksheet in the workbook to another position in the same workbook.

Signature
C#
C#
 public void CopySheet(Worksheet sheet, int position, System.String newName)

...

Param
position
position

The 0-based position at which to insert a copy of the specified worksheet. If position is less than 0, it is inserted before the first sheet in the workbook. If position is equal to or greater than Worksheets.Count, it is inserted after the last worksheet.

Param
newName
newName

the new The name to use for this the new worksheet.

Remarks

This method is intended to allow for copying of sheets from one position to another within a single workbook. To copy content from a worksheet in one workbook to worksheet in another workbook, use the Worksheet.CopyPaste

All of the settings, configuration, and values on the original worksheet will be both preserved on the original worksheet and copied to the new worksheet. If there are any formulas in the worksheet that is copied that reference that worksheet, they will be updated to reference the new worksheet instead. Formulas on the original worksheet and on other worksheets will not be affected.

Example
Code Block
csharp
csharp
titleC#
sheets.CopySheet(ws1, 0, "Sheet2");
Code Block
vb.net
vb.net
titlevb.net
sheets.CopySheet(ws1, 0, "Sheet2")