views:

26

answers:

0

Using C# I'm able to export an aspx page to Excel when the Excel version being used is 2010. However, if I try to export the content on an XP machine with Excel 2003 I get a box that displays saying - Unable to open file.

Is there something I need to add to the code that can make this go away and open the file? Here is what I have for the ContentType and AddHeader.

Response.ContentType = "application/vnd.ms-excel"; Response.AddHeader("content-disposition", "attachment; filename=test_excel.xls");

Thanks.

------- UPDATE ---------

In case this helps anyone else. What seemed to help here was adding this to the code behind.

private void Page_Init(object sender, System.EventArgs e)
{
    this.EnableViewState = false;
}