Resolve worksheet argumentcompleter Fixes:#1590

This commit is contained in:
Phil Bossman
2024-04-30 11:59:08 -04:00
parent c1b395fac6
commit efa73b37a0

View File

@@ -67,9 +67,8 @@ function WorksheetArgumentCompleter {
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter) param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)
$xlPath = $fakeBoundParameter['Path'] $xlPath = $fakeBoundParameter['Path']
if (Test-Path -Path $xlPath) { if (Test-Path -Path $xlPath) {
$xlpkg = Open-ExcelPackage -ReadOnly -Path $xlPath $xlSheet = Get-ExcelSheetInfo -Path $xlPath
$WorksheetNames = $xlPkg.Workbook.Worksheets.Name $WorksheetNames = $xlSheet.Name
Close-ExcelPackage -nosave -ExcelPackage $xlpkg
$WorksheetNames.where( { $_ -like "*$wordToComplete*" }) | foreach-object { $WorksheetNames.where( { $_ -like "*$wordToComplete*" }) | foreach-object {
New-Object -TypeName System.Management.Automation.CompletionResult -ArgumentList "'$_'", New-Object -TypeName System.Management.Automation.CompletionResult -ArgumentList "'$_'",
$_ , ([System.Management.Automation.CompletionResultType]::ParameterValue) , $_ $_ , ([System.Management.Automation.CompletionResultType]::ParameterValue) , $_