Save Workbooks as XML

In Excel 2003, you can now save a workbook as an XML spreadsheet or as XML Data from the Save As dialog box (Figure 15-1).

Saving a workbook as XML

Figure 15-1. Saving a workbook as XML

Choosing the XML Spreadsheet file type saves the workbook in an XML file that uses the Microsoft Office schema. Choosing the XML Data file type saves the workbook file in an XML file that uses a schema you provide through an XML map. Since it’s a good idea to start simply, I’ll discuss the XML spreadsheet format here and the XML data format later in this chapter in "Use XML Maps.”

If you save a workbook as an XML spreadsheet, you can open the file in Notepad, edit it, and still reopen/edit it in Excel later—provided you haven’t broken any of the rules in the file’s schema. A simple, default workbook includes a lot of items that aren’t required by the Office schema and you can simply delete those items to see the simplified “core” of an XML spreadsheet as shown here:

<?xml version="1.0"?> <?mso-application progid="Excel.Sheet"?> <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:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns:x2="http://schemas.microsoft.com/office/excel/2003/xml"> <Worksheet ...

Get Programming Excel with VBA and .NET 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.