我有一个要求,当相同的数据流入时,我必须组合单元格。 我想组合“proj_name”和“snd_ba_name”的单元格。我尝试了一些代码,但似乎没有任何工作。 有人可以帮忙 此报告的XML是
<?xml version="1.0" encoding="UTF-8"?>
<message>
<body>
<asset>
<entity>
<id>page3</id>
<entity-record>
<id>bad7ce40-66d2-11e7-9a1f-f5876ea6a532#-</id>
<field>
<id>sending_cc2</id>
<value>GCO BISO Mumbai</value>
</field>
<field>
<id>total_euro</id>
<value>0.00</value>
</field>
<field>
<id>proj_name</id>
<value>ABC</value>
</field>
<field>
<id>sum_inr</id>
<value>-47500.08</value>
</field>
<field>
<id>rec_cc</id>
<value>01471A00</value>
</field>
<field>
<id>snd_ba_name</id>
<value>A</value>
</field>
<field>
<id>fsi_code</id>
<value>F1770259000</value>
</field>
<field>
<id>sending_cc</id>
<value>9478110804</value>
</field>
<field>
<id>total_inr</id>
<value>0.00</value>
</field>
<field>
<id>sum_eur</id>
<value>-670.62</value>
</field>
</entity-record>
<entity-record>
<id>bad7ce41-66d2-11e7-9a1f-f5876ea6a532#-</id>
<field>
<id>sending_cc2</id>
<value>GCO BISO Mumbai</value>
</field>
<field>
<id>total_euro</id>
<value>0.00</value>
</field>
<field>
<id>proj_name</id>
<value>ABC</value>
</field>
<field>
<id>sum_inr</id>
<value>-11028.25</value>
</field>
<field>
<id>rec_cc</id>
<value>01470C00</value>
</field>
<field>
<id>snd_ba_name</id>
<value>A</value>
</field>
<field>
<id>fsi_code</id>
<value>F1770259000</value>
</field>
<field>
<id>sending_cc</id>
<value>9478110804</value>
</field>
<field>
<id>total_inr</id>
<value>0.00</value>
</field>
<field>
<id>sum_eur</id>
<value>-155.70</value>
</field>
</entity-record>
<entity-record>
<id>bad7ce42-66d2-11e7-9a1f-f5876ea6a532#-</id>
<field>
<id>sending_cc2</id>
<value>TaxOps-Bangalore-NOC</value>
</field>
<field>
<id>total_euro</id>
<value>0.00</value>
</field>
<field>
<id>proj_name</id>
<value>ABC</value>
</field>
<field>
<id>sum_inr</id>
<value>139417.72</value>
</field>
<field>
<id>rec_cc</id>
<value>01470H00</value>
</field>
<field>
<id>snd_ba_name</id>
<value>Tax Operations</value>
</field>
<field>
<id>fsi_code</id>
<value>F1770259000</value>
</field>
<field>
<id>sending_cc</id>
<value>9478754400</value>
</field>
<field>
<id>total_inr</id>
<value>0.00</value>
</field>
<field>
<id>sum_eur</id>
<value>1968.35</value>
</field>
</entity-record>
<entity-record>
<id>bad7ce43-66d2-11e7-9a1f-f5876ea6a532#-</id>
<field>
<id>sending_cc2</id>
<value>GCO BISO Mumbai</value>
</field>
<field>
<id>total_euro</id>
<value>0.00</value>
</field>
<field>
<id>proj_name</id>
<value>ABC</value>
</field>
<field>
<id>rec_cc</id>
<value>01470F00</value>
</field>
<field>
<id>snd_ba_name</id>
<value>B</value>
</field>
<field>
<id>fsi_code</id>
<value>F1770259000</value>
</field>
<field>
<id>sending_cc</id>
<value>9478110804</value>
</field>
<field>
<id>total_inr</id>
<value>0.00</value>
</field>
<field>
<id>sum_eur</id>
<value>-112.37</value>
</field>
</entity-record>
<entity-record>
<id>bad7ce44-66d2-11e7-9a1f-f5876ea6a532#-</id>
<field>
<id>sending_cc2</id>
<value>TaxOps-Bangalore-NOC</value>
</field>
<field>
<id>total_euro</id>
<value>0.00</value>
</field>
<field>
<id>proj_name</id>
<value>DEF </value>
</field>
<field>
<id>sum_inr</id>
<value>6971.10</value>
</field>
<field>
<id>rec_cc</id>
<value>01490B00</value>
</field>
<field>
<id>snd_ba_name</id>
<value>C</value>
</field>
<field>
<id>fsi_code</id>
<value>F1770259000</value>
</field>
<field>
<id>sending_cc</id>
<value>9478754400</value>
</field>
<field>
<id>total_inr</id>
<value>0.00</value>
</field>
<field>
<id>sum_eur</id>
<value>98.42</value>
</field>
</entity-record>
<entity-record>
<id>bad7ce45-66d2-11e7-9a1f-f5876ea6a532#-</id>
<field>
<id>sending_cc2</id>
<value>TaxOps-Bangalore-NOC</value>
</field>
<field>
<id>total_euro</id>
<value>0.00</value>
</field>
<field>
<id>proj_name</id>
<value>TSO-TAXOPS-C_9478754400</value>
</field>
<field>
<id>sum_inr</id>
<value>27883.69</value>
</field>
<field>
<id>rec_cc</id>
<value>01470E00</value>
</field>
<field>
<id>snd_ba_name</id>
<value>Tax Operations</value>
</field>
<field>
<id>fsi_code</id>
<value>F1770259000</value>
</field>
<field>
<id>sending_cc</id>
<value>9478754400</value>
</field>
<field>
<id>total_inr</id>
<value>0.00</value>
</field>
<field>
<id>sum_eur</id>
<value>393.67</value>
</field>
</entity-record>
</entity>
</asset>
</body>
</message>
我尝试的XSLT代码是
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" indent="yes"/>
<xsl:key name="snd_ba_name" match="body/asset/entity[id[text()='page3']]/entity-record" use="field[id[text()='snd_ba_name']]/value" />
<xsl:key name="proj_name" match="body/asset/entity[id[text()='page3']]/entity-record" use="field[id[text()='proj_name']]/value" />
<xsl:variable name="smallcase" select="'abcdefghijklmnopqrstuvwxyz'"/>
<xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
<xsl:template match="message">
<html>
<head>
<title>Invoice Report</title>
<style type="text/css">body { font-family:sans-serif; position: relative; margin: 0px auto; padding: 0px; border: none; width: 900px; margin: 0% 0%; padding: 0%; } hr { border:1px solid; border-bottom:1px; width:100%; } .page_break{page-break-after: always;} input[type=text] { height:25px; text-indent: 0.5em; border:1px solid black; background-color:white; } input[type=checkbox] { /* Double-sized Checkboxes */ -ms-transform: scaleX(1.3)scaleY(1.3); /* IE */ -moz-transform: scaleX(1.3)scaleY(1.3); /* FF */ -webkit-transform: scaleX(1.3)scaleY(1.3); /* Safari and Chrome */ -o-transform: scaleX(1.3)scaleY(1.3); /* Opera */ } .sqr_block { border:1px solid black; background-color:white; height:28px; width:18px; margin-left:2px; margin-right:2px; } .tableArray1 { border: 1px solid black; border-collapse: collapse; } #BorderHidden{ border-bottom-style:hidden; border-top-style:hidden; border-right-style:hidden; border-left-style:hidden; } .break{ page-break-before: always;}</style>
</head>
<body>
<table cellpadding="0" cellspacing="0" border="1" width="100%">
<xsl:for-each select="body/asset/entity[id[text()='page3']]/entity-record[count(.|key('snd_ba_name',field[id[text()='snd_ba_name']]/value)[1])=1]">
<xsl:sort select="field[id[text()='snd_ba_name']]/value"/>
<tr>
<td rowspan="" width="15%" style="font-size:10px;" valign="top" align="left">
<xsl:attribute name="rowspan">
<xsl:value-of select="count(key('snd_ba_name',field[id[text()='snd_ba_name']]/value)[1]) + 1"/>
</xsl:attribute>
<xsl:value-of select="field[id[text()='snd_ba_name']]/value"/>
</td>
<td width="15%" style="font-size:10px;" valign="top" align="left">
<xsl:value-of select="field[id[text()='proj_name']]/value"/>
</td>
<td width="10%" style="font-size:10px;" valign="top" align="left">
<xsl:value-of select="field[id[text()='sending_cc']]/value"/>
</td>
<td width="10%" style="font-size:10px;" valign="top" align="left">
<xsl:value-of select="field[id[text()='sending_cc2']]/value"/>
</td>
<td width="10%" style="font-size:10px;" valign="top" align="left">
<xsl:value-of select="field[id[text()='rec_cc']]/value"/>
</td>
<td width="10%" style="font-size:10px;" valign="top" align="left">
<xsl:value-of select="field[id[text()='fsi_code']]/value"/>
</td>
<td width="15%" style="font-size:10px;" valign="top" align="right">
<xsl:value-of select="field[id[text()='sum_eur']]/value"/>
<!-- <xsl:value-of select="format-number(sum(current-group()/field[id[text()='sum_eur']]/value),'0.00')"/> -->
</td>
<td width="15%" style="font-size:10px;" valign="top" align="right">
<xsl:value-of select="field[id[text()='sum_inr']]/value"/>
<!-- <xsl:value-of select="format-number(sum(current-group()/field[id[text()='sum_inr']]/value),'0.00')"/> -->
</td>
</tr>
</xsl:for-each>
<xsl:variable name="TotalInvoiceERU" select="body/asset/entity[id[text()='page3']]/entity-record/field[id[text()='sum_eur']]/value"/>
<xsl:variable name="TotalInvoiceERU1" select="sum($TotalInvoiceERU)"/>
<xsl:variable name="TotalInvoiceINR" select="body/asset/entity[id[text()='page3']]/entity-record/field[id[text()='sum_inr']]/value"/>
<xsl:variable name="TotalInvoiceINR1" select="sum($TotalInvoiceINR)"/>
<tr>
<td colspan="6">
<b>Total Result</b>
</td>
<td height="20px" style="font-size:10px;" align="right">
<xsl:value-of select="format-number(($TotalInvoiceERU1),'0.00')"/>
</td>
<td height="20px" style="font-size:10px;" align="right">
<xsl:value-of select="format-number(($TotalInvoiceINR1),'0.00')"/>
</td>
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
我的输出应该如下:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Invoice Report</title><style type="text/css">body { font-family:sans-serif; position: relative; margin: 0px auto; padding: 0px; border: none; width: 900px; margin: 0% 0%; padding: 0%; } hr { border:1px solid; border-bottom:1px; width:100%; } .page_break{page-break-after: always;} input[type=text] { height:25px; text-indent: 0.5em; border:1px solid black; background-color:white; } input[type=checkbox] { /* Double-sized Checkboxes */ -ms-transform: scaleX(1.3)scaleY(1.3); /* IE */ -moz-transform: scaleX(1.3)scaleY(1.3); /* FF */ -webkit-transform: scaleX(1.3)scaleY(1.3); /* Safari and Chrome */ -o-transform: scaleX(1.3)scaleY(1.3); /* Opera */ } .sqr_block { border:1px solid black; background-color:white; height:28px; width:18px; margin-left:2px; margin-right:2px; } .tableArray1 { border: 1px solid black; border-collapse: collapse; } #BorderHidden{ border-bottom-style:hidden; border-top-style:hidden; border-right-style:hidden; border-left-style:hidden; } .break{ page-break-before: always;}</style></head>
<body>
<table cellpadding="0" cellspacing="0" border="1" width="100%">
<tr>
<td width="15%" style="font-size:10px;" valign="top" align="left">Project Name</td>
<td width="15%" style="font-size:10px;" valign="top" align="left">Sending BA Name</td>
<td width="10%" style="font-size:10px;" valign="top" align="left">Sending CC</td>
<td width="10%" style="font-size:10px;" valign="top" align="left">Sending CC2</td>
<td width="10%" style="font-size:10px;" valign="top" align="left">REC CC</td>
<td width="10%" style="font-size:10px;" valign="top" align="left">FSI Code</td>
<td width="15%" style="font-size:10px;" valign="top" align="right">Amount in EUR</td>
<td width="15%" style="font-size:10px;" valign="top" align="right">Amount In INR</td>
</tr>
<tr>
<td rowspan="4" width="15%" style="font-size:10px;" valign="top" align="left">ABC</td>
<td rowspan="2"width="15%" style="font-size:10px;" valign="top" align="left">A</td>
<td width="10%" style="font-size:10px;" valign="top" align="left">9478090108</td>
<td width="10%" style="font-size:10px;" valign="top" align="left">ASU GTB-IN-PUNE-NOC</td>
<td width="10%" style="font-size:10px;" valign="top" align="left">0001855844</td>
<td width="10%" style="font-size:10px;" valign="top" align="left">F1770259000</td>
<td width="15%" style="font-size:10px;" valign="top" align="right">4105.19</td>
<td width="15%" style="font-size:10px;" valign="top" align="right">290768.89</td>
</tr>
<tr>
<td width="10%" style="font-size:10px;" valign="top" align="left">9478090108</td>
<td width="10%" style="font-size:10px;" valign="top" align="left">ASU GTB-IN-PUNE-NOC</td>
<td width="10%" style="font-size:10px;" valign="top" align="left">0001855844</td>
<td width="10%" style="font-size:10px;" valign="top" align="left">F1770259000</td>
<td width="15%" style="font-size:10px;" valign="top" align="right">4105.19</td>
<td width="15%" style="font-size:10px;" valign="top" align="right">290768.89</td>
</tr>
<tr>
<td rowspan="2" width="15%" style="font-size:10px;" valign="top" align="left">Tax Operations</td>
<td width="10%" style="font-size:10px;" valign="top" align="left">9478090108</td>
<td width="10%" style="font-size:10px;" valign="top" align="left">ASU GTB-IN-PUNE-NOC</td>
<td width="10%" style="font-size:10px;" valign="top" align="left">0001855844</td>
<td width="10%" style="font-size:10px;" valign="top" align="left">F1770259000</td>
<td width="15%" style="font-size:10px;" valign="top" align="right">4105.19</td>
<td width="15%" style="font-size:10px;" valign="top" align="right">290768.89</td>
</tr>
<tr>
<td width="10%" style="font-size:10px;" valign="top" align="left">9478090108</td>
<td width="10%" style="font-size:10px;" valign="top" align="left">ASU GTB-IN-PUNE-NOC</td>
<td width="10%" style="font-size:10px;" valign="top" align="left">0001855844</td>
<td width="10%" style="font-size:10px;" valign="top" align="left">F1770259000</td>
<td width="15%" style="font-size:10px;" valign="top" align="right">4105.19</td>
<td width="15%" style="font-size:10px;" valign="top" align="right">290768.89</td>
</tr>
<tr>
<td colspan="6"><b>Total Result</b></td>
<td height="20px" style="font-size:10px;" align="right"></td>
<td height="20px" style="font-size:10px;" align="right"></td>
</tr>
</table>
</body>
</html>