Solved

Problem when openning excel document. Two popups come up.

Posted on 2007-12-03
6
196 Views
Last Modified: 2013-12-16
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));
    }
0
Comment
Question by:mathieu_cupryk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 17

Accepted Solution

by:
Daniel Reynolds earned 500 total points
ID: 20400174
Can you write anything to an excel file? Try the following to just get a sample going and see if it will create the file for you. Once you know you are writing or saving the file, you can keep progressing on.
 
           Response.ContentType = "application/vnd.ms-excel";
            Response.AddHeader("Content-Disposition", "attachment; filename=c:\\myfile.xls");
            Response.Write("<HTML>\n");
            Response.Write("      <head runat='server'>\n");
            Response.Write("            <title>Excell_Output</title>\n");
            Response.Write("      </head>\n");
            Response.Write("      <body>\n");
            Response.Write("<table><tr><td>Howdy</td></tr></table");
            Response.Write("      </body>");
            Response.Write("</HTML>");
0
 

Author Comment

by:mathieu_cupryk
ID: 20401031
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.

0
 
LVL 10

Expert Comment

by:digitalZo
ID: 20401156
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?
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 10

Expert Comment

by:digitalZo
ID: 20401158
A typo:

Is* the Excel grid on a new form?
0
 
LVL 17

Expert Comment

by:Daniel Reynolds
ID: 20404617
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.
0
 

Author Closing Comment

by:mathieu_cupryk
ID: 31412455
This is a good solution and help me out. I used a button instead of a link.
0

Featured Post

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Need help for captcha 2 42
aspx ascx, c# 7 43
Disable the weekends on datepicker control 6 52
Building Collections of Objects based on their Tag Property 33 55
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question