Excel support?

Discussion in 'ASP.NET / ASP.NET Core' started by JRusty15, Feb 5, 2010.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. I am using Microsoft.Office.Interop.Excel assembly in my asp.net 3.5 application. The code runs fine when debugging on my local machine. When I uploaded the site I also uploaded Microsoft.Office.Interop.Excel.dll and Office.dll to the bin folder. I don't get any errors, but it doesn't seem that the code runs. I don't get any error messages, but nothing happens. The code should open Excel and create a spreadsheet and fill it with data. Can anyone help please?
     
  2. Has anyone else used the Excel piece for their asp.net application?
     
  3. Bruce

    Bruce DiscountASP.NET Staff

    You cannot use Excel InterOp on our server because it requires Office to be installed on the server.

    It is illegal for us to install Office on server machines and MSFT doesn't support Office automation on server platform.

    "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."

    See http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757#kb2
     
  4. Great. It would have been nice if customer support had mentioned that when I emailed them. They just told me to make sure I include the dll in the bin file.
     
  5. Is there any way to have the web application run Excel on the client side instead of on the server?
     
  6. You could use JavaScript to launch excel on the client. This is valid for IE:
    Code:
    <script type="text/javascript">
    	var excApp = new ActiveXObject("Excel.Application");
    	excApp.visible = true;
    	var excBook = excApp.Workbooks.open("c:\\somelocalfile.xls");
    </script>
    
    IE8 chucks a warning to the user when doing this.
     
  7. I'm not sure if for some reason you are glued into using Excel in your application; here's something that might be better than trying to integrate a desktop app with a web app: http://code.google.com/apis/spreadsheets/data/3.0/developers_guide.html

    There is a .NET client library for interacting and coding Google Apps and Google spreadsheets does support the Excel file format too ;)

    This would probably be my first choice for this type of application at the moment.
     
  8. mjp

    mjp

    Oh my, that's sweet!
     
  9. Thanks! Can the file be manipulated by the web application at this point?

    This looks good as well, so long as the user would be able to print out the resulting spreadsheet. Can that be done?
     
  10. The JS code is simply opening the excel workbook file that already exists on the users computer and it obviously doesn't work if either Excel is not installed on the users computer or the excel file does not exist. I don't know how your web application needs to work so there are a number of limitations that you might need to work through here. e.g. things that might need consideration:
    • You might need to somehow detect if Excel is installed on the client computer.
    • You might need the web application to provide the spreadsheet to the user before they can begin editing.
    • Is this really the best solution to the problem because launching Excel in this way from client script in the browser is really only going to be supported in IE (and maybe Firefox with some 3rd party ActiveX plugin installed).
    Maybe you misunderstood the sample code; the web application is no longer involved by this point because the Javascript is running on the client computer and the user takes over with Excel for any spreadsheet manipulation.
    Printing to PDF and HTML is supported; see this http://docs.google.com/support/bin/answer.py?hl=en-uk&answer=40617 for further information. If you think this is the way to go, it's really easy to sign up for a free Google Account and also add Google Apps to your Google account for free for dev and test purposes.
     
  11. Bruce

    Bruce DiscountASP.NET Staff

  12. Thanks guys, my boss decided it was acceptable to remove this functionality...at least for now. But basically all we wanted to do was (if Excel was installed on the PC), open up a spreadsheet and format it to the company standards and fill it in with data from the web application.
     
  13. Bruce

    Bruce DiscountASP.NET Staff

  14. Thanks bruce! This I can definitely use.
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page