Xceed Workbooks for .NET v1.4 Documentation
Move Method
Example 


Xceed.Workbooks.NET Assembly > Xceed.Workbooks.NET Namespace > WorksheetCollection Class : Move Method
Moves a Worksheet or a WorksheetRange to a selected location in the WorksheetCollection.
Overload List
OverloadDescription
Moves a Worksheet into a WorksheetCollection using Ids to identify the Worksheet to move & its insertion point.  
Moves a Worksheet into a WorksheetCollection using an Id to identify the Worksheet to move & the name of a Worksheet to determine the insertion point.  
Moves a Worksheet into a WorksheetCollection using an Id to identify the Worksheet to move & a specific Worksheet as the insertion point.  
Moves a Worksheet into a WorksheetCollection using a string to identify the Worksheet to move & an Id to determine its insertion point.  
Moves a Worksheet into a WorksheetCollection using strings to identify the Worksheet to move & its insertion point.  
Moves a Worksheet into a WorksheetCollection using a string to identify the Worksheet to move & a specific Worksheet as the insertion point.  
Moves a specific Worksheet into a WorksheetCollection and uses an Id to determine its insertion point.  
Moves a specific Worksheet into a WorksheetCollection and uses a string to determine its insertion point.  
Moves a specific Worksheet into a WorksheetCollection and targets another Worksheet as the insertion point.  
Moves a WorksheetRange into a WorksheetCollection using an Id to determine the insertion point.  
Moves a WorksheetRange into a WorksheetCollection using the name of a Worksheet to determine the insertion point.  
Moves a WorksheetRange into a WorksheetCollection using a specific Worksheet to determine the insertion point.  
Remarks
After the insertion, the order of the Worksheets will globally stay the same but the Worksheets after the insertion point will be slightly off to make place for the inserted elements.
Example
using( var workbook = Workbook.Create( "test.xlsx" ) )

  {

    // Get the first worksheet. A workbook contains at least 1 worksheet.

    var worksheet_A = workbook.Worksheets[ 0 ];



    // Fill cells in 1st worksheet.

    worksheet_A.Cells[ "D5" ].Value = "This is the first Worksheet.";



    // Add a worksheet with default "SheetX" name.

    var worksheet_B = workbook.Worksheets.Add();



    // Fill cells in 2nd worksheet.

    worksheet_B.Cells[ "D5" ].Value = "This is the second Worksheet.";



    // Add a worksheet with name "Third Sheet".

    var worksheet_C = workbook.Worksheets.Add( "Third Sheet" );



    // Fill cells in 3rd worksheet.

    worksheet_C.Cells[ "D5" ].Value = "This is the third Worksheet.";



    // Move the third worksheet at index 0 (to be first).

    // The Move function takes worksheet ids, names or instances.

    workbook.Worksheets.Move( worksheet_C.Name, 0 );



    // Save workbook to disk.

    workbook.Save();

  }
Requirements

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

See Also

Reference

WorksheetCollection Class
WorksheetCollection Members