Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

Move-OfficeExcelSheet

Aliases: ExcelSheetOrder, Set-OfficeExcelSheetOrder
Module PSWriteOffice
Aliases
ExcelSheetOrder Set-OfficeExcelSheetOrder
Inputs
OfficeIMO.Excel.ExcelDocument

Moves a worksheet to a new workbook position.

Syntax

Move-OfficeExcelSheet -Index <Int32> [-PassThru] [-Sheet <String>] [-SheetIndex <Int32>] [<CommonParameters>]
#
Parameter set: Context
Move-OfficeExcelSheet -Index <Int32> [-PassThru] [-Path] <String> [-Sheet <String>] [-SheetIndex <Int32>] [<CommonParameters>]
#
Parameter set: Path
Move-OfficeExcelSheet -Document <ExcelDocument> -Index <Int32> [-PassThru] [-Sheet <String>] [-SheetIndex <Int32>] [<CommonParameters>]
#
Parameter set: Document

Examples

Authored help example

Move the summary sheet to the front and verify order.

$proof = @(
    Move-OfficeExcelSheet -Path .\Report.xlsx -Sheet Summary -Index 0
    Get-OfficeExcelSummary -Path .\Report.xlsx -IncludeSheets |
        Select-Object -ExpandProperty Sheets |
        Select-Object -First 3 -Property Index, Name
)
$proof

Moves Summary to the first worksheet tab and reads back the first sheets from workbook summary.

Parameters

-Index Int32 requiredaliases: TargetIndex
Zero-based destination tab index.
-PassThru SwitchParameter optional
Emit the moved worksheet.
-Sheet String optionalaliases: WorksheetName
Worksheet name to move. Defaults to the current sheet inside an ExcelSheet block.
-SheetIndex Int32 optional
Worksheet index to move when using a workbook object or path.
-Path String requiredposition: 0aliases: FilePath, InputPathsets: Path
Workbook path to update.
-Document ExcelDocument requiredpipeline: True (ByValue)sets: Document
Workbook to update outside the DSL context.

Common Parameters

This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.

For more information, see about_CommonParameters.