mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-15 07:43:23 +00:00
Close the $Stream so the xlsx won't be locked
This commit is contained in:
@@ -98,6 +98,7 @@
|
|||||||
}
|
}
|
||||||
Write-Verbose "Copying $($SourceWorkSheet) from $($SourceWorkbook) to $($DestinationWorkSheet) in $($DestinationWorkbook)"
|
Write-Verbose "Copying $($SourceWorkSheet) from $($SourceWorkbook) to $($DestinationWorkSheet) in $($DestinationWorkbook)"
|
||||||
$null = Add-WorkSheet -ExcelWorkbook $wb -WorkSheetname $DestinationWorkSheet -CopySource $sourceWs
|
$null = Add-WorkSheet -ExcelWorkbook $wb -WorkSheetname $DestinationWorkSheet -CopySource $sourceWs
|
||||||
|
if ($Stream) {$Stream.Close() }
|
||||||
if ($package1) {Close-ExcelPackage -ExcelPackage $Package1 -NoSave }
|
if ($package1) {Close-ExcelPackage -ExcelPackage $Package1 -NoSave }
|
||||||
if ($package2) {Close-ExcelPackage -ExcelPackage $Package2 -Show:$show }
|
if ($package2) {Close-ExcelPackage -ExcelPackage $Package2 -Show:$show }
|
||||||
if ($show -and $DestinationWorkbook -is [OfficeOpenXml.ExcelWorkbook]) {
|
if ($show -and $DestinationWorkbook -is [OfficeOpenXml.ExcelWorkbook]) {
|
||||||
|
|||||||
@@ -109,6 +109,8 @@ Describe "Copy-Worksheet" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$targetSheets | ForEach-Object { Remove-WorkSheet -FullName $xlfile -WorksheetName $_ }
|
$targetSheets | ForEach-Object { Remove-WorkSheet -FullName $xlfile -WorksheetName $_ }
|
||||||
|
|
||||||
|
(Get-ExcelSheetInfo -Path $xlfile ).Count | Should Be 3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user