i have written code to open an excel like below:
string mRangeStartCell = @"A3";
string mRangeEndCell = @"D27";
Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbooks xlWbs = xlApp.Workbooks;
Microsoft.Office.Interop.Excel.Workbook xlWb = xlWbs.Open(ConfigurationManager.AppSettings["MasterFolderPath"] + pickupMailData.Attachment, System.Reflection.Missing.Value,
System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value,
System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value);
In local it runs without any problem, but when its deployed in server it shows following error:
Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80080005 Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)).
And in local computer i have excel 2016 version and in server excel 2010 version, And i am disposing object once all used, So can anyone can help me? Thanks in advance.
You have three choices, the first one won't require you to recode anything:
Install Microsoft Excel 2016 on the server (Please read this before doing so: https://support.microsoft.com/en-us/help/257757/considerations-for-server-side-automation-of-office).
Use the Open XML SDK
Use a 3rd party Excel library (example epplus)
I personally would choose Option 2 or 3 because it is much easier to deploy on multiple servers.
User contributions licensed under CC BY-SA 3.0