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

S

Steve Kershaw

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
 
C

Cowboy \(Gregory A. Beamer\)

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top