How do I choose where to download a report made in jasper?

0

So, I created an application that generates an ODT file ... in the code I am specifying exactly where it should be saved, which is in 'c: /teste/sample_report.odt' ... I put this name to test ... the problem is that the file will always be saved in this folder ... I do not want this, when we are browsing the internet and download a file and click on it, using chrome for example it already downloads to the 'downloads' folder, with firefox or IE appears a window to choose where to be saved, this is what I want ... the problem the way I did is that the person needs to have the 'test' folder in 'c:' ... I do not want this, I want it to click like any other download done on the net ... follow my code: .

   try {
    URL arquivo = getClass().getResource(/reports/term.jasper);
    JasperReport jasperReport = (JasperReport) JRLoader.loadObject(arquivo);

   //Aqui é gerado o DTO que será enviado para o IReport
    ArrayList<MinutoTRDto> dataList = getDataBeanList(licitacao);
    JRBeanCollectionDataSource beanColDataSource = new JRBeanCollectionDataSource(dataList);

    Map<String, Object> parameters = getParametros();            
    JasperPrint print = JasperFillManager.fillReport(jasperReport, parameters, beanColDataSource);

    JROdtExporter exporterOdt = new JROdtExporter();
    exporterOdt.setExporterInput(new SimpleExporterInput(print));





    // AQUI ESTA O GRANDE PROBLEMA!
    exporterOdt.setExporterOutput(new SimpleOutputStreamExporterOutput("C://teste//sample_report.odt"));
    exporterOdt.exportReport();

} catch (JRException jre) {
    jre.printStackTrace();
}
    
asked by anonymous 24.12.2015 / 13:04

1 answer

0

If you want the user to choose the location that will save, just use JFileChooser, there he chooses where he wants to save and you pass the path where he will be saved ...

    
24.12.2015 / 13:10