


Practical examples of using XML to realize general WEB report printing
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
Note that parent.frames is used to call the print control here.... This is to save the time of loading the print control every time the page is opened. A frame web page is used to print the The control is placed on a separate page so it does not need to be loaded each time.
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 (www.php.cn)!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Can XML files be opened with PPT? XML, Extensible Markup Language (Extensible Markup Language), is a universal markup language that is widely used in data exchange and data storage. Compared with HTML, XML is more flexible and can define its own tags and data structures, making the storage and exchange of data more convenient and unified. PPT, or PowerPoint, is a software developed by Microsoft for creating presentations. It provides a comprehensive way of

Convert XML data in Python to CSV format XML (ExtensibleMarkupLanguage) is an extensible markup language commonly used for data storage and transmission. CSV (CommaSeparatedValues) is a comma-delimited text file format commonly used for data import and export. When processing data, sometimes it is necessary to convert XML data to CSV format for easy analysis and processing. Python is a powerful

How to handle XML and JSON data formats in C# development requires specific code examples. In modern software development, XML and JSON are two widely used data formats. XML (Extensible Markup Language) is a markup language used to store and transmit data, while JSON (JavaScript Object Notation) is a lightweight data exchange format. In C# development, we often need to process and operate XML and JSON data. This article will focus on how to use C# to process these two data formats, and attach

Web standards are a set of specifications and guidelines developed by W3C and other related organizations. It includes standardization of HTML, CSS, JavaScript, DOM, Web accessibility and performance optimization. By following these standards, the compatibility of pages can be improved. , accessibility, maintainability and performance. The goal of web standards is to enable web content to be displayed and interacted consistently on different platforms, browsers and devices, providing better user experience and development efficiency.

Using Python to implement data validation in XML Introduction: In real life, we often deal with a variety of data, among which XML (Extensible Markup Language) is a commonly used data format. XML has good readability and scalability, and is widely used in various fields, such as data exchange, configuration files, etc. When processing XML data, we often need to verify the data to ensure the integrity and correctness of the data. This article will introduce how to use Python to implement data verification in XML and give the corresponding

Cockpit is a web-based graphical interface for Linux servers. It is mainly intended to make managing Linux servers easier for new/expert users. In this article, we will discuss Cockpit access modes and how to switch administrative access to Cockpit from CockpitWebUI. Content Topics: Cockpit Entry Modes Finding the Current Cockpit Access Mode Enable Administrative Access for Cockpit from CockpitWebUI Disabling Administrative Access for Cockpit from CockpitWebUI Conclusion Cockpit Entry Modes The cockpit has two access modes: Restricted Access: This is the default for the cockpit access mode. In this access mode you cannot access the web user from the cockpit

Jackson is a Java-based library that is useful for converting Java objects to JSON and JSON to Java objects. JacksonAPI is faster than other APIs, requires less memory area, and is suitable for large objects. We use the writeValueAsString() method of the XmlMapper class to convert the POJO to XML format, and the corresponding POJO instance needs to be passed as a parameter to this method. Syntax publicStringwriteValueAsString(Objectvalue)throwsJsonProcessingExceptionExampleimp

How Python parses XML files XML (eXtensibleMarkupLanguage) is a markup language used to represent structured data. When processing XML data, we often need to parse the XML file to extract the required information. Python provides many libraries and modules to parse XML files, such as ElementTree, lxml, etc. This article will introduce how to use Python to parse XML files, with code examples. In Python,
