Examples of using XML to implement common Web report printing in practical use

Source: Internet
Author: User
Tags format implement net version xsl
web|xml| Report Printing

Recently made a B/s project, in the printing of the use of IE embedded in the. NET WinForm control and XML combination of the way (see http://www.yesky.com/20030214/1652186.shtml), in the actual application process, there are some ideas, Share with you.
(i). format an XML file with a generic template
The system has used three kinds of documents, respectively, for the library list, warehousing orders, delivery orders, therefore, the definition of three template files, the format is as follows:
Chukudan.xsl:
<?xml version= "1.0" encoding= "GB2312"?>
<xsl:stylesheet version= "1.0" xmlns:xsl= "Http://www.w3.org/1999/XSL/Transform" >
<xsl:template match= "Bill" >
<root>
<pagesetting>
<landscape>false</landscape>
<paperkind>Custom</paperkind>
<paperwidth>800</paperwidth>
<paperheight>600</paperheight>
<paperleft>0</paperleft>
<paperight>0</paperight>
<papetop>0</papetop>
<papebottom>0</papebottom>
</pagesetting>
<reporttable>
<bill x= "y=" border= "0" bordercolor= "White" maxlines= "6" >
<xsl:for-each select= "Billmaster" >
<toptable width= "743" >
<tr height= ">"
&LT;TD width= "118" align= "right" fontsize= "fontname=" "Arial" fontcolor= "Black" b= "true" i= "false" u= "false" bgcolor= "WH" Ite "> Train number:</td>
&LT;TD width= "449" align= "right" fontsize= "fontname=" "Arial" fontcolor= "Black" b= "true" i= "false" u= "false" bgcolor= "Wh" Ite "><xsl:value-of select=" Serial_no "/></td>
&LT;TD width= "align=" "Right" fontsize= "Fontname=" "Song Body" fontcolor= "Black" b= "true" i= "false" u= "false" bgcolor= "whi TE "></td>
&LT;TD width= "138" align= "right" fontsize= "fontname=" "Arial" fontcolor= "Black" b= "true" i= "false" u= "false" bgcolor= "WH" Ite "></td>
</tr>
</toptable>
</xsl:for-each>
<detailtable width= "373" >
<xsl:for-each select= "Billdetail" >
<tr height= ">"
&LT;TD width= "align=" "Right" fontsize= "Fontname=" "Song Body" fontcolor= "Black" b= "true" i= "false" u= "false" bgcolor= " White "><xsl:value-of select=" Bill_no "/></td>
&LT;TD width= "173" align= "right" fontsize= "Fontname=" "The Song Body" fontcolor= "Black" b= "true" i= "false" u= "false" bgcolor= " White "><xsl:value-of select=" prod_model_2 "/></td>
&LT;TD width= "align=" "Right" fontsize= "Fontname=" "Song Body" fontcolor= "Black" b= "true" i= "false" u= "false" bgcolor= " White "><xsl:value-of select=" Prod_num "/></td>
&LT;TD width= "align=" "Right" fontsize= "Fontname=" "Song Body" fontcolor= "Black" b= "true" i= "false" u= "false" bgcolor= " White "><xsl:value-of select=" Piece_num "/></td>
</tr>

</xsl:for-each>
</detailtable>
<mastertable width= "370" >
<xsl:for-each select= "Billmaster" >
<tr height= ">"
&LT;TD width= "align=" "Right" fontsize= "Fontname=" "Song Body" fontcolor= "Black" b= "true" i= "false" u= "false" bgcolor= " White ">
</td>
&LT;TD width= "280" align= "right" fontsize= "Fontname=" "The Song Body" fontcolor= "Black" b= "true" i= "false" u= "false" bgcolor= " White "><xsl:value-of select=" Address "/></td>
</tr>
<tr height= ">"
&LT;TD width= "align=" "Right" fontsize= "Fontname=" "Song Body" fontcolor= "Black" b= "true" i= "false" u= "false" bgcolor= " White ">
</td>
&LT;TD width= "align=" "Right" fontsize= "Fontname=" "Song Body" fontcolor= "Black" b= "true" i= "false" u= "false" bgcolor= " White "><xsl:value-of select=" Contact_person "/></td>
&LT;TD width= "align=" "Right" fontsize= "Fontname=" "Song Body" fontcolor= "Black" b= "true" i= "false" u= "false" bgcolor= " White ">
</td>
&LT;TD width= "align=" "Right" fontsize= "Fontname=" "Song Body" fontcolor= "Black" b= "true" i= "false" u= "false" bgcolor= " White "><xsl:value-of select=" Contact_phone "/></td>
</tr>
<tr height= ">"
&LT;TD width= "align=" "Right" fontsize= "Fontname=" "Song Body" fontcolor= "Black" b= "true" i= "false" u= "false" bgcolor= " White ">
</td>
&LT;TD width= "280" align= "right" fontsize= "Fontname=" "The Song Body" fontcolor= "Black" b= "true" i= "false" u= "false" bgcolor= " White "><xsl:value-of select=" Driver_unit "/></td>
</tr>
<tr height= ">"
&LT;TD width= "align=" "Right" fontsize= "Fontname=" "Song Body" fontcolor= "Black" b= "true" i= "false" u= "false" bgcolor= " White ">
</td>
&LT;TD width= "align=" "Right" fontsize= "Fontname=" "Song Body" fontcolor= "Black" b= "true" i= "false" u= "false" bgcolor= " White "><xsl:value-of select=" Driver_no "/></td>
&LT;TD width= "align=" "Right" fontsize= "Fontname=" "Song Body" fontcolor= "Black" b= "true" i= "false" u= "false" bgcolor= " White ">
</td>
&LT;TD width= "align=" "Right" fontsize= "Fontname=" "Song Body" fontcolor= "Black" b= "true" i= "false" u= "false" bgcolor= " White "><xsl:value-of select=" Driver_person "/></td>
</tr>
<tr height= ">"
&LT;TD width= "align=" "Right" fontsize= "Fontname=" "Song Body" fontcolor= "Black" b= "true" i= "false" u= "false" bgcolor= " White ">
</td>
&LT;TD width= "align=" "Right" fontsize= "Fontname=" "Song Body" fontcolor= "Black" b= "true" i= "false" u= "false" bgcolor= " White "><xsl:value-of select=" Car_model "/>
</td>
&LT;TD width= "align=" "Right" fontsize= "Fontname=" "Song Body" fontcolor= "Black" b= "true" i= "false" u= "false" bgcolor= " White ">
</td>
&LT;TD width= "align=" "Right" fontsize= "Fontname=" "Song Body" fontcolor= "Black" b= "true" i= "false" u= "false" bgcolor= " White "></td>
</tr>
<tr height= ">"
&LT;TD width= "align=" "Right" fontsize= "Fontname=" "Song Body" fontcolor= "Black" b= "true" i= "false" u= "false" bgcolor= "WHI" TE ">
</td>
&LT;TD width= "280" align= "right" fontsize= "Fontname=" "The Song Body" fontcolor= "Black" b= "true" i= "false" u= "false" bgcolor= " White "><xsl:value-of select=" come_to "/></td>
</tr>
</xsl:for-each>
</mastertable>

<foottable width= "743" >
<xsl:for-each select= "Billmaster" >
<tr height= ">"
&LT;TD width= "align=" "Right" fontsize= "Fontname=" "Song Body" fontcolor= "Black" b= "true" i= "false" u= "false" bgcolor= " White "></td>
&LT;TD width= "173" align= "right" fontsize= "Fontname=" "The Song Body" fontcolor= "Black" b= "true" i= "false" u= "false" bgcolor= " White "></td>
&LT;TD width= "align=" "Right" fontsize= "Fontname=" "Song Body" fontcolor= "Black" b= "true" i= "false" u= "false" bgcolor= " White "></td>
&LT;TD width= "align=" "Right" fontsize= "Fontname=" "Song Body" fontcolor= "Black" b= "true" i= "false" u= "false" bgcolor= " White "></td>

&LT;TD width= "align=" "Right" fontsize= "Fontname=" "Song Body" fontcolor= "Black" b= "true" i= "false" u= "false" bgcolor= "WHI" TE ">
</td>
&LT;TD width= "280" align= "right" fontsize= "Fontname=" "The Song Body" fontcolor= "Black" b= "true" i= "false" u= "false" bgcolor= " White "><xsl:value-of select=" remark "/></td>
</tr>
</xsl:for-each>
</foottable>

</bill>
</reporttable>
</root>
</xsl:template>

</xsl:stylesheet>
Among them, Toptable is the head of the table, Detailtable is the product details on the left of the table, Mastertable is the transport information on the right side of the table, Foottable is the most of the following information such as watchmaker.

Then, in the ASP.net page, the results of the query are converted as follows

' Did you get the documents?
If billinfoxml <> Nothing Then

Billinfodoc.loadxml (Billinfoxml)
' Billinfodoc.loadxml ("http://111.111.111.111/stockmg/test.xsl")
Billtrans.load (Billformatxmlurl)

billxmlwr.formatting = System.Xml.Formatting.Indented
Billxmlwr.indentation = 4
Billxmlwr.indentchar = ""

Billtrans.transform (Billnav, nothing, billxmlwr, nothing)
Billxmlwr.flush ()

End If

The returned information is loaded into the print control in JavaScript code:
PARENT.FRAMES.FRMHIDPRINT.PARENT.FRAMES.FRMHIDPRINT.PRINT1.SETXML (Xmlresult); Setmessage (Xmlresult); PARENT.FRAMES.FRMHIDPRINT.PARENT.FRAMES.FRMHIDPRINT.PRINT1.PRINTACT ();

Note that the print control is invoked here with the parent.frames .... This is to save the time it takes to load a print control every time the page is opened, using a frames page that places the print control on a separate page, eliminating the need to load each time.



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.