%@page import="java.io.ByteArrayOutputStream"%>
<%@page import="java.util.Date"%>
<%@page import="net.sf.jasperreports.engine.JasperPrint"%>
<%@page import="com.forgon.disinfectsystem.common.CssdUtils"%>
<%@page import="com.forgon.tools.util.FileUtils"%>
<%@page import="net.sf.json.JSONObject"%>
<%@page import="net.sf.jasperreports.export.SimpleExporterInput"%>
<%@page import="net.sf.jasperreports.export.SimpleHtmlExporterOutput"%>
<%@page import="net.sf.jasperreports.export.SimpleHtmlReportConfiguration"%>
<%@page import="net.sf.jasperreports.engine.export.HtmlExporter"%>
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<%@ include file="/common/includeExtJsAndCss.jsp"%>
<%
String tableStr = "";
int pageIndex = 0;
int lastPageIndex = 0;
String timeStamp = request.getParameter("currentTime");
String isPrint = request.getParameter("isPrint");
String hidePrintBtn = request.getParameter("hidePrintBtn");
request.setAttribute("isPrint",isPrint);
request.setAttribute("hidePrintBtn",hidePrintBtn);
String reportName = ""; //报表的名称
//是否启用报表导出html或pdf功能,1显示报表导出pdf图标 2显示报表导出html图标 3都显示
JSONObject sstsConfig = CssdUtils.getWebConfigInfo();
String reportExportExtraFormat = sstsConfig.optString("reportExportExtraFormats","0");
try{
if(timeStamp == null){
timeStamp = "";
}
JasperPrint jasperPrint = (JasperPrint)session.getAttribute("JasperPrint"+timeStamp);
if(jasperPrint != null && jasperPrint.getPages() != null && jasperPrint.getPages().size() > 0){
reportName = jasperPrint.getName();
String currentTime = new Date().toString();
request.setAttribute("currentTime",currentTime);
session.setAttribute("JasperPrint"+currentTime,jasperPrint);
JasperPrint jasperPrintForPrint = (JasperPrint)session.getAttribute("jasperPrintForPrint"+timeStamp);
session.setAttribute("jasperPrintForPrint"+currentTime,jasperPrintForPrint);
if (jasperPrint.getPages() != null){
lastPageIndex = jasperPrint.getPages().size() - 1;
}
String pageStr = request.getParameter("pageIndex");
try{
if( pageStr != null)
pageIndex = Integer.parseInt(pageStr);
session.setAttribute("pageIndex", pageIndex);
}catch(Exception e){
}
if (pageIndex < 0){
pageIndex = 0;
}
if (pageIndex > lastPageIndex){
pageIndex = lastPageIndex;
}
HtmlExporter exporterHTML = new HtmlExporter();
ByteArrayOutputStream htmlStream = new ByteArrayOutputStream();
SimpleHtmlReportConfiguration reportExportConfiguration = new SimpleHtmlReportConfiguration();
reportExportConfiguration.setWhitePageBackground(false);
reportExportConfiguration.setPageIndex(pageIndex);
reportExportConfiguration.setRemoveEmptySpaceBetweenRows(true);
exporterHTML.setConfiguration(reportExportConfiguration);
exporterHTML.setExporterInput(new SimpleExporterInput(jasperPrint));
exporterHTML.setExporterOutput(new SimpleHtmlExporterOutput(htmlStream));
exporterHTML.exportReport();
tableStr = htmlStream.toString("UTF-8");
}
}catch(Exception e){
System.out.print("空页面!");
}
%>
<%-- 分页导航栏 --%>
<%
if("true".equals(isPrint)){
%>