IE unable to open Excel stream

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?Q2hyaXN0aWFuIFcuIExhcnNlbg==?=

    IE unable to open 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.


  • Alvin Bruney [ASP.NET MVP]

    #2
    Re: IE unable to open Excel stream

    Uncheck the show friendly error messages to see what the real error is. It
    should give you a good enough clue.

    --

    Regards,
    Alvin Bruney [MVP ASP.NET]

    [Shameless Author plug]
    The O.W.C. Black Book, 2nd Edition
    Exclusively on www.lulu.com/owc $19.99
    -------------------------------------------------------



    "Christian W. Larsen" <ChristianWLars en@discussions. microsoft.comwr ote in
    message news:AEC02F58-1397-4498-A91E-77FF12FD1496@mi crosoft.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...