tags:

views:

22

answers:

1

I have the following X.aspx code..to download excel file from Server

if (ss[5] != "")
            {
                Response.Clear();
                Response.AddHeader("Content-disposisition", "inline;filename=x.xls");
                Response.ContentType = "application/vnd.ms-excel";
                Response.TransmitFile(ss[5]);
                Response.End();
            }

Excel throws message

The file you are trying to open 'x.aspx', is in a different format that specified by the file extention....

How can I let excel know the correct file name ..

+1  A: 

Looks like you have a typo in your content disposition header. Try:

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

or

Response.AddHeader("Content-Disposition","attachment; filename=x.xls");

David
Thanks David, it is indeed a typo corrected as sugessted and working fine ..
TonyP