Click here to Skip to main content
15,891,372 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
So I have this code that Export string I pass to excel

VB
Response.Clear()
Response.Buffer = True
Response.AddHeader("content-disposition", "attachment;filename=MyExcelData.xls")
Response.Charset = ""
Response.ContentType = "application/vnd.ms-excel"
Response.Output.Write(myDataString)
Response.Flush()
Response.End()


This code ask me to open or save the file. My question is is there a way that automatically open the file without asking me to either open or save the file???
Posted

No, as this is a security risk.
 
Share this answer
 
Comments
Maciej Los 8-May-14 15:32pm    
+5
You can try to change the Reponse.Header to the following:

Response.AddHeader("Content-Disposition", "inline;filename=" + fileName);


Keep in mind this is a security risk and different browser will behave differently.
 
Share this answer
 
Comments
Maciej Los 8-May-14 15:32pm    
+5
[no name] 9-May-14 2:14am    
Didn't work it also prompt me to open or save the file. I want it to open without asking me to open
AnvilRanger 9-May-14 8:24am    
I said that different browsers behave differently. What you are trying to do is circumvent safety protocols that modern browsers have in place for a reason. What is the issue with the Open/Save dialog?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900