繁体   English   中英

无法在客户端使用poin mvc生成下载excel文件

[英]Unable to generate download excel file on client side usinf poi mvc

我无法在客户端生成要下载的Excel文件。 这是我的代码:

 <%
 try{
  //Getting HSSFWorbook object from controller
    HSSFWorkbook wb= (HSSFWorkbook)pageContext.findAttribute("wb");
    response.setContentType("application/vnd.ms-excel");
    response.setHeader("Content-   Disposition","attachment;
    filename=ESTHotelPerfByMonthExcelReport.xls"
    );
  //Writing to output Stream 

    ServletOutputStream outputStream = response.getOutputStream();
    wb.write(outputStream);
    outputStream.flush();
 }//closing try
 catch (IOException ioe) { 
 }
}//closing if


//The above code is not generating any 
// excel sheet however if i write the output to 
// a    excel file it shows the all the data

 %>

我假设您正在尝试从JSP文件中编写生成的xls文件。 问题可能在于空格,如果有的话,那么写入ServletOutputStream就会产生异常。

因此请在“<%”之前检查指令之间是否有空格。 同样设置<%@ page trimDirectiveWhitespaces="true" %>以防万一。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM