Hi...
I am generating a report the Data to Excel sheet.
The data gets generating but When i am trying to Open the Excel sheet document . shows the alert message like this.
The file you are trying to open abc.xls is in different format than specified by the extension. Verify that the file is not corrupted and is from trusted source before openong the file. Do you want to open the file now ??
And than i click Yes it's opening No issues
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("Content-disposition","attachment;filename=abc.xls)
Can any one help me to get rid of this alert message

Pradeep ShetRank #595 · 4K reputationPosted Jul 24, 2014, 10:36 PM EDT
Use Response.End(); after adding Adding Header and all.
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("Content-disposition","attachment;filename=abc.xls)
Response.End();
This will solve your problem of showing popup alert.
Hope this solution helps you. If so mark it as answered
Naveen Kumar54 reputationPosted Jul 24, 2014, 11:10 PM EDT
biren mohanty6 reputationPosted Jul 25, 2014, 5:21 AM EDT
Pradeep ShetRank #595 · 4K reputationPosted Jul 25, 2014, 8:35 PM EDT
Add below line, it should work.
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("Content-disposition","attachment;filename=abc.xls) ;
HttpContext.Current.ApplicationInstance.CompleteRequest();
Response.End();
Try it once and if it solves your problem, mark it answered.
Naveen Kumar54 reputationPosted Jul 28, 2014, 2:49 AM EDT
This was My code....
protected void btnReportS_Click(object sender, EventArgs e)
Employee Holiday Report
Report Generated On: " + drtime + "
Date Range: " + hdaterange.Value + "
" + lblUnmae.Text + "
"+lblleavestaken.Text+"