This project is read-only.

Select-OOXMLWorkSheet -WorkSheetName not working


When using select-OOXMLWorkSheet with the worksheetname parameter I get an error:

Sample code:

[OfficeOpenXml.ExcelPackage]$excel = New-OOXMLPackage -author "Buzz Buzz" -title "100 Grand Bar"
[OfficeOpenXml.ExcelWorkbook]$book = $excel | Get-OOXMLWorkbook

$excel | Add-OOXMLWorksheet -WorkSheetName "License detail"
$sheet = $book | Select-OOXMLWorkSheet -WorkSheetNumber "License detail"


Select-OOXMLWorkSheet : Cannot process argument transformation on parameter 'WorkSheetNumber'. Cannot convert value "License detail" to type "System.Int32". Error: "Input string was
not in a correct format."
At D:\OneDrive\Desktop\Excel Objects Test Work.ps1:14 char:57
  • $sheet = $book | Select-OOXMLWorkSheet -WorkSheetNumber "License detail"
  • ~~~~~~~~~~~~~~~~
    • CategoryInfo : InvalidData: (:) [Select-OOXMLWorkSheet], ParameterBindingArgumentTransformationException
    • FullyQualifiedErrorId : ParameterArgumentTransformationError,Select-OOXMLWorkSheet


Avalon77 wrote Sep 7, 2015 at 1:02 PM

In your code you are using "WorkSheetNumber" as parameter instead of "WorkSheetName"... So you get one error, it's normal but you made me inspect this Cmdlet in detail and I found that if you use WorkSheetName it doesn't work... This error was introduced by a bad refactoring... Oops ;-)

I've just fixed this bug in the version 0.5.9. Thanks !