Transfer from:
http://blog.9cbs.net/luandao2000/archive/2005/01/18/257840.aspx
ASP.NET Web Print - Ultimate Solution
Comrades who have done BS development should be deeply appreciated. In the web program, it is not easy to control in the application, and some of the natural features of the Web program have caused this shortcoming, such as: The printer is locally, and the file is indeed On the server; how to control and customize the format. They have brought a lot of problems to our development, although there are controls such as crystal reports to solve but are inconvenient. Of course, there is a problem, there will be some people to study, here I will first introduce the current ways to present:
1, IE directly print
This doesn't have to say more, call the Window.Print or the ExecwB method of the WebRower control to print. Convenient and fast, the client does not need any settings. With some ways, you can achieve simple customization, such as a template HTM file, then dynamically create a hidden frame in JS, with the script to generate the data, and write the last result file to the hidden frame printing process. If the processing is good, it is actually good. It should be enough for simple print demand. Here I am in the actual example to illustrate this way: the development often needs to print some statistics to the user, such as a common function is printing: Operator first enters the query condition, then submit a query As a result, click Print to print the report according to the well-defined format. Most of us implement the results of the query to DataGrid, then print the DataGrid. In this case, print is generally fixed in the format, and it will not be changed again after it is determined. So you can print directly, but if you call Window.Print to print the page, other elements on the page will also be printed, the format of the page header page is not well controlled.
2, ACTIVEX control
Develop controls themselves. In this way, many commercial software use this way, it has not been used after the control is written in the Web, and is used in the application. The printing method is very flexible, and the WEB that is basically programmed can also be done. But the client needs to install components, and deploy is not very convenient.
3, .NET Components Lu Yan wrote a good article "Using XML to realize General Web Report Print", I believe everyone has seen it. The idea is novel, and it is simple. It is indeed a general Web print solution, especially using XML to describe the print file. The expansion of the future format is a good interface, which is very easy to expand. This printing method is very suitable for applications where the format changes, and the amount of data is very suitable. This idea also gives a new idea to print on ASP.NET: Customize some components to implement flexible printing. Of course, the shortcomings are also obvious: 1. Require client installation NET Framework1.0 components. 2, XML's resolution, if the file is not very ideal. 3. There is a significant delay when the page is loaded.
Late entries, continue to write tomorrow