Solved

Save to Excel not working on IIS

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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
The viewer will learn how to synchronize PHP projects with a remote server 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…

737 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