I would like to parse the following Excel file which perfectly open in the application.
I browsed the Internet and lots of guys said that those two command lines do open Excel files (example Read Excel sheet in Powershell).
$excel = New-Object -com excel.application
$wb = $excel.workbooks.open("c:\users\administrator\my_test.xls")
But I have got the following exception:
Exception calling "Open" with "1" argument(s): "Old format or invalid type library. (Exception from HRESULT: 0x80028018 (TYPE_E_INVDATAREAD))"
How to outputs the value of each cell read-only, if possible keeping the rows ?
As mentioned by commenters, the error you're seeing is due to your system having different regional settings to those of the document you want to edit. To get around the problem, you can change your system locale to that of the excel document in question. If, for instance, your document is of locale 'nl-BE' (assumption based on your username), you can do the following:
& {
[threading.thread]::CurrentThread.CurrentCulture = 'nl-BE'
$excel = New-Object -com excel.application
$wb = $excel.workbooks.open("c:\users\administrator\my_test.xls")
}
Hope this helps.
User contributions licensed under CC BY-SA 3.0