Link to home
Start Free TrialLog in
Avatar of mathieu_cupryk
mathieu_cuprykFlag for Canada

asked on

Problem when openning excel document. Two popups come up.

The following code I have too explorers popup for saving excel files.

What am I missing.

protected void Page_Load(object sender, EventArgs e)
    {
        DataTable dt = (DataTable)Session["EXPORT_RESULT"];
        string filename = "export.csv";
        filename = string.Format("filename={0}", filename);
        Response.AppendHeader("content-disposition", filename);
        Response.ContentType = "application/vnd.ms-excel";
        Response.ContentEncoding = System.Text.Encoding.Default;

        // Envoyer les données (fichier CSV) au Browser
        Response.Write(GetCSVString(dt, false));
    }
ASKER CERTIFIED SOLUTION
Avatar of Daniel Reynolds
Daniel Reynolds
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mathieu_cupryk

ASKER

I am not sure what this will help me with. What do you mean? Once you know you are writing or saving the file, you can keep progressing on.

Perhaps it's because it's getting called twice. Does the Excel grid on a new form? If so, what is the excel button click code? Can you post it?
A typo:

Is* the Excel grid on a new form?
You said you were having a problem saving the excel file.
The code I displayed for you works to bring up the save/open dialog for an xls file.
In the process of debugging, I am just trying to make sure you eliminate each point of possible failure to eventually get the end results.
The first point of failure to eliminate is to get your syntax right with saving/writing a file to the response stream in the excel format.

So, if you do can do that, then you would next go to your routine where you read the data to save to your csv file and work thru that making sure there are no errors in it.
This is a good solution and help me out. I used a button instead of a link.