Everything worked fine in Office 2003, but with Office 2007 we get the following error when we try to open the Excel file.
"The file you are trying to open, 'ReportingHandler.aspx', is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file. Do you want to open the file now?"
In ReportHandler.aspx we are using the following lines to open:
private void GenerateExcelReport()
{
if(IsUserPrompted)
{
current.Response.AppendHeader("Content-disposition",
string.Format("attachment;filename={0}.xls", ReportName));
}
else
{
current.Response.AppendHeader("Content-disposition",
string.Format("inline;filename={0}.xls", ReportName));
}
current.Response.ContentType = "application/vnd.ms-excel";
WriteStream();
}
private void WriteStream()
{
MemoryStream stream = (MemoryStream)ReportCache;
current.Response.Buffer = true;
current.Response.BinaryWrite(stream.ToArray());
stream.Close();
SessionManagement.ViewBaseSession.Remove(ReportId);
}
If you click "Yes" on the warning then the Excel looks fine. I have read others on the internet are having similar issues and that it might be an Office 2007 issue, but wanted to run it up the flag pole here to see if you all knew anything.