Various scheme references printed in Rdiframework.net━web-Welcome supplement

Source: Internet
Author: User

  Various scheme references printed in Rdiframework.net━web-Welcome supplement

  

Web development of the comrades should have a deep understanding, in the Web program printing is no longer as easy to control in the application, Web programs inherent in some of the characteristics of this disadvantage, such as: The printer is local, and the file may be on the server, how the format control and customization, and so on, has brought a lot of problems in our development, Of course, there are problems will be people to study the solution, here I first on the current popular several ways to do a brief introduction:

First, IE direct printing  

This does not have to be said, directly call the Window.print or Webrower control of the EXECWB method to print. Quick and easy, the client does not need any settings. Using some methods can also achieve simple customization, such as a template HTM file, and then dynamically create a hidden frame in JS, with the script to generate the data, and then the final result file written to the hidden frame printing processing. If handled well, actually the effect is good, for simple printing needs should be enough. For example, the following implementation, we want to print to-do tasks, as shown in:

The user clicks the Print button to eject the print effect, as shown in:

Achieving the above results is very simple, which is very useful for simple, low-demand printing. The implementation is as follows, first we need to set a range we want to print, such as the following code: 

<!--startprint-->  <table id= "list" ></table>     <!--endprint-->
The above id=list is the area of our data display, so that when the user clicks it, they can print the data in this range and print the code as follows:

$ (' #btnPrint '). Click (       function Preview () {           var bdhtml = Window.document.body.innerHTML;           var sprnstr = "<!--startprint-->";           var eprnstr = "<!--endprint-->";           var prnhtml = Bdhtml.substr (Bdhtml.indexof (SPRNSTR) + +);           prnhtml = prnhtml.substring (0, Prnhtml.indexof (eprnstr));           Window.document.body.innerHTML = prnhtml;           Window.print ();           Window.history.go (0);       });
Second, use the Crystal Report to do printing support

 Crystal Report I believe in doing. NET development of friends have heard, Crystal Reports have many advantages, such as: Rapid report development, can be exported as a complex interactive chart, can be used with other controls in WebForm, able to dynamically export the report into a. Pdf,.doc,xls,html,rtf and many other formats. How to make Crystal report online there are many articles available for reference, here is not introduced. Below we use the Crystal Report to do the printing implementation. As below, we want to print the product management data as shown in:

 We can print the Product Management report as shown in click Print:

The code is very simple, first to make a good crystal report (the data source of the report can be a DataTable, can also be an entity), how to make reference to the relevant articles, many online. After making, create a new WebForm page, add crystalreportviewer to the page, and then specify its corresponding report, plus the following code, a simple report is completed.

protected void Page_Load (object sender, EventArgs e)        {            if (! Page.IsPostBack)            {                datatable dtreportdata = new DataTable ("Dsproductinfo");                Idbprovider Dbprovider = Dbfactoryprovider.getprovider (systeminfo.rdiframeworkdbconection);                Dtreportdata =dbprovider.fill ("Select TOP productcode,productname,productmodel,productstandard,productunit, Productprice,productdescription from "+case_productinfotable.tablename";                ReportDataSource rds = new ReportDataSource ("Dtcaseproductinfo", dtreportdata);                ReportViewer1.LocalReport.DataSources.Clear ();                REPORTVIEWER1.LOCALREPORT.DATASOURCES.ADD (RDS);                ReportViewer1.LocalReport.Refresh ();            }        }
Third, use Jqprint to print

 Jqprint, a jquery plugin jqprint that implements page printing by clicking the page button. The use of Jqprint is very simple, but better than the method we introduced, a bit more professional. To use Jqprint, first refer to the corresponding JS file.

<script language= "javascript" src= "jquery-1.4.4.min.js" ></script><script language= "JavaScript" src= "Jquery.jqprint-0.3.js" ></script>
For example, we want to print the following HTML:
<div id= "ddd" >    <table>        <tr>            <td>test</td>            <td>test</td >            <td>test</td>            <td>test</td>            <td>test</td>        </tr>    </table></div>
just call this line of code to implement:

$ ("#ddd"). Jqprint ();

If you need to use Jqprint, you can download it here and click Download.

Below we print a more complex, printed list of characters, with the results as follows:  

Click the Print button to print the effect as shown:

Iv. Other methods

1. We can print using the export Excel or PDF method.

2. Print using commercial print controls, such as the grid++ report control.

3. LODOP print control.

  4, this article is only a contribution to the role, welcome you to add.

Erichu Source: http://blog.csdn.net/chinahuyongEmail: [Email protected]qq exchange: 406590790 QQ Group: 237326100 Platform Blog: "CSDN"/HTTP/ Blog.csdn.net/chinahuyong         "Cnblogs" Http://www.cnblogs.com/huyong about senior engineer, information System Project Manager, DBA. Focus on Microsoft Platform Project architecture, management and enterprise solutions, multi-year project development and management experience, has organized and developed several large projects, proficient in dotnet,db (SQL Server, Oracle, etc.) technology. Familiar with Java, DELHPI and Linux operating system, have solid network knowledge. has some attainments in object-oriented, service-oriented and database fields. Currently engaged in DB management and development, WinForm, WCF, WebService, Web page Data capture and ASP, such as project management, development, architecture and other work. If you have any questions or suggestions, please enlighten me! This article is copyright to the author and Cnblogs blog, welcome to reprint, but without the author's consent must retain this paragraph statement, and in the article page obvious location to the original connection, if there is a problem, you can contact me by email or QQ, thank you very much.

Various scheme references printed in Rdiframework.net━web-Welcome supplement

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.