请教::生成EXCEL文件???? lz可以使用eXtremeComponents的 具体的可以查看google的搜索 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 给你做参考 参考: // 生成excel格式 public void excelReport(String jasperName,HttpServletRequest request,HttpServletResponse response,Connection conn)throws JRException,IOException{ JasperPrint jp = getJasperPrint(jasperName,response,conn) ; // org/apache/poi/hssf/usermodel/HSSFCellStyle JRXlsExporter exporter = new JRXlsExporter(); byte[] bytes; ByteArrayOutputStream bo = new ByteArrayOutputStream(); exporter.setParameter(JRExporterParameter.JASPER_PRINT,jp); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM,bo); exporter.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS,Boolean.TRUE); exporter.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET,Boolean.FALSE); exporter.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND,Boolean.FALSE); exporter.setParameter(JRXlsExporterParameter.IS_FONT_SIZE_FIX_ENABLED,Boolean.TRUE); exporter.exportReport(); bytes = bo.toByteArray(); if(bytes != null && bytes.length > 0){ response.reset(); response.setContentType("application/vnd.ms-excel"); response.setHeader("Content-Disposition", "attachment;filename="Report.xls"" );//打开保存 response.setContentLength(bytes.length); ServletOutputStream sos = response.getOutputStream(); sos.write(bytes,0,bytes.length); sos.flush(); sos.close(); } } HTTPCLIENT 如何 提取HTML中的PDF文件 hinernate高手进啊 在线等 Java用xsl对xml做格式转换时抛出ArrayIndexOutOfBoundException struts2练习时出现这个问题,高手帮看看 求一个能在JSF的实例.分不够还可以加. 给点提示就送分!! jdom处理xml文档过滤了留换行符~? struts2 form动态修改的数据如何传至后台action中 想学j2ee,请前辈指点! Struts2的奇怪bug 请教一个入门问题。 如何让ajax实现延时操作提示,如操作正在进行,请稍后....(在线等)
// 生成excel格式
public void excelReport(String jasperName,HttpServletRequest request,HttpServletResponse response,Connection conn)throws JRException,IOException{
JasperPrint jp = getJasperPrint(jasperName,response,conn) ;
// org/apache/poi/hssf/usermodel/HSSFCellStyle
JRXlsExporter exporter = new JRXlsExporter();
byte[] bytes;
ByteArrayOutputStream bo = new ByteArrayOutputStream();
exporter.setParameter(JRExporterParameter.JASPER_PRINT,jp);
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM,bo);
exporter.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS,Boolean.TRUE);
exporter.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET,Boolean.FALSE);
exporter.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND,Boolean.FALSE);
exporter.setParameter(JRXlsExporterParameter.IS_FONT_SIZE_FIX_ENABLED,Boolean.TRUE);
exporter.exportReport();
bytes = bo.toByteArray();
if(bytes != null && bytes.length > 0){
response.reset();
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition", "attachment;filename="Report.xls"" );//打开保存
response.setContentLength(bytes.length);
ServletOutputStream sos = response.getOutputStream();
sos.write(bytes,0,bytes.length);
sos.flush();
sos.close();
} }