Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

How to: Move a Worksheet to another Location

Important

You need a license for the DevExpress Office File API Subscription or DevExpress Universal Subscription to use these examples in production code.

This example demonstrates how to move a worksheet to another location in a workbook. To do this, call the Worksheet.Move method and pass the worksheet zero-based index specifying the position in the WorksheetCollection collection into which the worksheet should be moved.

View Example

// Move the first worksheet to the position of the last worksheet within the workbook.
workbook.Worksheets[0].Move(workbook.Worksheets.Count - 1);

You can also rearrange worksheets within a workbook by using methods inherited from the Sheet interface: Sheet.MoveToBeginning, Sheet.MoveBefore, Sheet.MoveAfter, and Sheet.MoveToEnd.

workbook.Worksheets[0].MoveToEnd();

The image below shows how the worksheet moves from the first position to the last position in the workbook (the workbook is opened in Microsoft® Excel®).

Worksheet_Move