我采用了一种出口xls文档的方法。 这种方法是正确的,但在被迫害后,我就得了。
面对: 在做出回应后无法取得进展
Here is the method:
public String exportXls() {
OutputStream out = null;
try {
FacesContext cxt = FacesContext.getCurrentInstance();
ExternalContext context = cxt.getExternalContext();
HttpServletResponse response = (HttpServletResponse) context.getResponse();
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition", "attachment; filename=name.xls");
out = response.getOutputStream();
WritableWorkbook workbook = createWorkbook(response);
// All sheets and cells added. Now write out the workbook
workbook.write();
workbook.close();
System.out.println("XLS written!");
} catch(Exception ex) {
logger.error("ERROR OCCURRED WITH exportXls" + ex.toString());
} finally {
try {
if (out != null) out.close();
} catch(IOException e) {
logger.error(e);
e.printStackTrace();
}
}
return "page";
}
页: 1 你们认为什么是问题?