我用的是ReportPro做的报表,现在怎么也打印不出来,我打开数据的方法是:
1
2dim conn
3Dim RS
4Dim sSQL
5Set conn = server.createobject("ADODB.connection")
6Conn.Open "Driver={Microsoft Access Driver (*.Mdb)};Dbq=" & Server.Mappath("contract.mdb")
7set RS = Server.CreateObject("adodb.RecordSet")
8sSQL = "Select * From goods"
9Rs.Open ssql, Conn, 3
请各位大侠帮帮!!
---------------------------------------------------------------
Rs.Open ssql, Conn, 1, 1
---------------------------------------------------------------
只是读的话:Rs.Open ssql, Conn,1,1
修改的话:Rs.Open ssql, Conn,1,3
---------------------------------------------------------------
1
2Dim RS,conn,sSQL
3Conn="Driver={Microsoft Access Driver (*.Mdb)};Dbq=" & Server.Mappath("contract.mdb")
4set RS = Server.CreateObject("adodb.RecordSet")
5sSQL = "Select * From goods"
6Rs.Open ssql, Conn,2,3
---------------------------------------------------------------
function printit()
{
if (confirm('确定打印吗?')) {
wb.execwb(6,6);
window.location.href="order_acc.asp?accid==id
&workope==name
&worktime=```
=worktime
1}
2}
3function printsetup(){
4// 打印页面设置
5wb.execwb(8,1);
6}
7function printpreview(){
8// 打印页面预览
9wb.execwb(7,1);
10}
11//function closeme(){
12// 关闭
13// wb.execwb(45,1);
14// }
![]() ![]() |
四.DeviceRect 与 LayoutRect 标记的动态自动添加:
前面我们说到,每个单独的打印页面都需要各自的 DeviceRect 与 LayoutRect 标记,那么,如果我们有 1000 个页面需要打印,是否就要在每个页面上重复繁琐的 Copy & Paste 操作?
答案是否定的,我们完全可以通过 JavaScript 脚本来完成这一繁琐的工作。
要实现 HTML 声明的动态创建,关键在于 <DIV> 标记的定义,下面是其定义规则。<DIV ID="devicecontainer"> ...... </DIV>
<DIV>与</DIV>之间,采用 insertAdjacentHTML() 方式,并主要利用了其 afterBegin 与 BeforeEnd 两个变量,现在我们将第一个页面"插入"到<DIV></DIV>之间:
devicecontainer.insertAdjacentHTML("afterBegin", newHTML);
具有继承属性的后续页面,调用 beforeEnd 变量:
devicecontainer.insertAdjacentHTML("beforeEnd", newHTML);
要装载 devicecontainer 页面,还需在 <Body>中添加:
<BODY ONLOAD="addFirstPage()">
现在我们在 JavaScript 中添加包含前面详细介绍的 LayoutRect 与 DeviceRect 元素,用到的命令是 addFirstPage() 。需要注意的是,newHTML 标记后使用的是双引号,而 LayoutRect 与 DeviceRect 标记后的变量使用单引号。如下:
function addFirstPage() {
newHTML = "<IE:DEVICERECT ID='devicerect1' MEDIA='print' CLASS='mystyle1'>";
newHTML += "<IE:LAYOUTRECT ID='layoutrect1' CONTENTSRC='2.html'" + "ONLAYOUTCOMPLETE='onPageComplete()' NEXTRECT='layoutrect2'" + "CLASS='contentstyle'/>";
newHTML += "</IE:DEVICERECT>";
devicecontainer.insertAdjacentHTML("afterBegin", newHTML); }
细心的读者一定会发现,LayoutRect 后出现了一个新的属性:LayoutRect:onLayoutComplete ,这个属性主要指定了 LayoutRect 停止响应的后续事件,如系统资源消耗殆尽而停止响应,或者 LayoutRect 指定的变量溢出。
好了,有了上面的原理,下面我们来编写具有自动"插入"功能的 JavaScript 代码: function onPageComplete() { if (event.contentOverflow) { newHTML = "<IE:DEVICERECT ID='devicerect" + (lastPage + 1) + "' MEDIA='print' CLASS='mystyle1'>";
newHTML += "<IE:LAYOUTRECT ID='layoutrect" + (lastPage + 1) + "' ONLAYOUTCOMPLETE='onPageComplete()' NEXTRECT='layoutrect" + (lastPage + 2) + "' CLASS='contentstyle'/>";
newHTML += "</IE:DEVICERECT>"; devicecontainer.insertAdjacentHTML("beforeEnd", newHTML); lastPage++; }
在上面的代码中,contentOverflow 代表的是由于页面信息过长,本页的 LayoutRect 停止响应,则直接跳到下一个页面,让 LayoutRect 重新定义下一个页面的版面;onPageComplete() 则不管页面是否过长,LayoutRect 是否停止响应,只要到了页面尾部则自动跳到下一页,这也是最常见的情况。
在编写本脚本时,关键处在于保持清醒,不能让任意一个变量出错。其中,ID 不仅针对 DeviceRect 与 LayoutRect ,还为 NextRect 所引用,页面指向不能出错;当前页面的页码应该是 lastPage+1 ,下一个页面的页码应该是 lastPage+2 ;NextRect 标记需要下一个页面的 LayoutRect 属性支持,因此它的值应该为 "layoutRect"+(lastPage+2);打开第一个页面时,这个 LastPage 初始值为 1 。
---------------------------------------------------------------
下面是一段javascript打印程序:
function doprint()
{
var str="
1<html>\n<meta content="text/html; charset=utf-8" http-equiv="content-type"/>";
2var stat;
3var strNextPageBegin="<!--Next_Page_Begin-->";
4var strNextPageEnd="<!--Next_Page_End-->";
5var strTmp;
6
7str += '<meta content="text/html; charset=utf-8" http-equiv="content-type"/>';
8str += '<title>'+document.title+'</title>';
9str += "<body bgcolor="#ffffff" leftmargin="5" marginheight="5" marginwidth="5" onload="window.print();" topmargin="5">";
10str += '<center><table bgcolor="#ffffff" border="0" cellpadding="0" cellspacing="20" width="700"><tr><td height="10"> </td><td>';
11
12stat = document.getElementById('stat').innerHTML;
13if(stat.indexOf(strNextPageBegin)!=-1)
14{
15str +=stat.substr(0,stat.indexOf(strNextPageBegin));
16strTmp=stat.substr(stat.indexOf(strNextPageEnd)+strNextPageEnd.length, stat.length);
17}
18else
19{
20strTmp=stat;
21}
22str += strTmp;
23
24
25str += "</td></tr></table></center>";
26str += "</body></html>
";
document.write(str);
document.close();
}
页面调用:
1<td align="center" height="10" valign="middle" width="309"><a class="A" href="javascript:doprint();">打印</a></td>