Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1604
  • Last Modified:

Convert Excel XML to HTML with XSLT

I have a small spreadsheet that I would like to publish on out Intranet and make changes to it every now and then.  Here is the XML source:

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="versions.xsl"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40">
      <DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
            <Author>MIS</Author>
            <LastAuthor>MIS</LastAuthor>
            <Created>2003-10-31T14:52:28Z</Created>
            <Company>Schonfeld Securities, LLC.</Company>
            <Version>10.2625</Version>
      </DocumentProperties>
      <OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">
            <DownloadComponents/>
            <LocationOfComponents HRef="file:///\\Jer-027\f\"/>
      </OfficeDocumentSettings>
      <ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
            <WindowHeight>8580</WindowHeight>
            <WindowWidth>15180</WindowWidth>
            <WindowTopX>120</WindowTopX>
            <WindowTopY>60</WindowTopY>
            <ProtectStructure>False</ProtectStructure>
            <ProtectWindows>False</ProtectWindows>
      </ExcelWorkbook>
      <Styles>
            <Style ss:ID="Default" ss:Name="Normal">
                  <Alignment ss:Vertical="Bottom"/>
                  <Borders/>
                  <Font/>
                  <Interior/>
                  <NumberFormat/>
                  <Protection/>
            </Style>
      </Styles>
      <Worksheet ss:Name="Sheet1">
            <Table ss:ExpandedColumnCount="2" ss:ExpandedRowCount="3" x:FullColumns="1" x:FullRows="1">
                  <Column ss:AutoFitWidth="0" ss:Width="62.25"/>
                  <Row>
                        <Cell>
                              <Data ss:Type="String">SchonEx</Data>
                        </Cell>
                        <Cell>
                              <Data ss:Type="String">2.10.10</Data>
                        </Cell>
                  </Row>
                  <Row>
                        <Cell>
                              <Data ss:Type="String">Dotty</Data>
                        </Cell>
                        <Cell>
                              <Data ss:Type="String">1.2.3</Data>
                        </Cell>
                  </Row>
                  <Row>
                        <Cell>
                              <Data ss:Type="String">Schonsite</Data>
                        </Cell>
                        <Cell>
                              <Data ss:Type="String">1.2.4</Data>
                        </Cell>
                  </Row>
            </Table>
            <WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
                  <Selected/>
                  <Panes>
                        <Pane>
                              <Number>3</Number>
                              <ActiveRow>2</ActiveRow>
                              <ActiveCol>1</ActiveCol>
                        </Pane>
                  </Panes>
                  <ProtectObjects>False</ProtectObjects>
                  <ProtectScenarios>False</ProtectScenarios>
            </WorksheetOptions>
      </Worksheet>
      <Worksheet ss:Name="Sheet2">
            <WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
                  <ProtectObjects>False</ProtectObjects>
                  <ProtectScenarios>False</ProtectScenarios>
            </WorksheetOptions>
      </Worksheet>
      <Worksheet ss:Name="Sheet3">
            <WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
                  <ProtectObjects>False</ProtectObjects>
                  <ProtectScenarios>False</ProtectScenarios>
            </WorksheetOptions>
      </Worksheet>
</Workbook>


++++++++++++++++++++++++++++++++++++++++++++++++++++

Here is the XSL I am using to process it (not working so far):

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
      <xsl:output method="html"/>
      <xsl:template match="/">
      <html>
            <head>
                  <title>Software Versions</title>
            </head>
      <body>

Versions: <br/>
      <xsl:for-each select="Workbook/Worksheet/Table/Row/Cell">
            <xsl:value-of select="Data" />
            <br/>
      </xsl:for-each>
      <br/>
-- end --
</body>
      </html>

</xsl:template>
</xsl:stylesheet>
0
AlexNYC
Asked:
AlexNYC
1 Solution
 
rishiskCommented:
Replace the Workbook start tag as follows

<Workbook xmlns="" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40">

It worked with IE 6.0

Hope it helps.
0
 
ericsDevCommented:
this should work for you, copy and paste over your current XSL and then apply to your existing Excel XML file, I tested it on the posted data above:

XSL : ms_excel.xsl
-----------------------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ericsDev="urn:schemas-microsoft-com:office:spreadsheet" version="1.0">
      <xsl:output method="html" />
      <xsl:template match="/">
            <html>
                  <head>
                        <title>AlexNYC's solution</title>
                  </head>
                  <body>
                        Versions:
                        <br />
                        <xsl:for-each select="ericsDev:Workbook/ericsDev:Worksheet/ericsDev:Table/ericsDev:Row/ericsDev:Cell">
                              <xsl:value-of select="ericsDev:Data"/>
                              <br/>
                        </xsl:for-each>
                        <br />
                        -- end --
                  </body>
            </html>
      </xsl:template>
</xsl:stylesheet>
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now