vipin_pc Posted November 26, 2008 Posted November 26, 2008 (edited) 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 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. Edited November 26, 2008 by PlausiblyDamp Quote
Administrators PlausiblyDamp Posted November 26, 2008 Administrators Posted November 26, 2008 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 appcmd set config -section:asp -enableParentPaths:true however this is introducing a potential security risk. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
vipin_pc Posted November 26, 2008 Author Posted November 26, 2008 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" Quote
vipin_pc Posted November 27, 2008 Author Posted November 27, 2008 The exact error i'm getting is System.Runtime.InteropServices.COMException: Exception from HRESULT: 0x800A03EC Quote
Administrators PlausiblyDamp Posted November 27, 2008 Administrators Posted November 27, 2008 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 %systemroot%/System32 folder and then just type it in. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
vipin_pc Posted November 27, 2008 Author Posted November 27, 2008 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. Quote
oct8sreehari Posted December 18, 2008 Posted December 18, 2008 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 Quote
anandbpatil Posted January 8, 2009 Posted January 8, 2009 Hi, I am getting the exception on save as. The file is not getting saved in the specified location can any1 please help... Quote
JohnsHandle Posted January 8, 2009 Posted January 8, 2009 (edited) 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. Edited January 8, 2009 by JohnsHandle Quote
djr Posted April 14, 2009 Posted April 14, 2009 I am having exactly the same problem (Server 2008, Office Excel 2003, ASP.NET C#). Did you find a solution to this please. Thanks. Quote
olehansen Posted July 24, 2009 Posted July 24, 2009 Tried this: http://www.made4dotnet.com/Default.aspx?tabid=141&aid=15 Quote
Priyavelan Posted October 20, 2010 Posted October 20, 2010 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 Quote
doodlebug5000 Posted May 20, 2011 Posted May 20, 2011 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/excel-help/excel-specifications-and-limits-HP005199291.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. Quote
PatrickMoe Posted November 7, 2012 Posted November 7, 2012 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. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.