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 3-1).
Note
Saving as XML makes your workbook usable from non-Windows platforms and convertible to other interesting formats, such as HTML. Itâs also handy to understand the little trick Microsoft uses to make Excelâs XML appear as a workbook in Windows.
Figure 3-1. Save As dialog box
How to do it
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 âUse XML Mapsâ later in this chapter.
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 in the following XML:
<?xml version="1.0"?> }- Processing instruction <?mso-application progid="Excel.Sheet"?> <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" ...
Get Excel 2003 Programming: A Developer's Notebook 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.