I want to generate a report which includes an excel sheet which is generated from the data from the database . I am using Apache POI HSSF for creating the excel sheet file in the model.
Now how to let the user download the file i have created ?
I want to generate a report which includes an excel sheet which is generated from the data from the database . I am using Apache POI HSSF for creating the excel sheet file in the model.
Now how to let the user download the file i have created ?
Just use a servlet. Feed
response.getOutputStream()
to POI HSSF to write the workbook to. Most important bit is theContent-Disposition
response header. If you set it toattachment
, then the browser will pop a Save As dialogue.Then let the download URL point to that servlet, if necessary with some request parameters or path info.