13777

{“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(); }

Answer1:

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

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

hope it works.

Answer2:

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>

Recommend

  • SQL query to return data only if ALL necessary columns are present and not NULL
  • Flask-SQLAlchemy ssl-connection with AWS RDS error
  • How to reduce image size after loading from url in android?
  • MATCH() function in VBA
  • IronPython - Run an Excel Macro
  • Excel Range in C# using interop.Excel. Range both empty and not empty?
  • Azure Resource Template Deployment issues
  • Get the computer user name in a web application
  • Deploy same Javascript webapp build to different environments
  • Can I make OCaml produce stack traces on uncaught exceptions?
  • Stored Procedure with multiple IN Parameter
  • Why would a Scala Worksheet using Scala-IDE give this as an error?
  • Insert Columns between columns in excel
  • Trouble connecting to Google Cloud SQL server from deployed app
  • Microsoft Chart Controls for Microsoft .NET Framework 4.0
  • Can I use worksheet_change for a specific column only?
  • Creating UDF with VSTO in Excel
  • Add Windows Feature from C#
  • VBA Dir function not working on Excel 2010
  • Outlook to Excel hyperlink issue
  • C# Excel interop - how to test if interop object is still working and performing a task?
  • ASP.NET MVC 2 Preview 2 - display directory list rather than home/index
  • Connect .sks to skscene.h
  • Calling Worksheet functions from vba in foreign language versions of Excel
  • How do I access an unhandled exception in an MVC Error view?
  • iOS: Detect app start via notification press
  • Change Inet root folder for iis 7
  • Spring Data JPA custom method causing PropertyReferenceException
  • C# - Serializing and deserializing static member
  • Sending data from AppleScript to FileMaker records
  • SSO with signing and signature validation doesn't work
  • Deserializing XML into class C#
  • Linker errors when using intrinsic function via function pointer
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • How to include full .NET prerequisite for Wix Burn installer
  • LevelDB C iterator
  • Is it possible to post an object from jquery to bottle.py?
  • costura.fody for a dll that references another dll
  • How can i traverse a binary tree from right to left in java?
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize