In my application i have to export the excel file which I have achieved by below code:
Response.ClearContent();
Response.AddHeader("Content-Disposition", string.Format("attachment; filename={0}", pFileName));
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
FileInfo myFile = new FileInfo(fullfilePath);
Response.WriteFile(myFile.FullName);
Response.Flush();
HttpContext.Current.ApplicationInstance.CompleteRequest();
Response.End();
From my main page where "Export To Excel" button is present, on click of of that button I have registerred a Javascript as below:
ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), "<script language=JavaScript>window.location.href('GenerateExcel.aspx');</script>");
and on the page load of GenerateExcel.aspx
page i have written the code for exporting file that I posted above. This code is work for me, when users hits the "Export To Excel" button windows file Open , save & close popup is apeear and user is able to save or open the file but my problem here is that after that file open popup I want to refresh the main page. I have tried registering javascript but after Response.End
nothiing is working.
Please help me.