报表打印控件wsReport4.6 

解决方案 »

  1.   

    vs2005自带的水晶报表是什么版本的,支持activex打印吗?
      

  2.   

    直接用table或div就可,关键是绝对定位.要详细调试.
      

  3.   

    cpp2017(慕白兄) hb_gx(高升)能不能给个参考的例子,这种模式是用IE本身的打印功能实现吗?
      

  4.   

    lambober(星之劫) 你也说应该是写绝对位置。绝对位置的概念是什么,3位兄才能否给个小例子参考一下
      

  5.   

    我就曾经每天拿把尺子量边距,这是最简单廉价的方法了。也是使用DIV.
      

  6.   

    用excel作为套票模板行列坐标就很好定位了(例如c1,c2。)
     Dim strOpenFile,strSaveFile  as String 
     Dim xlsApp As New Excel.Application
     Dim xlsWorkBook As Excel.Workbook
     Dim xlsSheet As Excel.Worksheet
     Dim xlsRange As Excel.Range
     Dim xlsSrcRange As Excel.Range strOpenFile = Server.MapPath("..\ReportFormat\test.xls")
            strSaveFile = Server.MapPath("..\filetemp\testtarget.xls")
            xlsApp.Application.DisplayAlerts = False
            xlsApp.Visible = False        '打开格式文件
            xlsWorkBook = xlsApp.Workbooks.Open(strOpenFile)
            xlsSheet = xlsWorkBook.Sheets(1)
            '根据需要的sheet数拷贝格式
            xlsSheet.Copy(, xlsWorkBook.Sheets(1))
            '获取需要填入数据的sheet
            xlsSheet = xlsWorkBook.Sheets(1)
            '选择拷贝源的行的下一行
            xlsRange = xlsSheet.Rows(3)
            '插入一行
            xlsRange.Insert()
            xlsRange.Insert()
            '选择拷贝源
            xlsSrcRange = xlsSheet.Rows(2)
            '把源拷贝到刚插入的行
            xlsSrcRange.Copy(xlsSheet.Rows(3))
            xlsSrcRange.Copy(xlsSheet.Rows(4))        '进行数据填充,实际代码根据记录数使用循环
            xlsSheet.Cells(2, 1) = "A"
            xlsSheet.Cells(2, 2) = 300
            xlsSheet.Cells(3, 1) = "B"
            xlsSheet.Cells(3, 2) = 400
            xlsSheet.Cells(4, 1) = "C"
            xlsSheet.Cells(4, 2) = 500        'sheet重命名
            xlsSheet = xlsWorkBook.Sheets(1)
            xlsSheet.Name = "200501"
            xlsSheet = xlsWorkBook.Sheets(2)
            xlsSheet.Name = "200502"
            '另存为结果表
            xlsWorkBook.SaveAs(strSaveFile)
            '关闭
            xlsWorkBook.Close()
            xlsApp.Quit()
            xlsApp = Nothing
            xlsWorkBook = Nothing
            xlsSheet = Nothing
            xlsRange = Nothing
            xlsSrcRange = Nothing
            GC.Collect()
      

  7.   

    如果不保存文件,只是打印的话        '进行数据填充,实际代码根据记录数使用循环
            xlsSheet.Cells(2, 1) = "A"
            xlsSheet.Cells(2, 2) = 300
            xlsSheet.Cells(3, 1) = "B"
            xlsSheet.Cells(3, 2) = 400
            xlsSheet.Cells(4, 1) = "C"
            xlsSheet.Cells(4, 2) = 500填充之后就可以直接打印了
      

  8.   

    <html>
    <head>
    <meta name=vs_targetSchema content="http://schemas.microsoft.com/intellisense/ie5">
    <title>***上海市眼病防治中心病人结帐费用报表***</title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <!--media=print 这个属性可以在打印时有效-->
    <style media=print>
    .Noprint{display:none;}
    .PageNext{page-break-after: always;}
    </style>
    <style>
    body,td,th 
    {
    font-size: 12px;
    }
    .tdp
    {
        border-bottom: 1 solid #000000;
        border-left:  1 solid #000000;
        border-right:  0 solid #ffffff;
        border-top: 0 solid #ffffff;
    }
    .tabp
    {
        border-color: #000000; border-collapse:collapse;
    }
    .NOPRINT {
    font-family: "宋体";
    font-size: 12px;
    }</style></head><body >
      <OBJECT  id=WebBrowser  classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2  height=0  width=0 VIEWASTEXT>
      </OBJECT>
    <input type=button value=打印     onclick="document.all.WebBrowser.ExecWB(6,1)" class="NOPRINT">
    <input type=button value=直接打印 onclick="document.all.WebBrowser.ExecWB(6,6)" class="NOPRINT">
    <input type=button value=页面设置 onclick="document.all.WebBrowser.ExecWB(8,1)" class="NOPRINT">
    <input type=button value=打印预览 onclick="document.all.WebBrowser.ExecWB(7,1)" class="NOPRINT">
      <br/>
    <table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr align="center"> 
        <td colspan="5"><font size="3">上海市眼病防治中心病人结帐费用报表(A) </font></td>
      </tr>
      <tr> 
        <td>汇总人次 5</td>
        <td>费用合计 15853.12</td>
        <td>统计日期 </td>
        <td>制表人 023</td>
        <td>制表日期:2004-05-13</td>
      </tr>
    </table><table width="90%" border="1" align="center" cellpadding="2" cellspacing="0" bordercolor="#000000"  class="tabp">
      <tr> 
        <td   >姓名</td>
        <td   >住院号</td>
        <td   >科室</td>
        <td   >结帐日期</td>
        <td   >出院日期</td>
        <td   >费用合计</td>
        <td   >医保交易费用</td>
        <td   >分类给付费用</td>
        <td   >非医保交易费</td>
        <td   >&nbsp;</td>
        <td   >&nbsp;</td>
        <td   >&nbsp;</td>
        <td   >&nbsp;</td>
        <td   >&nbsp;</td>
        <td   >&nbsp;</td>  </tr>
      <tr>
        <td   >&nbsp;</td>
        <td   >&nbsp;</td>
        <td   >&nbsp;</td>
        <td   >&nbsp;</td>
        <td   >&nbsp;</td>
        <td   >&nbsp;</td>
        <td   >&nbsp;</td>
        <td   >&nbsp;</td>
        <td   >&nbsp;</td>
        <td   >&nbsp;</td>
        <td   >&nbsp;</td>
        <td   >&nbsp;</td>
        <td   >&nbsp;</td>
        <td   >&nbsp;</td>  </tr>
    </table>
    <hr align="center" width="90%" size="1" noshade class="NOPRINT" >
    <!--分页-->
    <div class="PageNext"></div>
    <table width="90%" border="1" align="center" cellpadding="2" cellspacing="0" bordercolor="#000000"  class="tabp">
      <tr>
        <td >第2页</td>
      </tr>
      <tr>
        <td >看到分页了吧</td>
      </tr>
      <tr>
        <td >&nbsp;</td>
      </tr>
      <tr>
        <td >&nbsp;</td>
      </tr>
      <tr>
        <td ><table width="100%"  border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="50%" >这样的报表
                  对一般的要求就够了。</td>
              <td>&nbsp;</td>
            </tr>
        </table></td>
      </tr>
    </table>
    </body>
    </html>
      

  9.   


    //使用DIV。参考:
    <HTML>
    <HEAD>
    <title>打印行程单</title>
    <style type="text/css"> .STYLE1 { COLOR: #ff0000 } </style>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <!--media=print 这个属性可以在打印时有效-->
    <style media="print"> .Noprint { DISPLAY: none }  
    .PageNext { PAGE-BREAK-AFTER: always } </style><script>//按钮事件
    var directPrint = function(){
    pagesetup_null();
    var   div   =document.getElementById("wsp");
        var   div1   =document.getElementById("pt");
        div.style.display="";
        div1.style.display="none";
    document.all.WebBrowser.ExecWB(6,6);
    div.style.display="none";
        div1.style.display="";
    }//设置网页打印的页眉页脚为空
    function pagesetup_null(){         
    var  hkey_root,hkey_path,hkey_key;
    hkey_root="HKEY_CURRENT_USER"
    hkey_path="\\Software\\Microsoft\\Internet Explorer\\PageSetup\\";
    try{
                       var RegWsh = new ActiveXObject("WScript.Shell");
                      hkey_key="header";
                     RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"");
                     hkey_key="footer";
                     RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"");
             }catch(e){}
    }
    function Valid()
    {
        if(document.getElementById(<%="'" + this.TextBox1.ClientID + "'"%>).value=="")
        {
            alert("电子客票号码不能为空!");
            return false;
        }
        
        return true;
    }function Valid1()
    {
        if(document.getElementById(<%="'" + this.TextBox1.ClientID + "'"%>).value=="")
        {
            alert("电子客票号码不能为空!");
            return false;
        }
        return true;
    }
    </script>
    </HEAD>
    <body>
    <form id="WebPrint" method="post" runat="server">
    <table class="Noprint" width="98%" border="0" height=25  bordercolor="#000033" style="WIDTH:780px;">
    <tr >
       <td width=90 style="font-size: 9pt">电子客票号码:</td>
    <td width=90 style="font-size: 9pt"><asp:DropDownList ID="TextBox1" Height=25  width=125  runat="server" AutoPostBack="True" OnSelectedIndexChanged="TextBox1_SelectedIndexChanged"></asp:DropDownList></td>

    <td> &nbsp;<asp:Button ID="LinkButton1" runat="server" OnClick="LinkButton1_Click1" Width=90 style="font-size: 9pt" Text="创建行程单信息" ></asp:Button>
    &nbsp;&nbsp;<asp:Button ID="LinkButton2" runat="server" OnClick="LinkButton2_Click1" Width=80 style="font-size: 9pt" Text="作废行程单" OnClientClick="return confirm('您确定要取消行程单吗?')"></asp:Button>
           &nbsp;&nbsp; <input type=button name="打印" value="打印" style="font-size: 9pt; min-width:15px; min-height:10px"  onclick="directPrint()" id="Button1" />
        </td>
        <td>
                             <OBJECT id=WebBrowser classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 width=0> 
                            </OBJECT> 
        </td>
        <td width=200></td>
    </tr>
    </table>

    <div id="wsp" style="display:none">
    <table id="Table4" width="730" height="280" border="0" cellpadding="5" cellspacing="5">
    <tr>
      <td width="931">
    <div id="Div1" style="Z-INDEX:101;font-size:12pt;LEFT:441px;WIDTH:272px; POSITION:absolute; TOP:11px; HEIGHT:20px"
    align="left" ><%=Vise%></div>
    <div id="Div6" style="Z-INDEX:110;font-size:12pt;LEFT:80px; WIDTH:136px; POSITION:absolute; TOP:223px; HEIGHT:20px"
    align="left"><%=Tel%></div>
    <table ID="Table5" width="98%" cellpadding="3" align="LEFT" style="Z-INDEX:100;font-size:12pt; LEFT:53px; WIDTH:690px; POSITION:absolute; TOP:65px">
    <%=Text%>     </table> <div id="Div7" style="Z-INDEX:113; LEFT:80px; font-size:12pt; font-family:WIDTH:120px; POSITION:absolute; TOP:248px; HEIGHT:20px; width: 119px;"
    align="left"><%=Code%></div>
    <div id="Div8" style="Z-INDEX:112; LEFT:272px;font-size:12pt; WIDTH:296px; POSITION:absolute; TOP:254px; HEIGHT:20px"
    align="left"><%=Company%></div>
        <div id="Div9" align="left" style="Z-INDEX:106; font-size:12pt;LEFT:690px; WIDTH:55px; POSITION:absolute; TOP:228px; HEIGHT:20px"><%=Safety%></div>
    <div id="Div10" align="left" style="Z-INDEX:101;font-size:12pt; LEFT:201px; WIDTH:203px; POSITION:absolute; TOP:11px; HEIGHT:20px;"><%=Idec%></div>
    <div id="Div11" style="Z-INDEX:111; LEFT:256px; font-size:12pt;WIDTH:67px; POSITION:absolute; TOP:221px; HEIGHT:19px"
    align="left"><%=Verify%></div>
    <div id="Div12" align="left" style="Z-INDEX:101;font-size:12pt; LEFT:21px; WIDTH:183px; POSITION:absolute; TOP:11px; HEIGHT:20px"><%=Name%></div>
    <div id="Div13" align="left" style="Z-INDEX:107;font-size:12pt; LEFT:416px; WIDTH:200px; POSITION:absolute; TOP:221px; HEIGHT:20px"><%=Kep%></div>
    <div id="Div14" align="left" style="Z-INDEX:108; font-size:12pt;LEFT:632px; WIDTH:96px; POSITION:absolute; TOP:254px; HEIGHT:20px"><%=Date%></div>
    <table width="98%" align="center" style="Z-INDEX:103; LEFT:164px; WIDTH:556px; POSITION:absolute; TOP:197px; HEIGHT:21px"
    ID="Table6">
    <tr>
      <td width="100" align="left" height="20" style="font-size: 12pt"><%=Fare%></td>
      <td width="100" height="20" align="left" style="font-size: 12pt"><%=JcFare%></td>
      <td height="20" width="108" align="left" style="font-size: 12pt"><%=RyFare%></td>
      <td height="20" width="94" align="left" style="font-size: 12pt"><%=Rest%></td>
      <td height="20" width="132" align="left" style="font-size: 12pt"><%=Total%></td>
    </tr>
    </table>
    <div id="Div15" align="center" style="Z-INDEX:105; LEFT:21px; WIDTH:88px;font-size: 12pt; POSITION:absolute; TOP:39px; HEIGHT:20px"><%=Pnr%></div>
        <div id="Div16" style="Z-INDEX:113; LEFT:79px; font-size:12pt;WIDTH:120px; POSITION:absolute; TOP:267px; HEIGHT:20px"
    align="left"><%=Hxh%></div></td>
    </tr>
    </table>
    </div> </form>
    </body>
    </HTML>