Expand my Community achievements bar.

Excel reporting


Level 7

I want to trigger my sling servlet on button click and that servlet get trigerred after that and excel file must be downloaded automatically in browser .

I have done the coding its working withot any issue ....but the automatically download iafter clicking on buttton on bbrwser itself in dwoload folder that is what I am not able to acheive

when I work with simple fileoutput stream it works excel file get downloaded and i can open it and see it .(working code )

File excelfile = new File("customisedReport.xlsx");
FileOutputStream fileOutputStream = new FileOutputStream(excelfile);

but if i change the above code below like this : it won't work (nothing happens on clicking on button )

String reportName="customisedCommentReport.xlsx";
response.setHeader("Content-Disposition", "attachment; filename="+reportName);
ServletOutputStream outputStream = response.getOutputStream();

please suggest what can be the issue

Please note : google chrome i m using , apache poi , XSSFworkbook i used ,

0 Replies


Level 7

inside my js

funReport= function(t, e) {

                var presenturl=window.location.href;


                    type: "GET",

                    url: "/bin/excelreporting",

                    data: {






Directing hitting the URL /bin/excelreporting it works but on click of button this is not working ?

page footer