最近在公司做报表.
有一种方法是利用ORACLE的存储过程返回XML,然后利用XSLT转换为EXCEL.
以下是某个存储过程返回的XML:
<?xml version="1.0" encoding="UTF-8"?>
<ROOT>
    <container_detail>
  <ROW CONTAINER_NO="DFSU7666883 "/>
  <ROW CONTAINER_NO="DFSU7666836 "/>
  <ROW CONTAINER_NO="DFSU7666800 "/>
  <ROW CONTAINER_NO="DFSU7666878 "/>
  <ROW CONTAINER_NO="DFSU7666815 "/>
  <ROW CONTAINER_NO="DFSU7666857 "/>
  <ROW CONTAINER_NO="DFSU7666899 "/>
  <ROW CONTAINER_NO="DFSU7666820 "/>
  <ROW CONTAINER_NO="DFSU7666841 "/>
  <ROW CONTAINER_NO="DFSU7666862 "/>
    </container_detail>
</ROOT>
 
现要求,将CONTAINER_NO取出,转为EXCEL时要每四列就换行,如下:
Booking Confirmation Unit Details    
DFSU7666883  DFSU7666836  DFSU7666800  DFSU7666878  
DFSU7666815  DFSU7666857  DFSU7666899  DFSU7666820  
DFSU7666841  DFSU7666862    
 
在利用XSLT处理的时候遇到难题,半天解决不了.求助PM,一会儿就解决了,强哈~
部分如下:
    <xsl:for-each select="//ROW">
      <xsl:if test="position() mod 4 =1">
          <Row>
        <Cell ss:StyleID="s22">
            <Data ss:Type="String">
          <xsl:value-of select="@CONTAINER_NO"/>
            </Data>
        </Cell>
        <xsl:for-each select="following::*[position()<=3]">
            <Cell ss:StyleID="s22">
          <Data ss:Type="String">
              <xsl:value-of select="@CONTAINER_NO"/>
          </Data>
            </Cell>
        </xsl:for-each>
          </Row>
      </xsl:if> 
    </xsl:for-each>
 
还有得学哈~~加油加油!