File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,7 +2,8 @@ function Invoke-PowerShellNotebook {
22 param (
33 [Parameter (ValueFromPipelineByPropertyName )]
44 $NoteBookFullName ,
5- [Switch ]$AsExcel
5+ [Switch ]$AsExcel ,
6+ [Switch ]$Show
67 )
78
89 Process {
@@ -12,21 +13,30 @@ function Invoke-PowerShellNotebook {
1213 if ($AsExcel ) {
1314 if ($idx -eq 0 ) {
1415 $xlfile = $NoteBookFullName -replace " .ipynb" , " .xlsx"
16+ $xlfile = " $PSScriptRoot \$xlfile "
1517 Remove-Item $xlfile - ErrorAction SilentlyContinue
1618 }
1719
1820 $uniqueName = " Sheet$ ( $idx + 1 ) "
19- $targetCode |
20- Invoke-Expression |
21- Export-Excel - Path $xlfile - WorksheetName $uniqueName - AutoSize - TableName $uniqueName
21+ foreach ($dataSet in , @ ($targetCode | Invoke-Expression )) {
22+ Export-Excel - InputObject $dataSet - Path $xlfile - WorksheetName $uniqueName - AutoSize - TableName $uniqueName
23+ }
24+
25+ # $targetCode | Invoke-Expression |
26+ # Export-Excel -Path $xlfile -WorksheetName $uniqueName -AutoSize -TableName $uniqueName
2227 }
2328 else {
2429 , @ ($targetCode | Invoke-Expression )
2530 }
2631 }
2732
2833 if ($AsExcel ) {
29- Invoke-Item $xlfile
34+ if ($Show ) {
35+ Invoke-Item $xlfile
36+ }
37+ else {
38+ $xlfile
39+ }
3040 }
3141 }
3242}
Original file line number Diff line number Diff line change @@ -39,4 +39,8 @@ Describe "Test Invoke PS Notebook" {
3939 $actual [2 ].Count | Should Be 10
4040 }
4141
42+ # It "Should export this to an Excel file from the testPSExcel.ipynb" {
43+ # $actual = Invoke-PowerShellNotebook "$PSScriptRoot\GoodNotebooks\testPSExcel.ipynb" -AsExcel
44+ # #$actual | Should Be ""
45+ # }
4246}
You can’t perform that action at this time.
0 commit comments