mirror of
https://github.com/dfinke/ImportExcel.git
synced 2026-01-06 10:33:19 +00:00
directory renames
This commit is contained in:
28
Public/Remove-Worksheet.ps1
Normal file
28
Public/Remove-Worksheet.ps1
Normal file
@@ -0,0 +1,28 @@
|
||||
function Remove-Worksheet {
|
||||
[CmdletBinding(SupportsShouldProcess=$true)]
|
||||
param(
|
||||
# [Parameter(ValueFromPipelineByPropertyName)]
|
||||
[Parameter(ValueFromPipelineByPropertyName)]
|
||||
[Alias('Path')]
|
||||
$FullName,
|
||||
[String[]]$WorksheetName = "Sheet1",
|
||||
[Switch]$Show
|
||||
)
|
||||
|
||||
Process {
|
||||
if (!$FullName) {
|
||||
throw "Remove-Worksheet requires the and Excel file"
|
||||
}
|
||||
|
||||
$pkg = Open-ExcelPackage -Path $FullName
|
||||
|
||||
if ($pkg) {
|
||||
foreach ($wsn in $WorksheetName) {
|
||||
if ($PSCmdlet.ShouldProcess($FullName,"Remove Sheet $wsn")) {
|
||||
$pkg.Workbook.Worksheets.Delete($wsn)
|
||||
}
|
||||
}
|
||||
Close-ExcelPackage -ExcelPackage $pkg -Show:$Show
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user