Message-ID: <1955835962.7723.1711619095626.JavaMail.web05$@web05> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_7722_751039283.1711619095626" ------=_Part_7722_751039283.1711619095626 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html Worksheets.CopySheet(Worksheet, Int32, String)

Worksheets.CopySheet(Worksheet, Int32, String)

Description

=20

Copies a worksheet in the workbook to another position in the same workb= ook.

=20
C#
=20
 public void CopySheet(Worksheet sheet, int position, System.String newName=
)
=20
=20
vb.net
=20
Public Sub CopySheet(ByVal sheet As Worksheet, ByVal position As Integer, B=
yVal newName As String)
=20
=20

Paramete= rs

=20
sheet
A= =20 Worksheet object re= presenting the sheet to copy.=20
position The 0-based position at which to insert a copy of the specified workshe= et. If=20 position is less than 0, it is inserted before the first sheet= in the workbook. If=20 position is equal to or greater than=20 Worksheets.Count= , it is inserted after the last worksheet.=20
newName The name to use for the new worksheet.=20

Remarks=20

The CopySheet method is intended to allow for copying of sheets from one= position to another within a single workbook. To copy content from a works= heet in one workbook to worksheet in another workbook, use the Worksheet.CopyPast= e

=20

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

=20

Introduced in build 8.2

=20

Copysheet was extended to support copying worksheets between workbooks f= or XLSX and XLSM files.

=20

Examples=20
C#
=20
//An example of copying worksheets between workbooks
ExcelApplication xla =3D new ExcelApplication();
Workbook wbSource =3D xla.Open("sourceWorkbook");
Workbook wbDest =3D xla.Open("destWorkbook");

//Copy a worksheet from the source workbook into the destination workbook
//Insert the copy at the beginning of the workbook
Worksheet wsToCopy =3D wbSource.Worksheets[0];
wbDest.Worksheets.CopySheet(wsToCopy, 0, wsToCopy.Name);
=20
=20
vb.net
=20
'An example of copying worksheets between workbooks
Dim xla As ExcelApplication =3D new ExcelApplication()
Dim wbSource As Workbook =3D xla.Open("sourceWorkbook")
Dim wbDest As Workbook =3D xla.Open("destWorkbook")

'Copy a worksheet from the source workbook into the destination workbook
'Insert the copy at the beginning of the workbook
Dim wsToCopy As Worksheet =3D wbSource.Worksheets(0)
wbDest.Worksheets.CopySheet(wsToCopy, 0, wsToCopy.Name)
=20

------=_Part_7722_751039283.1711619095626--