1

I have an ASP.NET web application to export an Excel file with multiple sheets. Each sheet contains multiple tables on it created using Microsoft.Excel.Interop.Services package. The export functionality works while the web application is hosted on my machine without any issue/error.

After hosting it in on the server machine via IIS, and accessing this web application through a client machine (via the application URL), while exporting the file, I get COM & interop related exceptions as seen in the screenshot.

To resolve this I used some changes in DCOM settings like : Component services > Computers > My Computer > Dcom Config > Right click on Microsoft Excel Application >Properties > Navigate to Identity and change the selection from 'The launching user' to 'Interactive user'. So after changing this setting I have tried again to export a file and this works fine without providing me the COM and interop exceptions. However, this only works if a user is logged into the server on which the web application is hosted on. If no user is logged into the server, I get the exceptions again as shown in below image.

Screenshot #1 is my Excel format, screenshot #2 is the COM and interop exception I'm getting, screenshot #3 is DCOM config settings:

Image 1 in pic is my excel format , Image 2 is the com and interop exception im getting , Image 3 is DCOM COnfig setting

3
  • For a server, you can't use interactive user of course, and launching is usually uncertain. The easier it to use a predefined user with sufficient rights to do what's needed to do (possibly create one if needed). Commented Jul 23 at 12:13
  • And as a FYI? You would in theory need a full copy (and licensed) of Excel to be installed on the web server. This can be a real challenge, and a simple reference to the office .net "interop" or so called office PIO assemblies is NOT enough! -- You need both the inter-op references AND ALSO the full copy of Excel to have been installed. Worse yet, upon launching Excel, you may have prompts to "activate" the copy of Excel etc. So, it's a rather jinkey road. As suggested here, using openXML or a few other choices to generate the Excel file is the way to go. If if you get this working it's flakey Commented Jul 23 at 18:28
  • This question is similar to: How do you use Excel server-side?. If you believe it’s different, please edit the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem. Commented Jul 23 at 18:58

1 Answer 1

0

You're facing Excel Interop limitations. Excel needs a logged-in user session. Use OpenXML or a server-safe export library instead.

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

1 Comment

There is a Microsoft article with more details, support.microsoft.com/en-us/topic/…

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.