Developer forum

Forum » Development » "Microsoft.Office.Interop.Excel.Application" class question

"Microsoft.Office.Interop.Excel.Application" class question

Dimitrij Jazel
Reply

Hi Guys,

I am trying to create a program that creates Excel files on the fly.

More info on what I am working with is here:

http://csharp.net-informations.com/excel/csharp-create-excel.htm

 

 

Now, locally all works fine, but on staging server, I am getting an exception:

System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)). at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) at System.Activator.CreateInstance(Type type, Boolean nonPublic) at System.Activator.CreateInstance(Type type) at Samfund.CustomModules.Excel.ExcelHelper.GenerateExcel(TempOrder order) in C:\Users\Dmitrij\Source\Repos\sam\Samfund\CustomModules\Excel\ExcelHelper.cs:line 24 at CompiledRazorTemplates.Dynamic.ceeeceaabeeaea.Execute()

 

Now it is quite clear where the issue happens:

Codeline: 24 of ExcelHelper.cs class - and here it is:

Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application();

It is where I initiate Excel object class.

 

In order for this to work I had to reference a COM dll into a projecect.

Since that is local project, I just referenced it in the code, and DLL was created. But I am unsure regarding this COM dll on the productsion server.

In the project DLLs there is no Microsoft.Office DLL that I had to add, so I am not sure where to get it from...

 

If you have any Tips on this, would greatly appreicate that.

 

/Dmitrij

 


Replies

 
Nicolai Pedersen
Reply

Google knows - the com component is not installed on the server.

You probably need to install Excel on the server - be aware of license issues if you do that. It could trigger a CAL for each visitor on the site.

BR Nicolai

 
Dimitrij Jazel
Reply

I see... Thanks for this info Nicolai.

But otherwise, We need a solution, that can generate a file (or anything else) that Excel can understand.

This means that there can be .XSLX/XSL or .CSV file. in CSV file you can't have any images.

We choose Excel only because of image support.

 

If you would need to create something that Excel can open, and have possibility to insert images in it.

What would you choose then?

 

You must be logged in to post in the forum