Xceed Workbooks for .NET v1.4 Documentation
Remove Method (WorksheetCollection)
Example 


Xceed.Workbooks.NET Assembly > Xceed.Workbooks.NET Namespace > WorksheetCollection Class : Remove Method
Removes the Worksheet from the WorksheetCollection and offsets the index of the other Worksheets toward the deleted element.
Overload List
OverloadDescription
Removes a Worksheet from the WorksheetCollection using a string to identify the Worksheet that needs to be removed.  
Removes a Worksheet from the WorksheetCollection by identifying the specific Worksheet that needs to be removed.  
Removes a WorksheetRange from the WorksheetCollection.  
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.";



    // Remove the first worksheet.

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

    workbook.Worksheets.Remove( 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