A recent B/S project used a combination of embedding .net winform control and xml in IE when printing (see http://www.yesky.com/20030214/1652186.shtml ), in the actual application process, I have some experiences to share with you.
(1). Use a general template to format the XML file
There are three types of documents used in the system, namely the outbound order, the inbound order, and the delivery order. Therefore, three types of documents are defined. The template file has the following format
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="55" y="19" border="0" bordercolor="white" maxlines="6"> <xsl:for-each select="BillMaster"> <toptable width="743"> <tr height="20"> <td width="118" align="right" fontsize="10" fontname="宋体" fontcolor="black" b="true" i="false" u="false" bgcolor="white">车次号:</td> <td width="449" align="right" fontsize="10" fontname="宋体" fontcolor="black" b="true" i="false" u="false" bgcolor="White"> <xsl:value-of select="SERIAL_NO" /></td> <td width="35" align="right" fontsize="10" fontname="宋体" fontcolor="black" b="true" i="false" u="false" bgcolor="white"></td> <td width="138" align="right" fontsize="10" fontname="宋体" fontcolor="black" b="true" i="false" u="false" bgcolor="white"></td> </tr> </toptable> </xsl:for-each> <detailtable width="373"> <xsl:for-each select="BillDetail"> <tr height="33"> <td width="90" align="right" fontsize="10" fontname="宋体" fontcolor="black" b="true" i="false" u="false" bgcolor="White"> <xsl:value-of select="BILL_NO" /> </td> <td width="173" align="right" fontsize="10" fontname="宋体" fontcolor="black" b="true" i="false" u="false" bgcolor="white"> <xsl:value-of select="PROD_MODEL_2" /></td> <td width="55" align="right" fontsize="10" fontname="宋体" fontcolor="black" b="true" i="false" u="false" bgcolor="White"> <xsl:value-of select="PROD_NUM" /></td> <td width="55" align="right" fontsize="10" fontname="宋体" 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="33"> <td width="90" align="right" fontsize="10" fontname="宋体" fontcolor="black" b="true" i="false" u="false" bgcolor="White"> </td> <td width="280" align="right" fontsize="10" fontname="宋体" fontcolor="black" b="true" i="false" u="false" bgcolor="white"> <xsl:value-of select="ADDRESS" /> </td> </tr> <tr height="33"> <td width="90" align="right" fontsize="10" fontname="宋体" fontcolor="black" b="true" i="false" u="false" bgcolor="white"> </td> <td width="90" align="right" fontsize="10" fontname="宋体" fontcolor="black" b="true" i="false" u="false" bgcolor="White"> <xsl:value-of select="CONTACT_PERSON" /></td> <td width="70" align="right" fontsize="10" fontname="宋体" fontcolor="black" b="true" i="false" u="false" bgcolor="white"> </td> <td width="120" align="right" fontsize="10" fontname="宋体" fontcolor="black" b="true" i="false" u="false" bgcolor="White"> <xsl:value-of select="CONTACT_PHONE" /></td> </tr> <tr height="33"> <td width="90" align="right" fontsize="10" fontname="宋体" fontcolor="black" b="true" i="false" u="false" bgcolor="White"> </td> <td width="280" align="right" fontsize="10" fontname="宋体" fontcolor="black" b="true" i="false" u="false" bgcolor="white"> <xsl:value-of select="DRIVER_UNIT" /></td> </tr> <tr height="33"> <td width="90" align="right" fontsize="10" fontname="宋体" fontcolor="black" b="true" i="false" u="false" bgcolor="white"> </td> <td width="90" align="right" fontsize="10" fontname="宋体" fontcolor="black" b="true" i="false" u="false" bgcolor="white"> <xsl:value-of select="DRIVER_NO" /></td> <td width="70" align="right" fontsize="10" fontname="宋体" fontcolor="black" b="true" i="false" u="false" bgcolor="white"> </td> <td width="120" align="right" fontsize="10" fontname="宋体" fontcolor="black" b="true" i="false" u="false" bgcolor="white"> <xsl:value-of select="DRIVER_PERSON" /></td> </tr> <tr height="33"> <td width="90" align="right" fontsize="10" fontname="宋体" fontcolor="black" b="true" i="false" u="false" bgcolor="white"> </td> <td width="90" align="right" fontsize="10" fontname="宋体" fontcolor="black" b="true" i="false" u="false" bgcolor="white"> <xsl:value-of select="CAR_MODEL" /> </td> <td width="70" align="right" fontsize="10" fontname="宋体" fontcolor="black" b="true" i="false" u="false" bgcolor="white"> </td> <td width="120" align="right" fontsize="10" fontname="宋体" fontcolor="black" b="true" i="false" u="false" bgcolor="white"></td> </tr> <tr height="33"> <td width="90" align="right" fontsize="10" fontname="宋体" fontcolor="black" b="true" i="false" u="false" bgcolor="white"> </td> <td width="280" align="right" fontsize="10" fontname="宋体" 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="35"> <td width="90" align="right" fontsize="10" fontname="宋体" fontcolor="black" b="true" i="false" u="false" bgcolor="White"></td> <td width="173" align="right" fontsize="10" fontname="宋体" fontcolor="black" b="true" i="false" u="false" bgcolor="white"></td> <td width="55" align="right" fontsize="10" fontname="宋体" fontcolor="black" b="true" i="false" u="false" bgcolor="White"></td> <td width="55" align="right" fontsize="10" fontname="宋体" fontcolor="black" b="true" i="false" u="false" bgcolor="white"></td> <td width="90" align="right" fontsize="10" fontname="宋体" fontcolor="black" b="true" i="false" u="false" bgcolor="white"> </td> <td width="280" align="right" fontsize="10" fontname="宋体" 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 header, detailtable is the product details on the left side of the table, mastertable is the transportation information on the right side of the table, etc., and foottable is the bottom Tabulator and other information.
Then, in the asp.net page, convert the query results as follows
,,,,,,,,,,,,,,,,,,,,,,,,,’ Control:
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 above is the content of practical examples of using XML to realize universal WEB report printing. For more related content, please pay attention to the PHP Chinese website (m.sbmmt.com)!