mathieu_cupryk
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("con tent-dispo sition", filename);
Response.ContentType = "application/vnd.ms-excel" ;
Response.ContentEncoding = System.Text.Encoding.Defau lt;
// Envoyer les données (fichier CSV) au Browser
Response.Write(GetCSVStrin g(dt, false));
}
What am I missing.
protected void Page_Load(object sender, EventArgs e)
{
DataTable dt = (DataTable)Session["EXPORT
string filename = "export.csv";
filename = string.Format("filename={0
Response.AppendHeader("con
Response.ContentType = "application/vnd.ms-excel"
Response.ContentEncoding = System.Text.Encoding.Defau
// Envoyer les données (fichier CSV) au Browser
Response.Write(GetCSVStrin
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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?
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.
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.
ASKER
This is a good solution and help me out. I used a button instead of a link.
ASKER