Solved

Save to Excel not working on IIS

Posted on 2007-03-30
4
580 Views
Last Modified: 2013-11-27
I have a button on ASP.Net page that saves data in a session to an Excel file. I have used microsoft excel dll's and it works fine in visual web developer. But as soon as I put the code on IIS it does not work. I dont get ant errors I click on the button and nothing happens.

Here is the code......
DateTime dt = System.DateTime.Now;
        int currentMonth = dt.Month - 1;
        int currentYear = dt.Year;

        Microsoft.Office.Interop.Excel.Application application;
        Microsoft.Office.Interop.Excel.Workbook book;
        Microsoft.Office.Interop.Excel.Worksheet sheet;

        application = new Microsoft.Office.Interop.Excel.ApplicationClass();
        book = application.Workbooks.Add(Type.Missing);
        application.Visible = true;

        sheet = (Microsoft.Office.Interop.Excel.Worksheet)book.Worksheets[1];
        sheet.Name = "Forecast";

        // Header

        ((Microsoft.Office.Interop.Excel.Range)sheet.Cells[1, 1]).Value2 = "Distributor";
        ((Microsoft.Office.Interop.Excel.Range)sheet.Cells[1, 2]).Value2 = "Customer";
        ((Microsoft.Office.Interop.Excel.Range)sheet.Cells[1, 3]).Value2 = "End Customer";
        ((Microsoft.Office.Interop.Excel.Range)sheet.Cells[1, 4]).Value2 = "Project";
        ((Microsoft.Office.Interop.Excel.Range)sheet.Cells[1, 5]).Value2 = "Territory";
        ((Microsoft.Office.Interop.Excel.Range)sheet.Cells[1, 6]).Value2 = "Product";
0
Comment
Question by:apparition
  • 2
4 Comments
 
LVL 25

Expert Comment

by:dstanley9
ID: 18823943
Is excel installed on the server?  The same version that you are developing against?
0
 
LVL 5

Author Comment

by:apparition
ID: 18823981
I am doing the development on my server. Excel is set up and so is Visual Web developer. It runs fine from VWD but when I copy it over to IIS wwwroot directory and try to run it from there it does not work
0
 
LVL 5

Author Comment

by:apparition
ID: 18981843
I guess no one wants to help....I ended up just generating a CSV file
0
 
LVL 4

Accepted Solution

by:
Gruff82 earned 125 total points
ID: 19014754
Hi,

I wouldn't use excel automation on the server due to instability issues. However all is not lost

What I would recommend though is using the excellent Koogra Excel BIFF library from sourceforge (http://sourceforge.net/projects/koogra/) and opening your workbook using that. The library reads and writes in the BIFF8 format which is the file format for Excel 97 and on.

Using this library you wont need to use excel or any of the interop librarys... performance is good and its easy to use...

the object model is very simialir to the excel object model and doesn't take very long to get it up and running with it.

Just thought I'd let you know even though you've already done it with a csv.

Thanks

gareth
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now