Using Interop.Excel to generate excel file and export to excel

I am using the interop.excel to generate an excel file that I will be exporting to excel. It works fine if I save it to my C drive. But I want to be able to export to excel and give the user a file download prompt with the opens save, open or cancel. If I use
my opened window hangs. Any suggestions?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

pl try Response.BinaryWrite()
Neil FlemingConsultant and developerCommented:
try using a stringwriter:

Dim sw As New StringWriter()
        HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=" & filename)
        HttpContext.Current.Response.ContentType = "application/vnd.xls"
        HttpContext.Current.Response.Charset = ""



Open in new window

RylaAuthor Commented:
NeilFleming1, Do you think this will solve the Excel 2007 issue of the warning "The file you are trying to open, 'filename.xls', is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file. Do you want to open the file now?"
Why Diversity in Tech Matters

Kesha Williams, certified professional and software developer, explores the imbalance of diversity in the world of technology -- especially when it comes to hiring women. She showcases ways she's making a difference through the Colors of STEM program.

Neil FlemingConsultant and developerCommented:
No -- sadly it doesn't solve that little excitement, which is caused by MS's "security feature" caled 'Extension Hardening' (at least someone at MS has a sense of humor....)

Your choices are to use xlsx files (useless if anyone is using excel 2003), CSV files, or modify the client PC's registry to turn off the Extension checking.

Instructions on how to do that are here:

...bu obviously of no use unless you have access to every machine that will open your file.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Neil FlemingConsultant and developerCommented:
PS Microsoft's own advice is to ignore the warning -- the file opens fine in any case.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.