<%--
* 程序名 : listReportTabPreview.jsp
* 日期  : 2016-02-22
* 公司  ：宁波金网
* 作者  : 高伟杰
* 模块 : 报表预览
* 备注 : 
--%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ page import="com.gaowj.business.util.SessionUtil"%>
<%@ page import="net.sf.jasperreports.engine.*" %>
<%@ page import="net.sf.jasperreports.engine.util.*" %>
<%@ page import="net.sf.jasperreports.engine.export.*" %>
<%@ page import="net.sf.jasperreports.j2ee.servlets.*" %>
<%@ page import="java.io.*" %>
<%@ taglib uri="/struts-tags" prefix="s" %>

<%
String emid = (request.getParameter("emid") != null ? request.getParameter("emid"):SessionUtil.getEmid());
String myMethod = request.getParameter("myMethod");
String uuid = request.getParameter("uuid");
%>

<%

 JasperPrint jasperPrint = (JasperPrint)session.getAttribute("JasperPrint");

 session.setAttribute(ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE,jasperPrint);

 String pageTitle = (String)session.getAttribute("jasperTitle");

 

 JRHtmlExporter exporter = new JRHtmlExporter();

 int pageIndex = 0;

 int lastPageIndex = 0;

 if (jasperPrint.getPages() != null){

    lastPageIndex = jasperPrint.getPages().size() - 1;

 }

 

 String pageStr = request.getParameter("pageIndex");

 try{

    if( pageStr != null)

        pageIndex = Integer.parseInt(pageStr);

 }catch(Exception e){

    //e.printStackTrace();

 }

 

 if (pageIndex < 0){

    pageIndex = 0;

 }

 

 if (pageIndex > lastPageIndex){

    pageIndex = lastPageIndex;

 }

 

 StringBuffer sbuffer = new StringBuffer();

 

 exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);

 exporter.setParameter(JRExporterParameter.OUTPUT_STRING_BUFFER, sbuffer);

 exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, "images\\jasper\\");

 exporter.setParameter(JRExporterParameter.PAGE_INDEX, new Integer(pageIndex));

 exporter.setParameter(JRHtmlExporterParameter.HTML_HEADER, "");

 exporter.setParameter(JRHtmlExporterParameter.BETWEEN_PAGES_HTML, "");

 exporter.setParameter(JRHtmlExporterParameter.HTML_FOOTER, "");

 try{

    exporter.exportReport();

    }catch(Exception e){

      e.printStackTrace();

    }

%>

<table width="100%" border="0"><tr><td>
  <a href="#" title="导出 PDF" onclick="javascript:exportPDF()"><img src="gaowj/ria/jquery/jquery-easyui-1.4.1/themes/icons/pdf16.bmp" border="0"></a>
  <a href="#" title="导出 WORD" onclick="javascript:exportDOC()"><img src="gaowj/images/icons/(30,00).png" border="0"></a>
  <a href="#" title="导出 EXCEL" onclick="javascript:exportXLS()"><img src="gaowj/images/icons/(08,03).png" border="0"></a>
  <a href="report_listReportTabPreview?pageIndex=0&uuid=<%=uuid %>" title="首页"><img src="gaowj/images/icons/(23,46).png" border="0"></a>
  <a href="report_listReportTabPreview?pageIndex=<%=pageIndex - 1%>&uuid=<%=uuid %>" title="上一页"><img src="gaowj/images/icons/(11,41).png" border="0"></a>
  <a href="report_listReportTabPreview?pageIndex=<%=pageIndex + 1%>&uuid=<%=uuid %>" title="下一页"><img src="gaowj/images/icons/(08,41).png" border="0"></a>
  <a href="report_listReportTabPreview?pageIndex=<%=lastPageIndex%>&uuid=<%=uuid %>" title="末页"><img src="gaowj/images/icons/(32,01).png" border="0"></a>
</td></tr></table>
<table width="98%" cellpadding="0" cellspacing="0" border="0">
<tr>
 <td align="center">
 <%=sbuffer.toString()%>
 </td>
</tr>
</table>
<script type="text/javascript">
 function exportPDF(){
	 window.location = "report_exportPDF";
 }
 function exportDOC(){
	 window.location = "report_exportDOC";
 }
 function exportXLS(){
	 window.location = "report_exportXLS";
 }
</script>