File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ function Invoke-PowerShellNotebook {
88
99 Process {
1010 $codeBlocks = Get-NotebookContent $NoteBookFullName - JustCode
11+ $SheetCount = 0
1112 for ($idx = 0 ; $idx -lt $codeBlocks.Count ; $idx ++ ) {
1213 $targetCode = $codeblocks [$idx ].source
1314 if ($AsExcel ) {
@@ -21,7 +22,9 @@ function Invoke-PowerShellNotebook {
2122
2223 foreach ($dataSet in , @ ($targetCode | Invoke-Expression )) {
2324 if ($dataSet ) {
24- $uniqueName = " Sheet$ ( $idx ) "
25+ # $uniqueName = "Sheet$($idx)"
26+ $SheetCount ++
27+ $uniqueName = " Sheet$ ( $SheetCount ) "
2528 Export-Excel - InputObject $dataSet - Path $xlfile - WorksheetName $uniqueName - AutoSize - TableName $uniqueName
2629 }
2730 }
Original file line number Diff line number Diff line change @@ -63,9 +63,9 @@ Describe "Test Invoke PS Notebook" {
6363
6464 $sheets.Count | Should Be 3
6565
66- $sheets [0 ].Name | Should Be ' Sheet0 '
67- $sheets [1 ].Name | Should Be ' Sheet1 '
68- $sheets [2 ].Name | Should Be ' Sheet2 '
66+ $sheets [0 ].Name | Should Be ' Sheet1 '
67+ $sheets [1 ].Name | Should Be ' Sheet2 '
68+ $sheets [2 ].Name | Should Be ' Sheet3 '
6969
7070 Remove-Item $actual - ErrorAction SilentlyContinue
7171 }
You can’t perform that action at this time.
0 commit comments