Skip to content

Commit 12a90cb

Browse files
committed
Add a check for the ImportExcel module, if the AsExcel is used
1 parent 95e2863 commit 12a90cb

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

InvokePowerShellNotebook.ps1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,15 @@ function Invoke-PowerShellNotebook {
1717
Write-Progress -Activity "Executing PowerShell code block - [$(Get-Date)]" -Status (-join $targetCode) -PercentComplete (($idx + 1) / $codeBlockCount * 100)
1818

1919
if ($AsExcel) {
20+
if (!(Get-Module -ListAvailable ImportExcel -ErrorAction SilentlyContinue)) {
21+
throw "This feature requires the ImportExcel PowerShell module. Use 'Install-Module -Name ImportExcel' to get it from the PS Gallery."
22+
}
23+
2024
if ($idx -eq 0) {
2125
$notebookFileName = Split-Path $NoteBookFullName -Leaf
2226
$xlFileName = $notebookFileName -replace ".ipynb", ".xlsx"
2327

24-
$xlfile = "{0}\{1}" -f $pwd.Path, $xlFileName
28+
$xlfile = " { 0 }\ { 1 }" -f $pwd.Path, $xlFileName
2529
Remove-Item $xlfile -ErrorAction SilentlyContinue
2630
}
2731

0 commit comments

Comments
 (0)