XlApplicationServer := XlApplicationServer.ApplicationClass; XlHelperServer.CallOpen(XlApplicationServer,'C:\TEMP\file.xlsx'); XlApplicationServer.Visible := TRUE; XlWorkBookServer := XlApplicationServer.ActiveWorkbook; XlWorkSheetsServer := XlWorkBookServer.Worksheets; MESSAGE(FORMAT(XlWorkSheetsServer.Count));
Microsoft Dynamics NAV --------------------------- A call to System.__ComObject.Count failed with this message: Object does not match target type. --------------------------- OK ---------------------------
Comments
Now, I am not 100% sure about this, but I think it absolutely has to do with support for 32-bit COM under 64-bit environment.
The problem is, the .NET Excel interoperability is not .NET at all, it's merely a .NET wrapper around COM objects that uses COM Interop inside .NET to actually communicate with Excel. Since COM (Automation) is only supported client-side, anything that you attempt to do with it on the server side may not work properly. Obviously, you've found one instance of this.
I am not quite sure if it is related to this problem, but take a look at this:
http://stackoverflow.com/questions/8263 ... -on-64-bit
Also, consider opening Excel files through ADO.NET. I have some examples here:
http://vjeko.com/blog/excel-interoperab ... n-nav-2013
Good luck!
http://vjeko.com/