[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

problem converting xml to excel

Subject: problem converting xml to excel
From: Anna Bikkina <anna@xxxxxxxxxxxxxx>
Date: Thu, 11 Mar 2004 17:06:39 -0500
converting xml to excel
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.