日期:2014-05-17 浏览次数:21030 次
public String filename;
public InputStream excelStream;
get、set方法省略....
public String exportExcel() {
ByteArrayOutputStream targetFile = new ByteArrayOutputStream();
try {
WritableWorkbook workbook = Workbook.createWorkbook(targetFile);
WritableSheet sheet = workbook.createSheet("测试报告", 0);
......其他省略
workbook.write();
workbook.close();
} catch (Exception e) {
System.out.println("在输出到EXCEL的过程中出现错误,错误原因:" + e.toString());
}
excelStream = new ByteArrayInputStream(targetFile.toByteArray());
System.out.println("===================================="+excelStream);
}
<result name="excel" type="stream">
<param name="contentType">application/vnd.ms-excel</param>
<param name="inputName">excelStream</param>
<param name="contentDisposition">attachment;filename="test.xls"</param>
<param name="bufferSize">1024</param>
</result>
<!-- 导出excel -->
<action name="daochuexcel" class="com.wuliuguanli.action.DaochuExcelAction">
<result name="excel" type="stream">
<param name="contentType">application/vnd.ms-excel</param