⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 reporttemplate.htm

📁 报表打印例子报表打印例子报表打印例子报表打印例子报表打印例子
💻 HTM
字号:
<html>
<head>
	<link href="component.css" rel="stylesheet" type="text/css">
	<link href="printExport.css" rel="stylesheet" type="text/css">
	<link href="print.css" rel="stylesheet" type="text/css">
	<script src="SigmaBase.js"></script>
	<script src="ReportPrinter.js"></script>

	<STYLE MEDIA="PRINT">    
		 .noprint{display:none;}
	</STYLE>
	<STYLE MEDIA="SCREEN">    
		.noprint {display:block;}
	</STYLE>
	<script language="javascript">
		var print = null;
		var paperTypes = {
			A4:{name:"A4",width:210,height:297},
			hrsoft:{name:"hrsoft",width:218,height:140}
		};

		function Preview(){
			if (print.defaultPrinterName.length==0){
				alert("请先安装打印机,再执行此功能!");
				return;
			}
			print.InitPrint();
			print.companyName = "杭州慧软网络科技有限公司";
			print.seriesNo = "9325-9332-4763-1185" ; 
			setParameters();
			print.Preview();
		}

		function Print(){  
			if (print.defaultPrinterName.length==0){
				alert("请先安装打印机,再执行此功能!");
				return;
			}
			print.InitPrint();
			print.companyName = "杭州慧软网络科技有限公司";
			print.seriesNo = "9325-9332-4763-1185" ;
			setParameters();
			print.Print();
		}

		function setParameters(){
			print.SetMarginMeasure(1);
			print.paperSize = printCall.params.paperSize;
			print.orientation = printCall.params.orientation;
			if(print.orientation==1){
				print.pageHeight = printCall.params.pageHeight;
				print.pageWidth = printCall.params.pageWidth;
			}else{
				print.pageHeight = printCall.params.pageWidth;
				print.pageWidth = printCall.params.pageHeight;
			}
			
			print.marginLeft =	printCall.params.marginLeft;
			print.marginTop = printCall.params.marginTop;
			print.marginRight=	printCall.params.marginRight;
			print.marginBottom=	printCall.params.marginBottom;
			
		}

		var printCall = null;
		var columnNames = null;
		window.onload = function(){
			
			measurePxPerMM();
			print = document.all.eprint;
			printCall = window.opener.printer;
			initParams();
			var painter = new ReportPainter(printCall);
			painter.paint(document.getElementById("reportPane"));
			document.body.onclick=function(){
				//alert(event.clientY+document.body.scrollTop);
			}

		}

		function measurePxPerMM(){
			var px = document.getElementById("tt").offsetWidth;
			pxPerMM = px/100;
			document.getElementById("tt").removeNode(true);
		}

		function initParams(){
			if(printCall.params.paperSize == null || printCall.params.paperSize == ""){
				printCall.params.paperSize = "A4";
			}

			printCall.params.pageWidth =  paperTypes[printCall.params.paperSize].width;
			printCall.params.pageHeight =  paperTypes[printCall.params.paperSize].height;

			if(printCall.params.marginTop == null || printCall.params.marginTop == ""){
				printCall.params.marginTop = "5";
			}
			if(printCall.params.marginLeft == null || printCall.params.marginLeft == ""){
				printCall.params.marginLeft = "5";
			}
			if(printCall.params.marginRight == null || printCall.params.marginRight == ""){
				printCall.params.marginRight = "5";
			}
			if(printCall.params.marginBottom == null || printCall.params.marginBottom == ""){
				printCall.params.marginBottom = "5";
			}
			if(printCall.params.orientation == null || printCall.params.orientation == ""){
				printCall.params.orientation = 1;
			}
			
		}

		function PrintSet(){			
			document.all.marginT.value = printCall.params.marginTop;
			document.all.marginB.value = printCall.params.marginBottom;
			document.all.marginR.value = printCall.params.marginRight;
			document.all.marginL.value = printCall.params.marginLeft;

			var ops = document.all.pType.options;
			document.all.pType.selectedIndex = 0;
			for(var i=0;i<ops.length;i++){
				if(ops[i].value == printCall.params.paperSize){
					document.all.pType.selectedIndex = i;
				}
			}
			var orientations = document.getElementsByName("orientation");
			for(var i=0;i<orientations.length;i++){
				if(orientations[i].value == ""+printCall.params.orientation){
					orientations[i].checked = true;
				}
			}

			
			document.all.paramsView.style.display="";
			//可打印列设置
			var columns = printCall.columns;
			if(columns==null || columns.length<1)
				return ;
			var colsset = document.all.colsSet;
			colsset.innerHTML = "打印列设置:<br>";
			for(var i=0;i<columns.length;i++){
				var div = document.createElement("<div style='width:120px;float:left;'>");
				var input = null;
				if(columns[i]._printAble==true || columns[i]._printAble==null)
					input = document.createElement("<input type='checkbox' checked name='print_column' value='"+columns[i].name+"'>");
				else{
					input = document.createElement("<input type='checkbox' name='print_column' value='"+columns[i].name+"'>");
				}
				div.appendChild(input);
				var text = document.createTextNode(columns[i].caption+"");
				
				div.appendChild(text);
				colsset.appendChild(div);
			}
		}

		function getColumnByName(columns,name){
			if(columns==null)
				return null;
			for(var i=0;i<columns.length;i++){
				var col = columns[i];
				if(col.name == name){
					return col;
				}
			}
			return null;
		}

		function applySet(){
			document.all.paramsView.style.display="none";
			var pType = document.all.pType.options[document.all.pType.selectedIndex].value;
			printCall.params.paperSize = pType;
			printCall.params.pageWidth =  paperTypes[printCall.params.paperSize].width;
			printCall.params.pageHeight =  paperTypes[printCall.params.paperSize].height;

			var orientations = document.getElementsByName("orientation");
			for(var i=0;i<orientations.length;i++){
				if(orientations[i].checked){
					printCall.params.orientation = orientations[i].value;
				}
			}

			
			var printcolumns = document.getElementsByName("print_column");			
			for(var i=0;i<printcolumns.length;i++){
				var col = getColumnByName(printCall.columns,printcolumns[i].value);
				if(printcolumns[i].checked==true){
					col._printAble = true;
				}else{
					col._printAble = false;
				}
			}
			printCall.params.marginLeft = document.all.marginL.value;
			printCall.params.marginTop = document.all.marginT.value;
			printCall.params.marginRight = document.all.marginR.value;
			printCall.params.marginBottom = document.all.marginB.value;

			document.getElementById("reportPane").innerHTML = "";
			var painter = new ReportPainter(printCall);
			painter.paint(document.getElementById("reportPane"));

		}

		
	
	</script>
	<title>打印</title>
