Solved

Save to Excel not working on IIS

Posted on 2007-03-30
4
614 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
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…

691 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