< Back

Remove-WorkSheet

Wed Jan 15, 2020 1:21 am

NAME Remove-WorkSheet



SYNOPSIS

Removes one or more worksheets from one or more workbooks





SYNTAX

Remove-WorkSheet [[-FullName] <Object>] [[-WorksheetName] <String[]>] [-Show] [-WhatIf] [-Confirm]

[<CommonParameters>]





DESCRIPTION





PARAMETERS

-FullName <Object>

The fully qualified path to the XLSX file(s)



Required? false

Position? 1

Default value None

Accept pipeline input? True (ByPropertyName)

Accept wildcard characters? false



-WorksheetName <String[]>

The worksheet to be removed (sheet1 by default)



Required? false

Position? 2

Default value Sheet1

Accept pipeline input? False

Accept wildcard characters? false



-Show [<SwitchParameter>]

If specified the file will be opened in excel after the sheet is removed.



Required? false

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? false



-WhatIf [<SwitchParameter>]

Shows what would happen if the cmdlet runs. The cmdlet is not run.



Required? false

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? false



-Confirm [<SwitchParameter>]

Prompts you for confirmation before running the cmdlet.



Required? false

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



NOTES









-------------------------- EXAMPLE 1 --------------------------



PS\\> Remove-WorkSheet -Path Test1.xlsx -WorksheetName Sheet1



Removes the worksheet named 'Sheet1' from 'Test1.xlsx'

-------------------------- EXAMPLE 2 --------------------------



PS\\> Remove-WorkSheet -Path Test1.xlsx -WorksheetName Sheet1,Target1



Removes the worksheet named 'Sheet1' and 'Target1' from 'Test1.xlsx'

-------------------------- EXAMPLE 3 --------------------------



PS\\> Remove-WorkSheet -Path Test1.xlsx -WorksheetName Sheet1,Target1 -Show



Removes the worksheets and then launches the xlsx in Excel

-------------------------- EXAMPLE 1 --------------------------



PS\\> dir c:\\reports\\*.xlsx | Remove-WorkSheet



Removes 'Sheet1' from all the xlsx files in the c:\\reports directory



RELATED LINKS