利用XML实现通用WEB报表打印实际使用中的例子

王朝other·作者佚名  2006-11-24
宽屏版  字体: |||超大  

最近做的一个B/S项目,在打印时采用了在IE中嵌入.net winform控件和XML结合的方式(参见http://www.yesky.com/20030214/1652186.shtml),在实际应用过程中,有一些心得,和大家分享。

(一).使用通用模版格式化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">

&n

[1] [2] 下一页

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有