利用XML如何实现通用WEB报表打印实际使用中的例子?这个问题可能是我们日常学习或工作经常见到的。希望通过这个问题能让你收获颇深。下面是小编给大家带来的参考内容,让我们一起来看看吧!
(一).使用通用模版格式化XML文件
系统中共用到了三种单据,分别为出库单,入库单,送货单,因此,定义三个模版文件,格式如下
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>
其中,toptable是表头,detailtable是表格左边的产品明细,mastertable是表格右边的运输信息等,foottable是最下面制表人等信息。
然后,在asp.net页面中,将查询出的结果作如下转换
'是否取得了单据
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
返回的信息用javascript代码加载到打印控件:
parent.frames.frmhidPrint.parent.frames.frmhidPrint.print1.SetXml(xmlResult); //SetMessage(xmlResult); parent.frames.frmhidPrint.parent.frames.frmhidPrint.print1.PrintAct();
注意,这里调用打印控件用了parent.frames....这是为了节省每次打开页面时加载打印控件的时间,使用了一个框架网页,把打印控件放在一个单独的页面中,从而不需每次加载。
感谢各位的阅读!看完上述内容,你们对利用XML如何实现通用WEB报表打印实际使用中的例子大概了解了吗?希望文章内容对大家有所帮助。如果想了解更多相关文章内容,欢迎关注创新互联成都网站设计公司行业资讯频道。
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
网页名称:利用XML如何实现通用WEB报表打印实际使用中的例子-创新互联
URL分享:https://www.cdcxhl.com/article32/piosc.html
成都网站建设公司_创新互联,为您提供移动网站建设、App开发、关键词优化、面包屑导航、做网站、网站设计公司
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联