Working with Excel XML Spreadsheets

Problem

You want to export data from Excel to XML, but not in the native format supported by Microsoft.

Solution

If you have an Excel spreadsheet that looks like this:

Date

Price

Volume

20010817

61.88

260163

20010820

62.7

241859

20010821

60.78

233989

20010822

60.66

387444

Then the Excel XML version looks like this:

<?xml version="1.0"?> <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>Salvatore R. Mangano</Author> <LastAuthor>Salvatore R. Mangano</LastAuthor> <Created>2002-08-18T00:43:49Z</Created> <LastSaved>2002-08-18T02:19:21Z</LastSaved> <Company>Descriptix</Company> <Version>10.3501</Version> </DocumentProperties> <OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office"> <DownloadComponents/> <LocationOfComponents HRef="/"/> </OfficeDocumentSettings> <ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel"> <WindowHeight>9915</WindowHeight> <WindowWidth>10140</WindowWidth> <WindowTopX>240</WindowTopX> <WindowTopY>255</WindowTopY> <ProtectStructure>False</ProtectStructure> <ProtectWindows>False</ProtectWindows> </ExcelWorkbook> <Styles> <Style ss:ID="Default" ss:Name="Normal"> <Alignment ss:Vertical="Bottom"/> <Borders/> ...

Get XSLT Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.