Overload | Description |
---|---|
Copy(Int32,String,Nullable<Int32>) | |
Copy(String,String,Nullable<Int32>) | |
Copy(Worksheet,String,Nullable<Int32>) |
Overload | Description |
---|---|
Copy(Int32,String,Nullable<Int32>) | |
Copy(String,String,Nullable<Int32>) | |
Copy(Worksheet,String,Nullable<Int32>) |
The optional SheetName parameter will rename the copied Worksheet with the desired name if the name is available. If this parameter is left blank, the name given to the Worksheet will be the name of the original Worksheet with a number. For example, a Worksheet named Sheet could be called [Sheet (2)].
The destination Worksheet Index will move the copied Worksheet to the designated index in the collection. If the index is null, it will go to the end of the collection.
using( var workbook = Workbook.Create( "test.xlsx" ) ) { // Get the first worksheet. A workbook contains at least 1 worksheet. var worksheet = workbook.Worksheets[ 0 ]; // Set values in cells. worksheet.Rows[ 4 ].Cells[ 5 ].Value = "data."; // Copy first worksheet and name it "The new name". // The worksheet to copy can be identified by an id, a name or an instance. var worksheetCopy = workbook.Worksheets.Copy( 0, "The new name" ); // Input new values in copied worksheet. worksheetCopy.Cells[ "A10" ].Value = "data2"; // Save workbook to disk. workbook.Save(); }
Target Platforms: Windows 11, Windows 10, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2