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= ">"
<TD width= "118" align= "right" fontsize= "fontname=" "Arial" fontcolor= "Black" b= "true" i= "false" u= "false" bgcolor= "WH" Ite "> Train number:</td>
<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>
<TD width= "align=" "Right" fontsize= "Fontname=" "Song Body" fontcolor= "Black" b= "true" i= "false" u= "false" bgcolor= "whi TE "></td>
<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= ">"
<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>
<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>
<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>
<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= ">"
<TD width= "align=" "Right" fontsize= "Fontname=" "Song Body" fontcolor= "Black" b= "true" i= "false" u= "false" bgcolor= " White ">
</td>
<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= ">"
<TD width= "align=" "Right" fontsize= "Fontname=" "Song Body" fontcolor= "Black" b= "true" i= "false" u= "false" bgcolor= " White ">
</td>
<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>
<TD width= "align=" "Right" fontsize= "Fontname=" "Song Body" fontcolor= "Black" b= "true" i= "false" u= "false" bgcolor= " White ">
</td>
<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= ">"
<TD width= "align=" "Right" fontsize= "Fontname=" "Song Body" fontcolor= "Black" b= "true" i= "false" u= "false" bgcolor= " White ">
</td>
<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= ">"
<TD width= "align=" "Right" fontsize= "Fontname=" "Song Body" fontcolor= "Black" b= "true" i= "false" u= "false" bgcolor= " White ">
</td>
<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>
<TD width= "align=" "Right" fontsize= "Fontname=" "Song Body" fontcolor= "Black" b= "true" i= "false" u= "false" bgcolor= " White ">
</td>
<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= ">"
<TD width= "align=" "Right" fontsize= "Fontname=" "Song Body" fontcolor= "Black" b= "true" i= "false" u= "false" bgcolor= " White ">
</td>
<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>
<TD width= "align=" "Right" fontsize= "Fontname=" "Song Body" fontcolor= "Black" b= "true" i= "false" u= "false" bgcolor= " White ">
</td>
<TD width= "align=" "Right" fontsize= "Fontname=" "Song Body" fontcolor= "Black" b= "true" i= "false" u= "false" bgcolor= " White "></td>
</tr>
<tr height= ">"
<TD width= "align=" "Right" fontsize= "Fontname=" "Song Body" fontcolor= "Black" b= "true" i= "false" u= "false" bgcolor= "WHI" TE ">
</td>
<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= ">"
<TD width= "align=" "Right" fontsize= "Fontname=" "Song Body" fontcolor= "Black" b= "true" i= "false" u= "false" bgcolor= " White "></td>
<TD width= "173" align= "right" fontsize= "Fontname=" "The Song Body" fontcolor= "Black" b= "true" i= "false" u= "false" bgcolor= " White "></td>
<TD width= "align=" "Right" fontsize= "Fontname=" "Song Body" fontcolor= "Black" b= "true" i= "false" u= "false" bgcolor= " White "></td>
<TD width= "align=" "Right" fontsize= "Fontname=" "Song Body" fontcolor= "Black" b= "true" i= "false" u= "false" bgcolor= " White "></td>
<TD width= "align=" "Right" fontsize= "Fontname=" "Song Body" fontcolor= "Black" b= "true" i= "false" u= "false" bgcolor= "WHI" TE ">
</td>
<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.