Index: ssts-web/src/main/webapp/jasperRtp/exportReport.jsp =================================================================== diff -u -r33106 -r35512 --- ssts-web/src/main/webapp/jasperRtp/exportReport.jsp (.../exportReport.jsp) (revision 33106) +++ ssts-web/src/main/webapp/jasperRtp/exportReport.jsp (.../exportReport.jsp) (revision 35512) @@ -1,26 +1,19 @@ <%@ page contentType="text/html; charset=UTF-8"%> -<%@page import="net.sf.jasperreports.engine.export.JRXlsAbstractExporterParameter"%> -<%@page import="net.sf.jasperreports.engine.export.JRXlsExporterParameter"%> <%@page import="java.net.URLEncoder"%> -<%@page import="net.sf.jasperreports.engine.JRException"%> -<%@page import="net.sf.jasperreports.j2ee.servlets.ImageServlet"%> -<%@page import="java.io.IOException"%> <%@page import="java.io.OutputStream"%> -<%@page import="net.sf.jasperreports.engine.JRExporterParameter"%> -<%@page import="net.sf.jasperreports.engine.export.JExcelApiExporter"%> <%@page import="net.sf.jasperreports.engine.export.ooxml.JRXlsxExporter"%> <%@page import="net.sf.jasperreports.engine.JasperPrint"%> +<%@page import="net.sf.jasperreports.export.SimpleXlsxReportConfiguration"%> +<%@page import="net.sf.jasperreports.export.SimpleExporterInput"%> +<%@page import="net.sf.jasperreports.export.Exporter"%> +<%@page import="net.sf.jasperreports.export.SimpleOutputStreamExporterOutput"%> <% - -Object obj = session.getAttribute(ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE); -JasperPrint jasperPrint = null; -if(obj instanceof JasperPrint){ - jasperPrint = (JasperPrint)obj; -} +JasperPrint jasperPrint = (JasperPrint)session.getAttribute("jasperPrintForPrint"); OutputStream outputStream = null; - try { - //out.clear(); //清空缓存的内容 - //out = pageContext.pushBody(); + String fileName = null; + try { + out.clear(); //清空缓存的内容 + out = pageContext.pushBody(); outputStream = response.getOutputStream(); response.setContentType("application/x-download"); response.setCharacterEncoding("UTF-8"); @@ -29,31 +22,33 @@ appointFileName = ""; } if(appointFileName == ""){ - response.setHeader("Content-Disposition", "attachment;filename="+URLEncoder.encode(session.getAttribute("fileName") + appointFileName +".xlsx", "UTF-8")); + fileName = session.getAttribute("fileName") + appointFileName +".xlsx"; }else{ - response.setHeader("Content-Disposition", "attachment;filename="+URLEncoder.encode(appointFileName +".xlsx", "UTF-8")); + fileName = appointFileName +".xlsx"; } - - }catch (IOException e) { + response.setHeader("Content-Disposition", "attachment;filename="+URLEncoder.encode(fileName, "UTF-8")); + }catch (Exception e) { //e.printStackTrace(); - }catch(IllegalStateException e){ - } - JRXlsxExporter xlsExporter = new JRXlsxExporter(); - xlsExporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); - xlsExporter.setParameter(JRExporterParameter.OUTPUT_STREAM,outputStream); - xlsExporter.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS,Boolean.TRUE); - xlsExporter.setParameter(JRXlsExporterParameter.IGNORE_PAGE_MARGINS,Boolean.TRUE); - xlsExporter.setParameter(JRXlsAbstractExporterParameter.IS_DETECT_CELL_TYPE, Boolean.TRUE); - //xlsExporter.setParameter(JRXlsExporterParameter.IS_DETECT_CELL_TYPE, Boolean.TRUE);//设置导出的Excel 数字显示成字符串问题 - //xlsExporter.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET,Boolean.FALSE); - //xlsExporter.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND,Boolean.FALSE); - try { - xlsExporter.exportReport(); - outputStream.close(); - out.clear(); - out = pageContext.pushBody(); - } catch (JRException e) { - e.printStackTrace(); - } + } + SimpleOutputStreamExporterOutput simpleOutputStreamExporterOutput = new SimpleOutputStreamExporterOutput(outputStream); + Exporter exporter = new JRXlsxExporter(); + exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); + exporter.setExporterOutput(simpleOutputStreamExporterOutput); + SimpleXlsxReportConfiguration configuration = new SimpleXlsxReportConfiguration(); + configuration.setOnePagePerSheet(false); + configuration.setRemoveEmptySpaceBetweenRows(true); + configuration.setIgnorePageMargins(true); + configuration.setDetectCellType(true); + configuration.setWhitePageBackground(false); + exporter.setConfiguration(configuration); + exporter.exportReport(); + try { + outputStream.close(); + out.clear(); + out = pageContext.pushBody(); + } catch (Exception e) { + e.printStackTrace(); + } + %> Index: ssts-web/src/main/webapp/tempTable.html =================================================================== diff -u --- ssts-web/src/main/webapp/tempTable.html (revision 0) +++ ssts-web/src/main/webapp/tempTable.html (revision 35512) @@ -0,0 +1,289 @@ + + +
+
+
+
+ + +
|