7.1 Saving and Opening XML Spreadsheets


Excel treats XML spreadsheet files pretty much like regular .xls binary files. Microsoft has captured nearly all of the information stored in Excel workbooks in its XML format, with some major exceptions, including embedded Visual Basic for Applications (VBA), charting information, OLE objects, and drawing objects. It works very well for basic data import and export, but not as well for more sophisticated spreadsheets. While you can, for example, use VBA and charting on information stored in the XML maps described in Chapter 6, that functionality will be lost if you save the spreadsheet itself in SpreadsheetML and don't keep a .xls copy.

If you need access to Excel features that SpreadsheetML doesn't support, you might try tools like Spreadsheet::WriteExcel, a Perl module, available through http://cpan.org, or POI, a Java library available at http://jakarta.apache.org/poi/. These both operate on .xls files, not SpreadsheetML, and have their own limitations, but they tend to be different limitations than those of SpreadsheetML.


From the Excel user's perspective, opening a SpreadsheetML XML document is just like opening a spreadsheet with one minor complication. Excel shows all the XML documents in the current directory as choices to open, when they may not in fact contain SpreadsheetML. Excel looks for the mso-application processing instruction at the start of an XML document. If it finds one, it marks the file with a Word, Excel, or other Office logo, as shown in Figure 7-1.

Figure 7-1. The Open dialog box showing SpreadsheetML, WordML, other XML, and regular Excel files
figs/oxml_0701.gif


If a user happens to pick an XML file that Excel doesn't understand automatically (even, for instance, a WordML file), they'll be confronted with the dialog box shown in Figure 7-2.

Figure 7-2. The dialog box for opening XML files that don't contain SpreadsheetML
figs/oxml_0702.gif


This dialog box is very useful for the functionality described in Chapter 6, but users who open XML files containing SpreadsheetML will never have to deal with it everything looks just like it does when opening a traditional .xls file.

Saving Excel files as SpreadsheetML files is similarly simple. The Save As dialog box, shown in Figure 7-3, offers an "XML Spreadsheet (*.xml)" option right under the usual "Microsoft Excel Workbook (*.xls)" choice.

Figure 7-3. Saving a spreadsheet to the SpreadsheetML XML spreadsheet format
figs/oxml_0703.gif


If you're especially gung-ho about working with XML spreadsheets, you can set "XML Spreadsheet" to be your default file format in the Transition tab of the dialog box opened by selecting Options . . . from the Tools menu, as shown in Figure 7-4.

Figure 7-4. Setting the SpreadsheetML XML spreadsheet format to be the default
figs/oxml_0704.gif


Using any of these approaches, you'll be able to read and write XML Spreadsheets from within XML.



Office 2003 XML
Office 2003 XML
ISBN: 0596005385
EAN: 2147483647
Year: 2003
Pages: 135

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net