Internet Explorer unable to read Excel stream

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Christian W Larsen

    Internet Explorer unable to read Excel stream

    I want to export a datagrid to Excel. Here is the code:

    [after datagrid databind]


    Response.Clear( );


    Response.Buffer = true;
    Response.AddHea der("content-disposition",
    "attachment;fil ename=FileName. xls");
    Response.Conten tType = "applicatio n/vnd.ms-excel";
    Response.Charse t = "";
    Response.Cache. SetCacheability (HttpCacheabili ty.NoCache);
    System.IO.Strin gWriter stringWrite = new
    System.IO.Strin gWriter();
    System.Web.UI.H tmlTextWriter htmlWrite = new
    HtmlTextWriter( stringWrite);
    DataGrid1.Rende rControl(htmlWr ite);
    Response.Write( stringWrite.ToS tring());
    Response.End();


    When I open the page with Internet Explorer I get this:


    Internet Explorer cannot download [file name] from [server name]
    Internet Explorer was not able to open this Internet site. The
    requested site is either unavailable or cannot be found. Please try
    again later.


    The funny thing: it works with Firefox - no problems at all.
    Mime types on IIS are ok.
  • George Ter-Saakov

    #2
    Re: Internet Explorer unable to read Excel stream

    You might have to add the ContentLength header.

    PS: Are you using it with https? Some IE versions had a bug with https and
    content-disposition tag. Google it.

    George.


    "Christian W Larsen" <cwl@colon.dkwr ote in message
    news:809b1a3b-ff2c-4da3-89e9-43815f02a19f@i2 9g2000prf.googl egroups.com...
    >I want to export a datagrid to Excel. Here is the code:
    >
    [after datagrid databind]
    >
    >
    Response.Clear( );
    >
    >
    Response.Buffer = true;
    Response.AddHea der("content-disposition",
    "attachment;fil ename=FileName. xls");
    Response.Conten tType = "applicatio n/vnd.ms-excel";
    Response.Charse t = "";
    Response.Cache. SetCacheability (HttpCacheabili ty.NoCache);
    System.IO.Strin gWriter stringWrite = new
    System.IO.Strin gWriter();
    System.Web.UI.H tmlTextWriter htmlWrite = new
    HtmlTextWriter( stringWrite);
    DataGrid1.Rende rControl(htmlWr ite);
    Response.Write( stringWrite.ToS tring());
    Response.End();
    >
    >
    When I open the page with Internet Explorer I get this:
    >
    >
    Internet Explorer cannot download [file name] from [server name]
    Internet Explorer was not able to open this Internet site. The
    requested site is either unavailable or cannot be found. Please try
    again later.
    >
    >
    The funny thing: it works with Firefox - no problems at all.
    Mime types on IIS are ok.

    Comment

    Working...