• lodop分页,页眉页脚,foreach分页代码


    <!-- 
    本例是一个表格的打印
    说明:
    1、使用object对象来注册一个打印控件
    2、使用document.getElementById获取到打印控件,使用CheckLodop检查是否安装打印控件,检验版本
    3、使用c:forEach标签来遍历数据,使用EL来读取属性
    4、使用table来展现数据,使用到了thead、tfoot、tbody,主要是用于分页打印,这里设置每10行记录打印一页
    5、使用fmt:formatNumber将数值格式化为2位精度
    
     -->
    <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
    <%@ page isELIgnored="false" %>
    <%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
    <!DOCTYPE html>
    <html>
    
    	<head>
    		<title>打印测试</title>
    		<meta http-equiv="pragma" content="no-cache">
    		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    		<style type="text/css">
    </style>
    <%-- <script type="text/javascript" src="${pageContext.request.contextPath}/lodop/LodopFuncs.js"></script> --%>
    	</head>
    	<!-- 设置一个常量WebRoot,保存当前应用的contextpath -->
    	<script type="text/javascript">
    		var WebRoot = '${pageContext.request.contextPath}';
    	</script>
    	<!-- 注册一个Lodop控件 -->
    	
    <script type="text/javascript">
    	var LODOP = document.getElementById("LODOP");//这行语句是为了符合DTD规范
    	var LODOP=getLodop(document.getElementById('LODOP'),document.getElementById('LODOP_EM'));
    	//CheckLodop();
    	function create(printodiv) {  
    		//LODOP.PRINT_INIT("simple_form");
    		//假设我们使用A4纸张打印 A4=21cm * 29.7cm
    		//页边距我们设置为 1cm (top、left、right、bottom)
    		//width =21-1*2 =21-2=19
    		//height =29.7-1*2=29.7-2=27.7cm
            //LODOP.ADD_PRINT_HTM('1cm','1cm','19cm','27.7cm', printodiv.innerHTML);
    		//LODOP.ADD_PRINT_HTM('1cm', '1cm', '19cm', '27.7cm', document.getElementById(printodiv).innerHTML); //A4纸  纵
    		LODOP.SET_PRINT_PAGESIZE(2, 0, 0, "A4");
            LODOP.ADD_PRINT_TEXT('20', '420','600', '50', "换房统计表");
            LODOP.SET_PRINT_STYLEA(1, "ItemType", 1);
            LODOP.SET_PRINT_STYLEA(1, "FontSize", 14);
            LODOP.SET_PRINT_STYLEA(1, "Bold", 1);
            LODOP.ADD_PRINT_TEXT('730','660','200','22', "第#页/共&页");
            LODOP.SET_PRINT_STYLEA(2, "ItemType", 2);
            LODOP.SET_PRINT_STYLEA(2, "HOrient", 1);
            LODOP.ADD_PRINT_TABLE('50', '45', '500', '540', document.getElementById(printodiv).innerHTML);
    	}
    	function preview() {
    		create("from_div");
    		LODOP.PREVIEW();  //预览
    	}
    	function print(){
    		create("from_div");
    		LODOP.PRINT();
    	}
    </script> 
    </script>
    	<body>
    	     <form>
    			<div>
    				<a href="javascript:print();">打印</a>
    			    <a href="javascript:preview();">预览</a>
    				<a href="javascript:window.history.back();">返回</a>
    			</div>
    			<div id="from_div" align="center">
    				<table style="border-color: black; border-collapse: collapse; border- 1px; font-size: 20" border="1"
    					cellspacing="0" cellpadding="0" width="1000" align="center">
    						<!-- <tr>
    							<td colspan="15" align="center"><span style="font-size:14;font-family:宋体;" >换房统计表</span></td>
    						</tr> -->
    						<tr>
    							<td height="20" width="30"><span style="font-size:14;font-family:宋体;">序号</span></td>
    							<td height="20" width="58"><span style="font-size:14;font-family:宋体;">	换房类型</span></td>
    							<td height="20" width="42" ><span style="font-size:14;font-family:宋体;">	姓名</span></td>
    							<td height="20" width="45"><span style="font-size:14;font-family:宋体;">	原房号</span></td>
    							<td height="20" width="65"><span style="font-size:14;font-family:宋体;">	原房类</span></td>
    							<td height="20" width="30"><span style="font-size:14;font-family:宋体;">床位</span></td>
    							<td height="20" width="42"><span style="font-size:14;font-family:宋体;">	原房价</span></td>
    							<td height="20" width="48"><span style="font-size:14;font-family:宋体;">	服务费</span></td>
    							<td height="20" width="45"><span style="font-size:14;font-family:宋体;">	新房号</span></td>
    							<td height="20" width="65"><span style="font-size:14;font-family:宋体;">	新房类</span></td>
    							<td height="20" width="30"><span style="font-size:14;font-family:宋体;">床位</span></td>
    							<td height="20" width="42"><span style="font-size:14;font-family:宋体;">	新房价</span></td>
    							<td height="20" width="48"><span style="font-size:14;font-family:宋体;">	服务费</span></td>
    							<td height="20" width="115"><span style="font-size:14;font-family:宋体;">	换房日期</span></td>
    							<td height="20" width="160"><span style="font-size:14;font-family:宋体;">	换房原因</span></td>
    						</tr>
    						 <c:forEach items="${querylist}" var="s" varStatus="status">
    						 	<tr>
    						 		<td height="20" width="30" align="center"><span style="font-size:12;font-family:宋体;">${status.index+1}</td>  
    								<c:choose>
    									<c:when test="${s.changeroomType} == 1">
    									<td height="20" width="58"><span style="font-size:12;font-family:宋体;">换空房</span></td>
    									</c:when>
    									<c:otherwise><td height="20" width="58"><span style="font-size:12;font-family:宋体;">房间对换</span></td></c:otherwise>
    								</c:choose>
    								<td height="20" width="42" ><span style="font-size:12;font-family:宋体;">${s.nameBefore}</span></td>
    								<td height="20" width="45" align="center"><span style="font-size:12;font-family:宋体;">${s.zoneAndNum}</span></td>
    								<td height="20" width="65"><span style="font-size:12;font-family:宋体;">${s.roomtypeBefore}</span></td>
    								<td height="20" width="30" align="center"><span style="font-size:12;font-family:宋体;">${s.bednumBefore}</span></td>
    								<td height="20" width="42" align="right"><span style="font-size:12;font-family:宋体;">${s.rateBefore}</span></td>
    								<td height="20" width="48" align="right"><span style="font-size:12;font-family:宋体;">${s.servicechargeBefore}</span></td>
    								<td height="20" width="45" align="center"><span style="font-size:12;font-family:宋体;">${s.zoneAndNumNew}</span></td>
    								<td height="20" width="65"><span style="font-size:12;font-family:宋体;">${s.roomtypeNew}</span></td>
    								<td height="20" width="30" align="center"><span style="font-size:12;font-family:宋体;">${s.bednumNew}</span></td>
    								<td height="20" width="42" align="right"><span style="font-size:12;font-family:宋体;">${s.rateNew}</span></td>
    								<td height="20" width="48" align="right"><span style="font-size:12;font-family:宋体;">${s.servicechargeNew}</span></td>
    								<td height="20" width="115" align="center"><span style="font-size:12;font-family:宋体;">${s.changeroomDate}</span></td>
    								<td height="20" width="160"><span style="font-size:12;font-family:宋体;">${s.changeroomCause}</span></td>
    						 	</tr>
    						 </c:forEach>
    			</table>		
    			</div>
    		</form>
    	</body>
    </html>
    

      

  • 相关阅读:
    如何解压.bz2文件包
    Typecho中的gravatar头像无法加载
    整理的mysql优化内容
    PHP常用的一些正则表达式
    git log --stat常用命令
    Linux查找含有某字符串的所有文件
    linux下如何查看chm文件
    linux访问windows共享文件夹的方法
    typecho除了首页其他大部分网页404怎么办?
    Windows在当前目录打开cmd
  • 原文地址:https://www.cnblogs.com/xiehaoyu/p/5563974.html
Copyright © 2020-2023  润新知