Unable to find type [OfficeOpenXml.ExcelPackage]

I am trying to create an Excel spreadsheet using the Powershell module, ImportExcel, Export-Excel.
The syntax is
Invoke-Sqlcmd -ServerInstance $PRODSqlServer -Database $PRODdatabase -Query “select EmpNo from Employees” -OutputAs DataRows | Export-Excel -Path $ExcelOut WorksheetName 1.

I am receiving the error "Unable to find type [OfficeOpenXml.ExcelPackage].
At C:\Program Files\WindowsPowerShell\Modules\ImportExcel\7.1.1\Public\Export-Excel.ps1:3 char:17

  • [OutputType([OfficeOpenXml.ExcelPackage])]
    
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (OfficeOpenXml.ExcelPackage:TypeName) , RuntimeException
    • FullyQualifiedErrorId : TypeNotFound"

I have successfully installed and imported the module.
Thanks in advance.

Can’t find the type suggests that the dll didn’t get loaded when you imported the module.
Can you do
Import-Module import excel
and look for any errors and then
get-service | export-excel

If that fails try running this
Add-type -path "$env:userProfile\Documents\WindowsPowerShell\Modules\Importexcel\epplus.dll"
(it will throw an error if the DLL isn’t there) if you type [OfficeOpen [tab] it should tab compete officeOpenXML

One other thing you could try for us. We have lots of 6.0.0 installs and no-one has reported this problem you could install with -version 6.0.0 and see if that works because that would indicate a problem packaging 6.2 for download. I’m running the 6.2 code from a folder under my user directory and that’s OK on both 5.1 and 6.2, and I think all the automated tests install for the current user (the testing account doesn’t have privileges to install for all).