Solved

Convert Excel XML to HTML with XSLT

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
two submit buttons one form 15 75
Getting attribute Values using xslt 4 41
Specific format 21 184
XML & .net 5 41
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
The viewer will learn how to dynamically set the form action using jQuery.
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 …

862 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

23 Experts available now in Live!

Get 1:1 Help Now