Copy a Worksheet
Contents
[
Hide
]
Add Worksheets describes how to add new worksheets to Aspose.Cells.GridWeb. It’s also possible to add a copy (or replica) of another worksheet to the Aspose.Cells.GridWeb control. This feature can be useful when identical or similar data in one worksheet is also required in another worksheet. When that’s the case, it’s easier to copy an existing worksheet and add it to Aspose.Cells.GridWeb as a new worksheet instead of creating it from scratch.
Copying a Worksheet
Using Sheet index
The example code below shows how to add a copy of a worksheet to the GridWeb control by specifying the worksheet’s index in the GridWorksheetCollection’s AddCopy method.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// Adding the copy of a worksheet to GridWeb by specifying its sheet index | |
int sheetIndex = GridWeb1.WorkSheets.AddCopy(0); |
Using Sheet Name
The example code below shows how to add a copy of a worksheet to the GridWeb control by specifying the worksheet’s name in the GridWorksheetCollection’s AddCopy method.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// Adding the copy of a worksheet to GridWeb by specifying its sheet name | |
int sheetIndex1 = GridWeb1.WorkSheets.AddCopy("Students"); |
The AddCopy method returns the newly added worksheet’s index which can be used to access the worksheet instance. For more details on how to access worksheets, read Access Worksheets.