国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

利用XML實現通用WEB報表打印實際使用中的例子

2019-11-18 17:20:14
字體:
來源:轉載
供稿:網友

最近做的一個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="   <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="
     <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("                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....這是為了節省每次打開頁面時加載打印控件的時間,使用了一個框架網頁,把打印控件放在一個單獨的頁面中,從而不需每次加載。

 第一次發帖,包涵,呵呵。

出處:品味技術 感受人生 BLOG


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 太仆寺旗| 临沧市| 梨树县| 汉源县| 葵青区| 建水县| 慈利县| 栾城县| 柳江县| 台东市| 上饶县| 安陆市| 汉源县| 绍兴市| 平陆县| 阿拉尔市| 丽水市| 武宁县| 涞源县| 湟源县| 阳东县| 秦皇岛市| 太原市| 霍州市| 泰安市| 敦化市| 工布江达县| 家居| 望都县| 阿坝| 新乡市| 梅州市| 太康县| 汕头市| 江永县| 桐乡市| 名山县| 平远县| 固始县| 抚远县| 胶州市|