1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| File export = exporterVolumes(typeTemps, typeInst, Long.parseLong(profilId), dateDebut, dateFin);
HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse();
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition", "attachment; filename=\"Export_details_deal_numero_" + id + ".xls\"");
FileInputStream is = new FileInputStream(export);
byte buffer[] = new byte[1024];
int nbLecture = 0;
// Envoyer le flux dans la réponse
OutputStream os = response.getOutputStream();
while ((nbLecture = is.read(buffer)) != -1) {
os.write(buffer, 0, nbLecture);
}
os.flush();
os.close();
facesContext.responseComplete(); |
Partager