Solved

Save to Excel not working on IIS

Posted on 2007-03-30
4
589 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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

809 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