Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Convert XMl to Excel using XLST >Thread Next - Re: Convert XMl to Excel using XLST RE: Convert XMl to Excel using XLSTTo: NULL Date: 1/5/2006 8:10:00 AM I just ran through this exercise and this is what I found. Assuming you are using Office 2002 or above, a good start is to create your desired Excel spreadsheet look with all of the column headers and column formats then save the file as XML. This will create the basic XML file you need as a starting point. Then you turn the file into a XSL style sheet by adding the following lines to the top <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml"/> <xsl:preserve-space elements="*"/> <xsl:template match="/"> and add the corresponding end tags to the end of the file. </xsl:template> </xsl:stylesheet> Save the file with an extension of .XSL and use this in your XSL Transformation. The guts of the file are similar to what you have already. Leon "mark.macumber@g..." wrote: > 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 | |||
|
