Solved

Convert Excel XML to HTML with XSLT

Posted on 2003-10-31
2
1,531 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
2 Comments
 

Expert Comment

by:rishisk
Comment Utility
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
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

762 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now