Skip to content

Commit e30b1fc

Browse files
committed
Added SheetCount
1 parent 4d01a2c commit e30b1fc

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

‎InvokePowerShellNotebook.ps1‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff 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
}

‎__tests__/InvokePowerShellNotebook.tests.ps1‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)