</head>
	
<body style="margin:0">

<div class="noprint">
	<object id=eprint classid="clsid:CA03A5A8-9890-49BE-BA4A-8C524EB06441" codebase="eprint.cab#Version=3,0,0,6" viewasext VIEWASTEXT> </object>
	<p>
	<input type="button" value="打印预览" onclick="Preview()"/>
	<input type="button" value=" 打  印 " onclick="Print()"/>
	<input type="button" value="打印设置" onclick="PrintSet()"/>

	<div id="paramsView" style="height:180px;border:1 solid blue;display:none;font-size:14px;margin-left:20px;">	
		<div style="float:left;width:35%;">
			<div style="padding:5px;">
				纸张:
				<select id="pType">
					<option value="A4">A4</option>
					<option value="hrsoft">hrsoft</option>
				</select>
			</div>
			<div style="padding:5px;">
				方向:
				<input type="radio" name="orientation" value="1"/>纵向&nbsp;&nbsp;&nbsp;&nbsp;
				<input type="radio" name="orientation" value="2"/>横向
			</div>
			<div style="padding:5px;">
				页边距(毫米):
				<table style="font-size:14px;">
					<tr>
						<td>
							上:<input type="text" id="marginT" value="5" size="5">
						</td>
						<td>
							下:<input type="text" id="marginB" value="5" size="5">
						</td>
					</tr>
					<tr>
						<td>
							左:<input type="text" id="marginL" value="5" size="5">
						</td>
						<td>
							右:<input type="text" id="marginR" value="5" size="5">
						</td>
					</tr>
				</table>
			</div>
		</div>
		<div style="float:left; width:5px;"></div>
		<div id="colsSet" style="float:left;width:60%;">

		</div>
		<div style="height:30px;padding:4px;float:left;text-align:center;width:90%;">&nbsp;
			<button onclick="applySet();">确定</button>
		</div>
	</div>
</div>

<div id="tt" style="position:absolute;left:1;width:100mm;border:1 solid red;">正在生成打印页面.. </div>

<center>
<div id="reportPane" class="report">
</div>
</center>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -