zoukankan      html  css  js  c++  java
  • 打印表格

    1、在jsp中与table 标签 同层次添加iframe标签

    <iframe id='frmPrint'  width='0' height='0' frameborder='0'></iframe>
    <table border="1" cellpadding="0" cellspacing="0" class="dateLisTable">
    <thead style="background-color: #ebf5fc;">
    </thead>
    <tbody id="dataBody">
    </tbody>
    </table>
    

    2、js中将表格数据写入到弹出框中

    //打印功能
    	document.getElementById("frmPrint").contentWindow.document.body.innerText = ""; //iframe清空后在复制防止多次写入重复
    	 $(".dsdaochu01").attr("style","display:none;"); //隐藏打印导出按钮
    	var initData = document.getElementsByClassName("page")[0].innerHTML
    	var printData = document.getElementById("biao").innerHTML;// 获得
    	var printWindow=window.frames['frmPrint'];
    	printWindow.document.write(printData);//内容写到iframe中去
    	 $(".dsdaochu01").attr("style","display:true;"); 
    	//document.getElementsByClassName(".dsdaochu01").style.display = "block"; // 显示
    	
    	layer.open({
    		type : 1,
    		title: false,
    		fix : true,
    		shadeClose : true,
    		area : [ '100%', '100%' ],
    		closeBtn : 0,
    		content :'<div >' + printData + '</div>',
    		btn : ['打印','关闭'],
    		yes : function(index) {
    			printWindow.focus();
    			window.print(); // 开始打印
    		},
    		
    		success : function(layero) {
    			$('.layui-layer-btn').position('relative');
    
    			$('.layui-layer-btn')
    
    		}
    	});
    

    3、打印不全问题

    style="font-size:8px;height:100%;100%"  修饰表格

    <table border="1" cellpadding="0" cellspacing="0" class="dateLisTable" style="font-size:10px;100%" >
    </table>

    通过宽度高度,字体大小调整

    美好生活
  • 相关阅读:
    JNI接口的使用(简单版)
    Android内核剖析(1)
    Spring 和 Mybatis 整合
    AppStore被拒原因及总结
    iOS开发中,应用内直接跳转到Appstore
    ios 中生成二维码和相册中识别二维码
    IOS开发中(null)与<null>的处理
    融云即时通讯~~
    iOS中菊花。。。
    关于判断邮箱 手机号等一系列的正则表达式
  • 原文地址:https://www.cnblogs.com/ssbydk/p/9541351.html
Copyright © 2011-2022 走看看