Move help from Comment-based to md. Relocate functions (sans help)

This commit is contained in:
jhoneill
2019-11-17 15:30:15 +00:00
parent 07b36e5e56
commit 6d97018de6
133 changed files with 41075 additions and 5241 deletions

View File

@@ -0,0 +1,24 @@
function Select-Worksheet {
param (
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ParameterSetName = 'Package', Position = 0)]
[OfficeOpenXml.ExcelPackage]$ExcelPackage,
[Parameter(Mandatory = $true, ParameterSetName = 'Workbook')]
[OfficeOpenXml.ExcelWorkbook]$ExcelWorkbook,
[Parameter(ParameterSetName='Package')]
[Parameter(ParameterSetName='Workbook')]
[string]$WorksheetName,
[Parameter(ParameterSetName='Sheet',Mandatory=$true)]
[OfficeOpenXml.ExcelWorksheet]$ExcelWorksheet
)
#if we were given a package, use its workbook
if ($ExcelPackage -and -not $ExcelWorkbook) {$ExcelWorkbook = $ExcelPackage.Workbook}
#if we now have workbook, get the worksheet; if we were given a sheet get the workbook
if ($ExcelWorkbook -and $WorksheetName) {$ExcelWorksheet = $ExcelWorkbook.Worksheets[$WorksheetName]}
elseif ($ExcelWorksheet -and -not $ExcelWorkbook) {$ExcelWorkbook = $ExcelWorksheet.Workbook ; }
#if we didn't get to a worksheet give up. If we did set all works sheets to not selected and then the one we want to selected.
if (-not $ExcelWorksheet) {Write-Warning -Message "The worksheet $WorksheetName was not found." ; return }
else {
foreach ($w in $ExcelWorkbook.Worksheets) {$w.View.TabSelected = $false}
$ExcelWorksheet.View.TabSelected = $true
}
}