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
Naveen KumarPosted Jul 28, 2014, 6:49 AM
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+"
Pradeep ShetPosted Jul 26, 2014, 12:35 AM
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.
biren mohantyPosted Jul 25, 2014, 9:21 AM
Naveen KumarPosted Jul 25, 2014, 3:10 AM
Pradeep ShetPosted Jul 25, 2014, 2:36 AM
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