{“Exception from HRESULT: 0x800A03EC”} at Microsoft.Office.Interop

I am trying to create an excel file using the below code in an ASP.Net web applcation. The code works normally when I run from visual studio, but an exception occur <strong>workbook.Close</strong> command when I deploy the application on IIS and run the deployed version.

Excel.Application exc = null; try { exc = new Excel.Application(); Excel.Workbooks workbooks = exc.Workbooks; Excel._Workbook workbook = workbooks.Add(Excel.XlWBATemplate.xlWBATWorksheet); Excel._Worksheet worksheet = (Excel._Worksheet)workbook.Worksheets[1]; Excel.Range range = worksheet.get_Range("A1", System.Reflection.Missing.Value); Object[] data = new Object[] { "" }; range.GetType().InvokeMember("Value", System.Reflection.BindingFlags.SetProperty, null, range, data); workbook.Close(true, p_sTempFileName, null); } catch (Exception ex) { Console.WriteLine(ex.Message + "\n" + ex.InnerException); Console.ReadLine(); } finally { if (exc != null) exc.Quit(); }


check this link: http://www.c-sharpcorner.com/UploadFile/jayendra/5443/

check the section where it says "Exception from HRESULT: 0x800A03EC"

hope it works.


In the code:

    <li>A1 should not be zero;</li> <li>A1 should be > 0;</li> <li>Range rng = (Excel.Range)worksheet.get_Range((object)worksheet.Cells[1, 1], (object)worksheet.Cells[3,3])</li> </ul>

    人吐槽 人点赞



用户名: 密码:
验证码: 匿名发表


查看评论:{“Exception from HRESULT: 0x800A03EC”} at Microsoft.Office.Interop