Error while saving workbook: System.Runtime.InteropServices.COMException: Exception from HRESULT: 0x800A03EC

I am creating an excel file with my asp.net application. I host this site on IIS7.

When I run it from the server, it gives an error while saving the workbook.

my code

Workbook.SaveAs(Server.MapPath("Folder") + "\\" + filename + ".xls" , Excel.XlFileFormat.xlHtml, objOpt, objOpt, false, false ,Excel.XlSaveAsAccessMode.xlShared, false, false, objOpt, objOpt); 

I tried to solve this for a week. hope i find some help here.

That's my fault

 System.Runtime.InteropServices.COMException: Exception from HRESULT: 0x800A03EC 

I am using Office 2000, IIS7. I installed all permissions. Any suggestions are welcome.

+4
source share
2 answers

Interop is not supported in multi-scripting scenarios (e.g. IIS) using MS .

There are many possibilities for reading / editing / creating Excel files without Interop / installing Excel on the server:

MS provides the free OpenXML SDK V 2.0 - see http://msdn.microsoft.com/en-us/library/bb448854%28office.14%29.aspx (XLSX only)

It can read + write MS Office files (including Excel).

Another free option, see http://www.codeproject.com/KB/office/OpenXML.aspx (XLSX only)

IF you need more how to handle older versions of Excel (e.g. XLS, not only XLSX), rendering, creating PDF files, formulas, etc., then there are various free and commercial libraries such as ClosedXML (free, only XLSX), EPPlus (free, XLSX only), Aspose.Cells , SpreadsheetGear , LibXL and Flexcel , etc.

+2
source

Did you set the Read-Only property to true when you open the book?

Refer to the instructions on how to open a book with write access:

 Microsoft.Office.Interop.Excel.Application xlApp = null; Microsoft.Office.Interop.Excel.Workbook xlWorkBook = null; xlApp = new Excel.ApplicationClass(); xlWorkBook = xlApp.Workbooks.Open(txtFilePath.Text, 0, false, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0); 

A false value for the 3rd parameter of the xlApp.Workbooks.Open method means that the book will not be read-only.

This is just a wild hunch, since you have not shared any code on how you open the book. Hope this helps.

0
source

All Articles