需要使用XSLT创建多个excel .xls文件

时间:2016-11-08 09:01:49

标签: xml xslt xls

以下是XML文件示例

<?xml version="1.0"?>
<MT_TEST_IN>
<RECORD>
  <NAME>AASHISH</NAME>
  <AGE>25</AGE>
  <Place>Chennai</Place>
</RECORD>
<RECORD>
  <NAME>Satheesh</NAME>
  <AGE>25</AGE>
  <Place>Coimbatore</Place>
</RECORD>
</MT_TEST_IN>  

我需要根据NAME元素的文本添加2个excel文件。

<?xml version="1.0" encoding="utf-8"?>
<?mso-application progid="Excel.Sheet"?>
<xsl:stylesheet version="1.0"
xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">
<xsl:template match="/">
<Workbook>
  <Styles>
    <Style ss:ID="Default" ss:Name="Normal">
      <Alignment ss:Vertical="Bottom" />
      <Borders />
      <Font />
      <Interior />
      <NumberFormat />
      <Protection />
    </Style>
    <Style ss:ID="s21">
      <Font ss:Size="22" ss:Bold="1" />
    </Style>
    <Style ss:ID="s22">
      <Font ss:Size="14" ss:Bold="1" />
    </Style>
    <Style ss:ID="s23">
      <Font ss:Size="12" ss:Bold="1" />
    </Style>
    <Style ss:ID="s24">
      <Font ss:Size="10" ss:Bold="1" />
    </Style>
  </Styles>
  <Worksheet ss:Name="Page1">
    <Table>
      <xsl:call-template name="XMLToXSL" />
    </Table>
   </Worksheet>
  </Workbook>
  </xsl:template>
  <xsl:template name="XMLToXSL">
  <Row ss:Index="1" >
  <Cell>
    <Data ss:Type="String">NAME</Data>
  </Cell>
   <xsl:for-each
  select="//RECORD">
    <Cell ss:Index="2">
      <Data ss:Type="String">
        <xsl:value-of select="NAME" />
      </Data>
    </Cell>
    </xsl:for-each>
    </Row>
   <Row ss:Index="2" >
  <Cell>
    <Data ss:Type="String">Place</Data>
  </Cell>
  <xsl:for-each
 select="//RECORD">
    <Cell ss:Index="2">
      <Data ss:Type="String">
        <xsl:value-of select="Place" />
      </Data>
    </Cell>
  </xsl:for-each>
</Row>
</xsl:template>
<xsl:template match="DataList">
</xsl:template>
</xsl:stylesheet>

我想根据&#34; NAME&#34;的值来获得2个excel文件。元件。在一个excel文件中,名称的详细信息&#34; AASHISH&#34;在另一个excel文件中,那些用于&#34; Satheesh&#34;。不是单独的表。我需要单独的excel文件。

请帮我解决这个问题。

0 个答案:

没有答案