Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7904203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:57:13+00:00 2026-06-03T09:57:13+00:00

In my application i have to export the excel file which I have achieved

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T09:57:15+00:00Added an answer on June 3, 2026 at 9:57 am

    You have changed the location of the main window with window.location.href and then the HTTP response has the Excel MIME type. The main window no longer has an HTTP response to work with and is unable to refresh.

    Instead you should open a completely new window and use that to send the Excel file response. You will then still have the main window available to refresh.

    Your script should be something like;

    <script> 
      window.open('GenerateExcel.aspx', 'Export To Excel');
      window.location.href=window.location.href;
    </script>
    

    Another way to avoid opening a window is to make the HTTP Request with JavaScript but that is going to need jQuery for a reliable cross browser solution.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Grail application under Groovy. I export an Excel file. I can
I want to have a one-click excel export feature for my application. I therefore
In my console application have an abstract Factory class Listener which contains code for
This is the code that i have to export data to Excel. Dim oExcel
I receive an excel file monthly and have to export parts of it to
I have the following code to export a gridview to excel and the export
We have an application that, amongst many other things, has an export to Excel
I have a simple table which I would like to export to an Excel
So I have an 'export' application that arrives the user at an end page
i have a web application that export CSV and i logged in as admin

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.