I am trying to read Excel file using PowerShell. My script works on my machine but it generates the following error when I run it on the server where MS Office is not installed. The client will not intall MS Office on the server. How can I solve this problem?
Error:
Retrieving the COM class factory for component with CLSID {00000000-0000-0000-0000-000000000000} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
Script:
$objExcel = New-Object -ComObject "Excel.Application"
I have tried to load Microsoft.Office.Interop.Excel.dll
in my script by coping it to the server. But it doesn't help.
I have tried this solution this solution, but it generates microsoft.jet.oledb.4.0 provider is not registered on the local machine
Import-CSV
from Powershell to read the data. And yes, "just" copying the DLL won't do, you need at least partial install of MS Office that includes MS Excel to make calls forNew-Object -ComObject "Excel.Application"
work. – VesperExcel.Application
without Excel being installed. (Excel is theExcel.Application
you're trying to create an instance of, and clearly you can't do so if it doesn't exist.) – Ken White