• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 851
  • Last Modified:

Exporting to Excel from a Modal IE Window

I have the following code to export binary data in a modal window that is opened using javascript window.showmodaldialog():

        Dim result() As Byte
        ...
        Response.ClearContent()
        Response.ClearHeaders()
        Response.ContentType = "application/vnd.ms-excel"
        Response.AddHeader("Content-Disposition", "attachment; filename=" & sFilename & "")
        Response.BinaryWrite(result)
        Response.End()

The problem is that it opens a blank window where it opens up the Save/Open dialog.  And I do not want another window opening up.  Everything works fine when I try to export from an ordinary window.

I've tried putting <base target=_self> in my aspx file.  What happens is the modal window seems to just refresh itself, but the Save/Open dialog doesn't appear anymore.

Help please.

Thanks.
0
gtmljsc
Asked:
gtmljsc
  • 2
  • 2
1 Solution
 
dfu23Commented:
Good question, maybe try getting tricky ... like putting an IFRAME in the modal window that loads the excel ... not sure of why it does not load offhand but try some quick workarounds to see if there is a way to hack it and get it to do what you want it to do.

Does it have to be a modal window? Can a normal window with some javascript accomplish the same thing?
0
 
gtmljscAuthor Commented:
Our client wants it to be a modal window.

Anyways, here's what I really have:  

I do have an IFrame in my modal window, and it's created at runtime.  The content of the IFrame is a report generated by SQL 2000 Reporting Service.  Outside the IFrame is a an Export Button, which calls another method to render the report in Excel format, output as  binary data into my byte variable, result.  And then I use the code above to "export" the data as an Excel file.

I tried creating another IFrame F2, and putting <base target="F2"> in my aspx page.  It didn't work still.  It still opens up a new window.

Should my button be inside another iFrame?  If it is inside another IFrame, can it still access the query strings passed on to the main modal window?

Thanks.
0
 
gtmljscAuthor Commented:
Everything's working now... I had to put my button inside another IFrame and call my export function from there.  But I also had to retransfer my query string again to the page in my new IFrame.  It's pretty messy, but it works!

Thanks dfu23.
0
 
dfu23Commented:
No problem ... glad you were able to get to work!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now