Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Excel reporting

Avatar

Avatar
Contributor 2
Level 4
AdobeID24
Level 4

Likes

54 likes

Total Posts

153 posts

Correct Reply

1 solution
Top badges earned
Contributor 2
Validate 10
Validate 1
Ignite 5
Ignite 3
View profile

Avatar
Contributor 2
Level 4
AdobeID24
Level 4

Likes

54 likes

Total Posts

153 posts

Correct Reply

1 solution
Top badges earned
Contributor 2
Validate 10
Validate 1
Ignite 5
Ignite 3
View profile
AdobeID24
Level 4

23-10-2019

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);
workbook.write(fileOutputStream);
fileOutputStream.close();

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.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setHeader("Content-Disposition", "attachment; filename="+reportName);
ServletOutputStream outputStream = response.getOutputStream();
workbook.write(outputStream);
outputStream.flush();
outputStream.close();
workbook.close();

please suggest what can be the issue

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

Replies

Avatar

Avatar
Contributor 2
Level 4
AdobeID24
Level 4

Likes

54 likes

Total Posts

153 posts

Correct Reply

1 solution
Top badges earned
Contributor 2
Validate 10
Validate 1
Ignite 5
Ignite 3
View profile

Avatar
Contributor 2
Level 4
AdobeID24
Level 4

Likes

54 likes

Total Posts

153 posts

Correct Reply

1 solution
Top badges earned
Contributor 2
Validate 10
Validate 1
Ignite 5
Ignite 3
View profile
AdobeID24
Level 4

23-10-2019

inside my js

funReport= function(t, e) {

                var presenturl=window.location.href;

                $.ajax({

                    type: "GET",

                    url: "/bin/excelreporting",

                    data: {

                        'presenturl':presenturl,

                    }

                })

               

            }

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