I dont want to open the excel sheet in same browser

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • firasjabur
    New Member
    • Feb 2008
    • 3

    I dont want to open the excel sheet in same browser

    Hello folks,
    I am exporting my gridview .net page to excel. Everything works fine, except that the excel sheet opens through IE browser. When i researched it, I found out it i can do it manualy by going to Folder Options/File Types and check Confirm Open after Download. And it works, but I cannot force every user to do that. How can I automate this process (coding)? Help is greatly appreciated!
  • ShadowLocke
    New Member
    • Jan 2008
    • 116

    #2
    Make sure you add the correct header. It needs to be an attachment if you want the prompt to open/save as

    for example.. {C#}

    Code:
    Response.AddHeader("Content-disposition", "attachment; filename=\"excel.xls\""
    (Quotes around file name for cross browser support)

    Comment

    Working...