利用XML如何實(shí)現(xiàn)通用WEB報(bào)表打印實(shí)際使用中的例子?這個(gè)問(wèn)題可能是我們?nèi)粘W(xué)習(xí)或工作經(jīng)常見(jiàn)到的。希望通過(guò)這個(gè)問(wèn)題能讓你收獲頗深。下面是小編給大家?guī)?lái)的參考內(nèi)容,讓我們一起來(lái)看看吧!

(一).使用通用模版格式化XML文件
系統(tǒng)中共用到了三種單據(jù),分別為出庫(kù)單,入庫(kù)單,送貨單,因此,定義三個(gè)模版文件,格式如下
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">車(chē)次號(hào):</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是表格左邊的產(chǎn)品明細(xì),mastertable是表格右邊的運(yùn)輸信息等,foottable是最下面制表人等信息。
然后,在asp.net頁(yè)面中,將查詢(xún)出的結(jié)果作如下轉(zhuǎn)換
'是否取得了單據(jù)
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();
注意,這里調(diào)用打印控件用了parent.frames....這是為了節(jié)省每次打開(kāi)頁(yè)面時(shí)加載打印控件的時(shí)間,使用了一個(gè)框架網(wǎng)頁(yè),把打印控件放在一個(gè)單獨(dú)的頁(yè)面中,從而不需每次加載。
感謝各位的閱讀!看完上述內(nèi)容,你們對(duì)利用XML如何實(shí)現(xiàn)通用WEB報(bào)表打印實(shí)際使用中的例子大概了解了嗎?希望文章內(nèi)容對(duì)大家有所幫助。如果想了解更多相關(guān)文章內(nèi)容,歡迎關(guān)注創(chuàng)新互聯(lián)成都網(wǎng)站設(shè)計(jì)公司行業(yè)資訊頻道。
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性?xún)r(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專(zhuān)為企業(yè)上云打造定制,能夠滿足用戶(hù)豐富、多元化的應(yīng)用場(chǎng)景需求。
網(wǎng)頁(yè)名稱(chēng):利用XML如何實(shí)現(xiàn)通用WEB報(bào)表打印實(shí)際使用中的例子-創(chuàng)新互聯(lián)
URL分享:http://chinadenli.net/article32/piosc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供移動(dòng)網(wǎng)站建設(shè)、App開(kāi)發(fā)、關(guān)鍵詞優(yōu)化、面包屑導(dǎo)航、做網(wǎng)站、網(wǎng)站設(shè)計(jì)公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容
移動(dòng)網(wǎng)站建設(shè)知識(shí)