API Reference

Cmdlet

Move-OfficeExcelSheet

Aliases: ExcelSheetOrder, Set-OfficeExcelSheetOrder
Namespace PSWriteOffice
Aliases
ExcelSheetOrder Set-OfficeExcelSheetOrder
Inputs
OfficeIMO.Excel.ExcelDocument
Outputs
System.Object

Moves a worksheet to a new workbook position.

Remarks

Moves a worksheet to a new workbook position.

Examples

Authored help example

Move the summary sheet to the front and verify order.

PS>


$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.

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.

Syntax

Move-OfficeExcelSheet -Index <Int32> [-PassThru] [-Sheet <String>] [-SheetIndex <Nullable`1>] [<CommonParameters>]
#
Parameter set: Context

Parameters

Index Int32 requiredposition: namedpipeline: Falsealiases: TargetIndex
Zero-based destination tab index.
PassThru SwitchParameter optionalposition: namedpipeline: False
Emit the moved worksheet.
Sheet String optionalposition: namedpipeline: Falsealiases: WorksheetName
Worksheet name to move. Defaults to the current sheet inside an ExcelSheet block.
SheetIndex Nullable`1 optionalposition: namedpipeline: False
Worksheet index to move when using a workbook object or path.

Outputs

System.Object

Move-OfficeExcelSheet -Index <Int32> -InputPath <String> [-PassThru] [-Sheet <String>] [-SheetIndex <Nullable`1>] [<CommonParameters>]
#
Parameter set: Path

Parameters

Index Int32 requiredposition: namedpipeline: Falsealiases: TargetIndex
Zero-based destination tab index.
InputPath String requiredposition: 0pipeline: Falsealiases: FilePath, Path
Workbook path to update.
PassThru SwitchParameter optionalposition: namedpipeline: False
Emit the moved worksheet.
Sheet String optionalposition: namedpipeline: Falsealiases: WorksheetName
Worksheet name to move. Defaults to the current sheet inside an ExcelSheet block.
SheetIndex Nullable`1 optionalposition: namedpipeline: False
Worksheet index to move when using a workbook object or path.

Outputs

System.Object

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

Parameters

Document ExcelDocument requiredposition: namedpipeline: True (ByValue)
Workbook to update outside the DSL context.
Index Int32 requiredposition: namedpipeline: Falsealiases: TargetIndex
Zero-based destination tab index.
PassThru SwitchParameter optionalposition: namedpipeline: False
Emit the moved worksheet.
Sheet String optionalposition: namedpipeline: Falsealiases: WorksheetName
Worksheet name to move. Defaults to the current sheet inside an ExcelSheet block.
SheetIndex Nullable`1 optionalposition: namedpipeline: False
Worksheet index to move when using a workbook object or path.

Outputs

System.Object