Excel Interop RunOnClient=No
mrQQ
Member Posts: 239
Hello,
I have a requirement to import excel file using NAS.
I have following code:
It works absolutely fine if I set RunOnClient=Yes for all the .NET variables.
However, if I set it to No, I get following error on the MESSAGE line:
The service is running on my own PC, started with my own username.
What is the problem here?
I have a requirement to import excel file using NAS.
I have following code:
XlApplicationServer := XlApplicationServer.ApplicationClass; XlHelperServer.CallOpen(XlApplicationServer,'C:\TEMP\file.xlsx'); XlApplicationServer.Visible := TRUE; XlWorkBookServer := XlApplicationServer.ActiveWorkbook; XlWorkSheetsServer := XlWorkBookServer.Worksheets; MESSAGE(FORMAT(XlWorkSheetsServer.Count));
It works absolutely fine if I set RunOnClient=Yes for all the .NET variables.
However, if I set it to No, I get following error on the MESSAGE line:
Microsoft Dynamics NAV --------------------------- A call to System.__ComObject.Count failed with this message: Object does not match target type. --------------------------- OK ---------------------------
The service is running on my own PC, started with my own username.
What is the problem here?
0
Comments
-
I believe there is no solution to this, and what you are trying to do is not possible the way you are trying to do it.
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!(Co-)author of "Implementing Microsoft Dynamics NAV 2009"
http://vjeko.com/0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 611 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 253 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions