lz可以使用eXtremeComponents的 具体的可以查看google的搜索

解决方案 »

  1.   

    给你做参考 参考:
        
    // 生成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();
               }       }