Sending xls file from Server to Client via

Discussion in 'ASP .Net' started by Lars Netzel, Nov 10, 2005.

  1. Lars Netzel

    Lars Netzel Guest

    I have an XLS file that I try to send to the webclient via ASP.NET. When
    sending I use this code...


    Response.ContentType = "application/"

    Response.AddHeader("Content-Disposition", "inline; filename=" &
    ClientFilename & ".xls")



    The Problem:

    When clicking the link that is running this code the "_blank" window that is
    suppoed to show the excel file, closes imediately... it's like.. I click..
    a new window opens and closes right away.. no error messages

    I do the same for a PDF file with the only exception for the contenttype and
    extention of the file name. and that works fine.

    What's the problem you think? why does a PDF work and not the Xls file?

    best regards

    Lars Netzel, Nov 10, 2005
    1. Advertisements

  2. Lars,

    I'm not certain if this will help in your situation or not. I was just
    looking over some code of mine for outputting a datagrid as an excel file so
    it's a little bit different than your code, but I do two things before
    sending the stream to the client that you're not doing:

    1.. '---Clear the characterset
    2.. Response.Charset = ""
    4.. '---Viewstate must be turned off.
    5.. Me.EnableViewState = False
    Maybe adding this will work.


    S. Justin Gengo, MCP
    Web Developer / Programmer

    "Out of chaos comes order."
    S. Justin Gengo, Nov 10, 2005
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.