Home » excel » excel – Create XLS file on server and return back to client without saving file on server in java

excel – Create XLS file on server and return back to client without saving file on server in java

Posted by: admin May 14, 2020 Leave a comment

Questions:

In my strut2 base web application . I want to create XLS file when user click on download button without saving that file on server return back to client machine.

I have tried with different libraries but not found suitable solution.

also the save the file comes to client browser instead of download window is it possible to open save/cancel dialog box in which user can select file location to save .

Thanks

How to&Answers:

Apache POI provides Workbook.write(java.io.OutputStream). You should able to access the output stream and then write to it.

There are many hits comes from google – here is some that is very close.

That is (from Jim Garrison), do not open FileOutputStream. Servlet will provide you output stream. Write on to it. To help users with automatic filename or MIME handlers etc, do so the content disposition like possible filename.