Last post Nov 13, 2013 04:42 PM by Paul Linton
Nov 13, 2013 09:34 AM|Robert Larson|LINK
I am struggling with exporting the webgrid data to the excel file. It is actually working fine on lolcalhost, but not on my main server. I’ve tried deploying it to the main server, but still couldn’t get the job done.
I created the excel sheet using MS Office interop excel app. And, when I tried to generate excel file on the main server I got this message:
failed due to the following error: 80040154.**Class Not registered
I have tried to come up with the solution myself and have looked on various forums and blogs but it was a blank shot.
Is there, maybe, a plugin (or something similar) which I may use to overcome this?
Nov 13, 2013 09:39 AM|Robert Farmer|LINK
You must install your Excel on the Main Server directly. However, you must know that this is not such a good practice due to security issues (you’ll need to provide more privileges to your network service account so it is able to run excel on the main server).
Here is a good resource for you. Also, you might want to move over to other libraries such as Open XML.
Nov 13, 2013 10:43 AM|oned_gk|LINK
Nov 13, 2013 01:20 PM|markfitzme|LINK
The Office Suite must be installed to make use of it. This is not appropriate for use on the server and Microsoft has been recomending against it for over 15 years. The threading model is wrong to be used from a web environment and it destabilizes the server
environment. I've actually had to repaid a server that became fouled thanks to the Office suite that one of it's applications used.
You are far better off making use of third-party components that work with the office document model, are designed to be threaded and used from web applications, are written in .net and don't require interop librarys and, most importantly don't rely on the
office suite to be installed.
Nov 13, 2013 01:30 PM|PatriceSc|LINK
As pointed by other responses, you have to understand that the code behind runs server side. So it may appear to work on your dev box where the client and server are the same machine and where Office is installed.
As soon as you'll deploy this to a web server that doesn't have Office it will break (and making Office to work in this context would be really difficult as it has never been intended for this).
Always keep this in mind as when you starts it's easy to get caught in doing things that would ever work only on your own dev box (for example writing a file to disk, thinking that your web app will be able to write to the client side disk).
Depending on your needs you could try
http://www.codeproject.com/Tips/477436/Export-Gridview-Data-to-Excel-in-ASP-NET basically your options are :
- if enough use HTML as Excel is able to read HTML files
- you could use http://excelpackage.codeplex.com/ for Excel 2007 or later
- or a third party library
Nov 13, 2013 04:42 PM|Paul Linton|LINK
"Microsoft does not recommend or support server-side Automation of Office."
for more details see http://support.microsoft.com/kb/257757