Atal Shrivastava
Atal Shrivastava

Reputation: 702

Error when creating Excel file from asp.net

I am trying to create an excel file using c#. My code is working fine on windows server 2008 but I am getting error in window server 2012 R2, iis server 8.5, ms office 2007 standard. Its telling me error on line

oWB = (Excel._Workbook)(oXL.Workbooks.Add(Excel.XlWBATemplate.xlWBATWorksheet));

error: [COMException (0x800a03ec):microsoft office can not save or open more documents.

Upvotes: 0

Views: 1503

Answers (2)

Heinzi
Heinzi

Reputation: 172468

You are trying to create an Excel file

  • using COM automation
  • from an ASP.NET application.

This combination is officially unsupported by Microsoft:

Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.

Thus, if it worked so far on your Windows Server 2008, it was a mere coincidence. You have been lucky. It's not something you should do on a production system.

To create an Excel file from ASP.NET, use one of the various other solutions available:

(Personally, I have good experience with SpreadsheetLight, but any of the other solutions is fine as well.)

Upvotes: 1

msmolcic
msmolcic

Reputation: 6577

It's possible that it isn't a problem with your code since it works fine with windows server 2008. You can try this registry hack, but keep in mind that wrong registry modification can be fatal so you might want to create restore point or backup of your registry:

  1. Run > regedt32
  2. Fix the value of: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders

  3. In your User Shell Folders select Cache key and assign it to your own directory

There are also solutions I found for your problem without registry modification, visit this link or this one, it might help you. If none of these things work for you try googling "microsoft office can not save or open more documents" and check problems related to the excel itself. Once again, I assume the problem is not inside your code.

Upvotes: 0

Related Questions