ASP.NET - Trying to spin off an Excel worksheet with IIS

Discussion in 'ASP .Net' started by Steve Kershaw, Jul 16, 2007.

  1. Hello,

    I've been trying to spin off an Excel worksheet on the client from an
    ASP.NET website. I was successfull in displaying an Excel worksheet on
    the client in a test website (not using IIS, but using Visual Studio
    2005) with the following code:

    protected void Button1_Click(object sender, EventArgs e)
    {
    Application exc = new Application();

    exc.Visible = true;

    Workbooks workbooks = exc.Workbooks;

    _Workbook workbook = workbooks.Add(XlWBATemplate.xlWBATWorksheet);

    Excel.Worksheet worksheet = (Excel.Worksheet)workbook.ActiveSheet;
    }

    This code spins off a blank Excel worksheet.

    However when I place this code into another ASP.NET website that I'm
    developing, I find that I can't set exc.Visible = true! The Excel
    worksheet doesn't display at all. The only difference is that the new
    ASP.NET website is run off of IIS and the test website is run off the
    local Visual Studio 2005.

    What am I doing wrong?

    Thanks!

    Steve
    Steve Kershaw, Jul 16, 2007
    #1
    1. Advertising

  2. "Steve Kershaw" <> wrote in message
    news:...

    > What am I doing wrong?


    You're trying to use server-side Office automation - this doesn't work:
    http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757#kb2

    Fortunately, there are several other options, depending on what you're
    trying to do. Can you please tell us your requirements, and also maybe
    explain what you mean by "spin off" an Excel worksheet...?


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net
    Mark Rae [MVP], Jul 16, 2007
    #2
    1. Advertising

  3. Office automation bits are not designed to work in web applications. If you
    want to pop things up as Excel, you have three options I can think of

    1. Create a page with an HTML table and change the MIME type to Excel. Poor
    man's way
    2. Use a third party component to create the excel spreadsheet as a file
    (this can be streamed or saved and linked)
    3. Use the office components to do the same as #2

    I do not recommend #3. And, #1 is only useful for simple spreadsheets (data
    reports, for example). There are various office writer type components that
    are much lighter than the office bits, so I would use #2 to create files.

    --
    Gregory A. Beamer
    MVP; MCP: +I, SE, SD, DBA
    http://gregorybeamer.spaces.live.com
    Co-author: Microsoft Expression Web Bible (upcoming)

    ************************************************
    Think outside the box!
    ************************************************
    "Steve Kershaw" <> wrote in message
    news:...
    > Hello,
    >
    > I've been trying to spin off an Excel worksheet on the client from an
    > ASP.NET website. I was successfull in displaying an Excel worksheet on
    > the client in a test website (not using IIS, but using Visual Studio
    > 2005) with the following code:
    >
    > protected void Button1_Click(object sender, EventArgs e)
    > {
    > Application exc = new Application();
    >
    > exc.Visible = true;
    >
    > Workbooks workbooks = exc.Workbooks;
    >
    > _Workbook workbook = workbooks.Add(XlWBATemplate.xlWBATWorksheet);
    >
    > Excel.Worksheet worksheet = (Excel.Worksheet)workbook.ActiveSheet;
    > }
    >
    > This code spins off a blank Excel worksheet.
    >
    > However when I place this code into another ASP.NET website that I'm
    > developing, I find that I can't set exc.Visible = true! The Excel
    > worksheet doesn't display at all. The only difference is that the new
    > ASP.NET website is run off of IIS and the test website is run off the
    > local Visual Studio 2005.
    >
    > What am I doing wrong?
    >
    > Thanks!
    >
    > Steve
    >
    Cowboy \(Gregory A. Beamer\), Jul 16, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?U2hhbyBZb25n?=

    How to delete an Excel worksheet by using ASP.NET?

    =?Utf-8?B?U2hhbyBZb25n?=, May 10, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    1,123
    Martin Dechev
    May 12, 2004
  2. info
    Replies:
    1
    Views:
    524
    Richard
    Jul 21, 2003
  3. dan_roman
    Replies:
    3
    Views:
    1,898
    John Machin
    Oct 5, 2006
  4. Replies:
    1
    Views:
    282
    Mirco Wahab
    Apr 17, 2007
  5. Katja
    Replies:
    1
    Views:
    197
Loading...

Share This Page