[]
Copies the sheet to the location before the specified sheet.
The copied sheet is inserted immediately before targetSheet. The target sheet can belong to the current workbook or another workbook.
IWorksheet CopyBefore(IWorksheet targetSheet)
Function CopyBefore(targetSheet As IWorksheet) As IWorksheet
| Type | Name | Description |
|---|---|---|
| IWorksheet | targetSheet | The sheet before which the copied sheet will be placed. It can be a sheet in the same workbook or another workbook. |
| Type | Description |
|---|---|
| IWorksheet | The new copied sheet. |
worksheet.Name = "Data";
worksheet.Range["A1"].Value = "Name";
IWorksheet summarySheet = workbook.Worksheets.Add();
summarySheet.Name = "Summary";
IWorksheet copiedSheet = worksheet.CopyBefore(summarySheet);
copiedSheet.Name = "Data Copy";