jsp打印表格方法

<%@ page contentType="text/html; charset=GBK" %>
<%@ page language="java" import="java.util.*"%>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head> 
    <title>配水交接单</title> 
  </head> 

//注意这个对象

<OBJECT id=wb height=0 width=0
classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 name=wb></OBJECT>

//打印函数

<script language="JavaScript">
 function printit()
 {
 if (confirm('确定打印吗?')) {

/**不打印按钮*/
  var cen = document.getElementById("sheet");
  cen.innerHTML = '';

/**执行打印*/
  wb.execwb(6,6)
  }
 }

</script>

<body>

<center>

<table>

 <tr>
    <td height="26">车次日期:</td>
    <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
   <td height="24">客运段:</td>
    <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
    </tr>

.........
  <tr>
    <td height="24">车长姓名:</td>
    <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
    <td>乘务员组号:</td>
    <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
  </tr>

......
    <tr>
    <td>实际数量(瓶):</td>
    <td>&nbsp;&nbsp;&nbsp;</td>
    <td height="25">配送人:(CRE)</td>
    <td>&nbsp;&nbsp;&nbsp;</td>
  
</table>
<center id="sheet">
<table>
 <tr>
  <td><input type="button" onclick=javascript:printit()  value="打印" class="input2" /><td>
 </tr>
</table>
</center>
</form>
<center>

</center>
</body>

</html>

 

你可能感兴趣的:(JavaScript,html,jsp,String,table,Path)