ASP.NET Topics include: System.Web classes, Web Forms and Web Controls.

Go Back  Xtreme .NET Talk > .NET > ASP.NET > Error 'Exception from HRESULT: 0x800A03EC' when saving an excel file in C#-ASP.NET 2


Reply
 
Thread Tools Display Modes
  #1  
Old 11-26-2008, 06:07 AM
vipin_pc vipin_pc is offline
Newcomer
 
Join Date: Nov 2008
Posts: 4
vipin_pc is on a distinguished road
Unhappy Error 'Exception from HRESULT: 0x800A03EC' when saving an excel file in C#-ASP.NET 2



Hi All,

In one the intranet sites which I have developed, i'm creating an excel file from C#.Net 2005-ASP.NET 2.0

application. In my local machine which runs on Windows XP the application works perfectly, but when I try to run

the application in windows 2008 server machine it throws an exception.

'Exception from HRESULT: 0x800A03EC'

What is running in the windows 2008 server machine is the published version of my application. I have all the

required dlls and other application dependency files in the bin folder including Interop.Excel.dll and

Interop.Microsoft.Office.Core.dll.

The windows 2008 server machine has MS Office 2003 version installed. I have also configured DCOM in this machine.

Here is my code
Code:
string fileName = "", strSaveFileAs = "";//To Save the File Name of the Excel File
            ItemMaster itemInfo;       
            Excel.Application xlApp = new Excel.Application();//initialise Xl app
            Excel.Workbook xlWorkBook = xlApp.Workbooks.Add(true);
            object worksheet = xlWorkBook.ActiveSheet;// set work sheet
            object objMissing = System.Reflection.Missing.Value;                     
            if (arList.Count > 0)
            {
                ((Excel.Worksheet)xlApp.ActiveSheet).Cells[1,1] = "SINO";
                ((Excel.Worksheet)xlApp.ActiveSheet).Cells[1, 2] = "ItemGroupName";
                ((Excel.Worksheet)xlApp.ActiveSheet).Cells[1, 3] = "ItemCode";
                ((Excel.Worksheet)xlApp.ActiveSheet).Cells[1, 4] = "ItemName";
                ((Excel.Worksheet)xlApp.ActiveSheet).Cells[1, 5] = "QTY";
                ((Excel.Worksheet)xlApp.ActiveSheet).Cells[1, 6] = "Rate";             
 
                int SINo = 0;// To Show Serial No in excel.               
                for (int iRows = 1; iRows <= arList.Count; iRows++)
                {
                    itemInfo = new ItemMaster();
                    itemInfo = (ItemMaster)arList[SINo];                   
                    ((Excel.Worksheet)xlApp.ActiveSheet).Cells[iRows + 1, 1] = (SINo + 1).ToString();
                    //Here GroupId actually contains group name                   
                    ((Excel.Worksheet)xlApp.ActiveSheet).Cells[iRows + 1, 2] = itemInfo.GroupID.ToString();
                    ((Excel.Worksheet)xlApp.ActiveSheet).Cells[iRows + 1, 3] = itemInfo.ItemCode.ToString();
                    ((Excel.Worksheet)xlApp.ActiveSheet).Cells[iRows + 1, 4] = itemInfo.ItemName.ToString();
                    ((Excel.Worksheet)xlApp.ActiveSheet).Cells[iRows + 1, 5] = "";
                    ((Excel.Worksheet)xlApp.ActiveSheet).Cells[iRows + 1, 6] = itemInfo.Rate.ToString();
                    ((Excel.Worksheet)xlApp.ActiveSheet).Cells[iRows + 1, 7] = "";
                    ((Excel.Worksheet)worksheet).Columns.AutoFit()//format                 
                    xlApp.ScreenUpdating = true;
                    SINo++;
                }
                /* FileName format of xls is: QuoteNo_CustomerName_Date*/
                strSaveFileAs = txtCode.Text + "_" + ddlCustomer.SelectedItem.ToString() + "_" +  txtDate.Text;     

           
                string filePath = Server.MapPath("..//Sales//Quote/");               
                fileName = filePath + "QuoteFile" + ".xls";
                if (File.Exists(fileName))
                    File.Delete(fileName);
                  //Save file in the Location 'fileName'
                xlWorkBook.SaveAs((object)(fileName), objMissing, objMissing, objMissing, objMissing, objMissing,

Excel.XlSaveAsAccessMode.xlNoChange, objMissing, objMissing, objMissing, objMissing, objMissing);
"Exception from HRESULT: 0x800A03EC" exception is thrown when the line of code

xlWorkBook.SaveAs((object)(fileName), objMissing, objMissing, objMissing, objMissing, objMissing, Excel.XlSaveAsAccessMode.xlNoChange, objMissing, objMissing, objMissing, objMissing, objMissing); is executed.

Looking forward to hear from you soon.

Last edited by PlausiblyDamp; 11-26-2008 at 12:50 PM.
Reply With Quote
  #2  
Old 11-26-2008, 01:00 PM
PlausiblyDamp's Avatar
PlausiblyDamp PlausiblyDamp is offline
Ultimate Contributor

Preferred language:
C#, VB
 
Join Date: Sep 2002
Location: Lancashire, UK
Posts: 6,461
PlausiblyDamp is on a distinguished road
Default Re: Error 'Exception from HRESULT: 0x800A03EC' when saving an excel file in C#-ASP.NE

Is the version of Excel the same on both the server and your PC? Does the application have permissions to write to the folder on the server?

One other thing to check is if it works using an absolute path rather than with the ..// bit in, IIS 7 disbales parent paths by default (which is a good thing really) - you could always re-enable it with
Code:
appcmd set config -section:asp -enableParentPaths:true
however this is introducing a potential security risk.
__________________
Posting Guidelines FAQ Post Formatting

Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein
Reply With Quote
  #3  
Old 11-26-2008, 05:29 PM
vipin_pc vipin_pc is offline
Newcomer
 
Join Date: Nov 2008
Posts: 4
vipin_pc is on a distinguished road
Default Re: Error 'Exception from HRESULT: 0x800A03EC' when saving an excel file in C#-ASP.NE

To your questions
1. Is the version of Excel the same on both the server and your PC?

Yes both are having MS Office 2003

2. Does the application have permissions to write to the folder on the server?

Could you please explain this question little more?

In case i want to enable "..//", where should i execute this code "appcmd set config -section:asp -enableParentPaths:true"
Reply With Quote
  #4  
Old 11-27-2008, 02:54 AM
vipin_pc vipin_pc is offline
Newcomer
 
Join Date: Nov 2008
Posts: 4
vipin_pc is on a distinguished road
Default Re: Error 'Exception from HRESULT: 0x800A03EC' when saving an excel file in C#-ASP.NE

The exact error i'm getting is
System.Runtime.InteropServices.COMException: Exception from HRESULT: 0x800A03EC
Reply With Quote
  #5  
Old 11-27-2008, 06:28 AM
PlausiblyDamp's Avatar
PlausiblyDamp PlausiblyDamp is offline
Ultimate Contributor

Preferred language:
C#, VB
 
Join Date: Sep 2002
Location: Lancashire, UK
Posts: 6,461
PlausiblyDamp is on a distinguished road
Default Re: Error 'Exception from HRESULT: 0x800A03EC' when saving an excel file in C#-ASP.NE

Regarding the permissions you will need to check on the IIS manager tool what application pool the website is running under and then the user account the application pool uses - this user will then need the ability to read and write to the folder containing your application.

To run the command thing just open a command prompt as administrator and cd to to the &#37;systemroot%/System32 folder and then just type it in.
__________________
Posting Guidelines FAQ Post Formatting

Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein
Reply With Quote
  #6  
Old 11-27-2008, 12:06 PM
vipin_pc vipin_pc is offline
Newcomer
 
Join Date: Nov 2008
Posts: 4
vipin_pc is on a distinguished road
Default Re: Error 'Exception from HRESULT: 0x800A03EC' when saving an excel file in C#-ASP.NE

I checked the user accounts and also permissions. Its NETWORK SERVICES and I have given full permission. I'm attaching an image(screen shot) with this. I have also added IUSRS, INTERACTIVE and SYSTEM accounts

These accounts also have DCOM "Access Permissions" and "Launch and Activation Permissions"

I'm sorry that in my thread i have not mentioned that the Windows 2008 Server is trial version.
Attached Images
File Type: jpg Permissions.jpg (137.3 KB, 67 views)
Reply With Quote
  #7  
Old 12-18-2008, 01:21 AM
oct8sreehari oct8sreehari is offline
Newcomer
 
Join Date: Dec 2008
Posts: 1
oct8sreehari is on a distinguished road
Default Re: Error 'Exception from HRESULT: 0x800A03EC' when saving an excel file in C#-ASP.NE

Can any body tell me how did you resolve the issue as i am facing the same eroor in my application it will be helpful if you give me step up step resolution to fix it. It will be very helpfull to me
Reply With Quote
  #8  
Old 01-08-2009, 07:56 AM
anandbpatil anandbpatil is offline
Newcomer
 
Join Date: Jan 2009
Posts: 2
anandbpatil is on a distinguished road
Default Re: Error 'Exception from HRESULT: 0x800A03EC' when saving an excel file in C#-ASP.NE

Hi, I am getting the exception on save as. The file is not getting saved in the specified location can any1 please help...
Reply With Quote
  #9  
Old 01-08-2009, 08:32 AM
JohnsHandle JohnsHandle is offline
Newcomer
 
Join Date: Dec 2008
Posts: 15
JohnsHandle is on a distinguished road
Default Re: Error 'Exception from HRESULT: 0x800A03EC' when saving an excel file in C#-ASP.NE

Quote:
Originally Posted by PlausiblyDamp View Post
Does the application have permissions to write to the folder on the server?
I think that maybe the problem. Writing files to the server is not something that is normally allowed.

On your local machine are you using "http://localhost"? because this behaves differently to remote access and has more trust.
Which would explain why it works locally. If you are, try accessing it remotely on your XP machine and see if this will reproduce the error.

Last edited by JohnsHandle; 01-08-2009 at 08:37 AM. Reason: becuase I'm sure it was wrong and irrelevant
Reply With Quote
  #10  
Old 04-14-2009, 04:45 PM
djr djr is offline
Newcomer
 
Join Date: Apr 2009
Posts: 1
djr is on a distinguished road
Default Re: Error 'Exception from HRESULT: 0x800A03EC' when saving an excel file in C#-ASP.NE

I am having exactly the same problem (Server 2008, Office Excel 2003, ASP.NET C#). Did you find a solution to this please. Thanks.
Reply With Quote
  #11  
Old 07-24-2009, 08:11 AM
olehansen olehansen is offline
Newcomer
 
Join Date: Jul 2009
Posts: 2
olehansen is on a distinguished road
Default Re: Error 'Exception from HRESULT: 0x800A03EC' when saving an excel file in C#-ASP.NE

Reply With Quote
  #12  
Old 10-19-2010, 09:47 PM
Priyavelan Priyavelan is offline
Newcomer
 
Join Date: Oct 2010
Location: S'Pore
Posts: 1
Priyavelan is on a distinguished road
Default Re: Error 'Exception from HRESULT: 0x800A03EC' when saving an excel file in C#-ASP.NE

Hi,

I tried the fix given in the above link also. Even I get the same error "Exception from HRESULT: 0x800A03EC" on executing the line ObjExcel.ThisWorkbook.Save();.

If anyone know the solution, pls help me out to solve.

Thanks
Priya
Reply With Quote
  #13  
Old 05-20-2011, 09:39 AM
doodlebug5000 doodlebug5000 is offline
Newcomer
 
Join Date: May 2011
Posts: 1
doodlebug5000 is on a distinguished road
Default Re: Error 'Exception from HRESULT: 0x800A03EC' when saving an excel file in C#-ASP.NE

I get the same error trying to write to XLS files from a different language/program.

The problem could be a simple one -
XLS files only support 256 columns of data, even though they support 60k+ rows.
ref: http://office.microsoft.com/en-us/ex...005199291.aspx

I fixed it two ways: change my data matrix such that it had fewer than 256 columns of data,
or
write to XLSX file. The new XLSX file format supports many more columns of data.

maybe this helps. maybe not.
Reply With Quote
  #14  
Old 11-07-2012, 09:43 AM
PatrickMoe PatrickMoe is offline
Newcomer
 
Join Date: Nov 2012
Posts: 1
PatrickMoe is on a distinguished road
Default Re: Error 'Exception from HRESULT: 0x800A03EC' when saving an excel file in C#-ASP.NE

I was getting the same exact error and none of the solutions here were relevant to my problem.

After poking around for a while, I found that the partition I was trying to write to was maxed out. I moved a bunch of un-needed files to an archive to clear up some room and the problem was resolved.
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
saving excel file from VB.Net shankar Interoperation / Office Integration 2 09-29-2004 12:47 PM
ERROR: Exception from HRESULT: 0x80047E2C joe_pool_is General 2 07-14-2004 05:58 PM
Anyone knows this error? Exception from HRESULT: 0X800A0062? Chrisaldi General 1 06-17-2004 12:33 AM
Excel from vb and an hresult exception wildfire1982 Interoperation / Office Integration 8 04-19-2004 11:50 AM
MS Excel: Set the ActivePrinter Error (HRESULT: 0x800A03EC) grazzman Interoperation / Office Integration 4 12-01-2003 06:51 PM

Advertisement:







Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe