xsl-list
[Top] [All Lists]

Re: problem converting xml to excel

2004-03-12 09:36:39
I am still having the same problem. Can someone please help.

Thanks,
Anna.

On Thursday 11 March 2004 05:06 pm, Anna Bikkina wrote:
Hi,

I am trying to convert a xml file into excel using xsl. The data in the xml
comes from a database table. When there are empty columns in any row in the
xml in excel it is getting filled with the first value entered into
excel(the one in row 0 col0). I am not able to understand how that value is
propagating to other rows and columns.


My xml file looks like this
      <result>
              <row><col>col1</col><col>col2</col><col/></row>
              
<row><col>col1row2</col><col>col2ro2</col><col>col3row2</col></row>
      </result>
If you see carefully the third column in row1 is empty. This is causing a
problem . Instead of leaving the excel cell empty the cell is being filled
with the first value I enter into excel. If I do not fill in row0 col0 what
ever value I fill in first gets in there. Can someone please tell me where
I am making a mistake.


Below is a snippet from my xsl


  <xsl:template match="result">
       <xsl:for-each select="column">
                   <gmr:Cell Row="4" ValueType="60">
                    <xsl:variable name="colnumber"><xsl:number from="result"
count="column"/></xsl:variable>
                    <xsl:attribute name="Col">
                       <xsl:value-of select="$colnumber"/>
                    </xsl:attribute>
                     <gmr:Content>
                                  <gmr:Styles>
                                      <gmr:StyleRegion startCol="0" 
startRow="4" endCol="30"
endRow="4"> <gmr:Style HAlign="1" VAlign="2" WrapText="0" Orient="1"
Shade="0" Indent="0" Fore="F800:0:0" Back="0:8000:0"
PatternColor="C000:C000:C000" Format="General">
                                        <gmr:Font Unit="9" Bold="1" 
Italic="0" Underline="0"
                              StrikeThrough="0">Helvetica</gmr:Font>
                                      </gmr:Style>
                                      </gmr:StyleRegion>
                                    </gmr:Styles>
                                              <xsl:apply-templates select="." 
mode="value"/>
                      </gmr:Content>
                   </gmr:Cell>
      </xsl:for-each>
    <xsl:for-each select="row">
      <xsl:apply-templates select=".">
        <xsl:with-param name="rownumber" select="position()+4"/>
      </xsl:apply-templates>
    </xsl:for-each>
  </xsl:template>

  <xsl:template match="row">
    <xsl:param name="rownumber" select="3"/>
    <xsl:for-each select="*">
      <xsl:apply-templates select=".">
        <xsl:with-param name="rownumber" select="$rownumber"/>
        <xsl:with-param name="colnumber" select="position()"/>
      </xsl:apply-templates>
    </xsl:for-each>
  </xsl:template>

      <xsl:template match="col">
         <!-- avoids Result Tree Fragments -->
         <xsl:param name="rownumber" select="0"/>
         <xsl:param name="colnumber" select="0"/>
         <gmr:Cell ValueType="60" Col="{$colnumber}" Row="{$rownumber}">
           <xsl:apply-templates mode="value" select="."/>
         </gmr:Cell>
      </xsl:template>


Thanks,
Anna.


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list