2

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 ?

3

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.