Results 1 to 4 of 4

Thread: Tough Question about exporting to EXCEL file.

  1. #1
    Join Date
    Dec 2007
    Location
    Medellin, Colombia, South America
    Posts
    45

    Default Tough Question about exporting to EXCEL file.

    I am using Spring MVC, Spring.
    Well, I have programmed a button to export the contents of a list using (retrieved with parameters used in the JSP page) Japerreports and used the View technology support in Spring MVC via JasperReportsMultiFormatView class mainly to export to EXCEL files, when I click on the button (the onSubmit event is fired) there are two situations arise using IE. One is that the excel file is downloaded to my computer and then opened using Microsoft Excel file (outside the IE browser, and this is desirable), the other is my web page is replaced to an inline version and thus the user can think it was lost and has to click the back button to see the IE browser again and possibly not in the same page.

    My question is. Is there a way to solve the problem to always force IE to download file no matter it has an embedded EXCEL viewer inside the IE browser.
    I would like to know.

    One other solution is to use a popup windows but a problem here is how do I post parameters to the page.

    Well this also happens to PDF rendering.
    Hope you can help or know of someone who knows a better solution for this though question.,

    Thanks in advance and hoping your reply is on the way.

  2. #2

    Default

    Well you can always use target="_blank" on the link. Usually, browsers would open the link's target in a new window then. I don't think you can really force the IE not to open the file directly. As far as I know it decides that based on the file's extension (*.xls) and if you name the file differently, your users might not know what to do with the file.

  3. #3
    Join Date
    Jan 2007
    Location
    Orlando, FL USA
    Posts
    84

    Default

    Hello Carlos,

    I haven't used JasperReportsMultiFormatView myself, but if you do servlet by itself, the following usually will make browser download file instead of open by it's plugin as embedded browser objects.

    For example with a HttpServletResponse object, do:

    response.setHeader("Content-Disposition", "attachment; filename=\""+yourFilename+"\"")
    response.setContentType("application/octet-stream")
    response.setContentLength(yourFileLength)
    //stream your file out here to response's output steam

    Hope this helps.
    http://www.jroller.com/thebugslayer - notes on java, scala and other development stuff.

  4. #4
    Join Date
    Dec 2007
    Location
    Medellin, Colombia, South America
    Posts
    45

    Default A kind reply

    thanks thebugslayer, Ammaletu
    Well I have to tell ao Ammaletu that your reply is one part of the solution only if my button is a link but I have now a program which uses a button who makes a form submission via post and the controller is the one to decide what to do next, in fact, it uses JasperReport in SpringMVC as the View and just send it to client, i.e., to IE or Firefox (that is my current solution), but the file in IE is embedded which makes users lose focus on application navigation, but in FireFox it is downloaded (provided I am using Windows). Thus it is not a complete link for now but I will have to test this tip. Thanks for this Ammaletu.

    To thebugslayer (nice alias), let me tell you that I have to check it out your tip. thanks.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •