Solved

Convert Excel XML to HTML with XSLT

Posted on 2003-10-31
2
1,556 Views
Last Modified: 2013-11-19
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
Comment
Question by:AlexNYC
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Expert Comment

by:rishisk
ID: 9661456
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
 
LVL 2

Accepted Solution

by:
ericsDev earned 125 total points
ID: 9669051
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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question