Transform XML into a Spreadsheet

You can also use XSLT or other tools to transform XML files created outside of Excel into XML spreadsheets. In this way, you can create native Excel documents from your own applications.


XML is a two-way street. Getting XML into Excel is as important as knowing how to get it out.

How to do it

For instance, the following abbreviated XML represents a customer order created outside of Excel:

     <?xml version="1.0"?>
     <!-- SimpleOrder.xml -->
                 <Name>Joe Magnus</Name>
                 <Street1>1234 Made Up Place</Street1>
             <Description>Mahogany Tiller</Description>

To convert this XML into an XML spreadsheet, create XSLT that creates the following nodes and processing instruction:

  1. The mso-application processing instruction that identifies this file as an XML spreadsheet.

  2. A root Workbook node that defines the Microsoft Office namespaces.

  3. A Styles node defining the cell formatting to display in the worksheet. Styles include number formats, such as Currency, Percentage, or General number.

  4. A Worksheet node for each order.

  5. Column nodes to set the width of the ...

Get Excel 2003 Programming: A Developer's Notebook now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.