Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries [Thread Prev] >Thread Next - RE: Convert XMl to Excel using XLST Convert XMl to Excel using XLSTTo: NULL Date: 1/4/2006 8:34:00 PM I have been Scowering the net to try to find how to convert a simple XML file to an Excel workbook using XSLT. I have a basic outline working, But I need extra help. My XML is as follows: <?xml version="1.0"?> <?xml-stylesheet type='text/xsl' href='conditionReport.xslt'?> <AreasRoot> <room name="Entrance Hall"> <item name="Doors"> <roomIndex>0</roomIndex> <conditionBefore /> <conditionAfter /> <commentsBefore /> <commentsAfter /> </item> <item name="Security Door"> <roomIndex>0</roomIndex> <conditionBefore>F</conditionBefore> <conditionAfter /> <commentsBefore /> <commentsAfter /> </item> </room> <userDetails> <tennant address="123 Fake Street" name="Mark" landlord="DCK" leaseDate="11/11/2005" /> </userDetails> </AreasRoot> ********************************************************************************* End of XML - this is not part of the XML ********************************************************************************* and here is the XSLT document I use to format the above: (called conditionReport.xslt) <?xml version="1.0" encoding="UTF-8" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <head> <style> </style> </head> <body> <table border="1"> <colgroup width="20" align="center"></colgroup> <colgroup width="135" align="left"></colgroup> <colgroup width="25" align="left"></colgroup> <colgroup width="25" align="left"></colgroup> <colgroup width="25" align="left"></colgroup> <colgroup width="250" align="left"></colgroup> <colgroup width="25" align="left"></colgroup> <colgroup width="25" align="left"></colgroup> <colgroup width="25" align="left"></colgroup> <colgroup width="250" align="left"></colgroup> <td>Room</td> <td>Item</td> <td>Good</td> <td>Fair</td> <td>Poor</td> <td>Other Items and Comments</td> <td>Good</td> <td>Fair</td> <td>Poor</td> <td>Other Items and Comments</td> <xsl:for-each select="AreasRoot/room"> <tr> <td valign="top" rowspan="{count(item)}" reference-orientation="90"> <b> <xsl:value-of select="@name"/> </b> </td> <xsl:for-each select="item"> <td> <xsl:value-of select="@name"/> </td> <td> <xsl:if test="./conditionBefore = 'G' "> x </xsl:if> </td> <td> <xsl:if test="./conditionBefore = 'F' "> x </xsl:if> </td> <td> <xsl:if test="./conditionBefore = 'P' "> x </xsl:if> </td> <td> <xsl:value-of select="commentsBefore"/> </td> <td> <xsl:if test="./conditionAfter = 'G' "> x </xsl:if> </td> <td> <xsl:if test="./conditionAfter = 'G' "> x </xsl:if> </td> <td> <xsl:if test="./conditionAfter = 'G' "> x </xsl:if> </td> <td> <xsl:value-of select="commentsAfter"/> </td> <xsl:if test="position() != last()"> <xsl:text disable-output-escaping="yes"><tr></xsl:text> </xsl:if> </xsl:for-each> </tr> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet> **************************************************************************** End of XSLT document - this is not part of the XSLT document **************************************************************************** so that works ok so far. I need some basic formatting done, but that can be worried about at a leter date. As you can see in the XML there is a element called userDetails. I need for the information stored in this node the on a different worksheet, how do i do that? I just cant seem to find an answer anywhere its driving me nuts! Please help. Cheers, Mark | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
