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
Copies a worksheet in the workbook to another position in the same workb= ook.
=20public void CopySheet(Worksheet sheet, int position, System.String newName= )=20
Public Sub CopySheet(ByVal sheet As Worksheet, ByVal position As Integer, B= yVal newName As String)=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
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
=20All 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.
=20Copysheet was extended to support copying worksheets between workbooks f= or XLSX and XLSM files.
=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
'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