SpreadsheetML is the XML vocabulary included with Excel 2003 as well as Excel XP. It consists of tags that can describe all aspects of an Excel spreadsheet. Just as you can with WordprocessingML, you can write the SpreadsheetML from scratch in an XML or text editor, or you can allow Excel 2003 or XP to generate the content for you automatically.
SpreadsheetML documents start with an XML declaration and processing instruction. The root node <Workbook> includes references to a number of namespaces.
<?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:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40">
The XML document has the following structure:
<DocumentProperties> <!-- information about document properties --> </DocumentProperties> <ExcelWorkbook> <!-- information about the Excel workbook --> </ExcelWorkbook> <Styles> <!-- information about the styles --> </Styles> <Worksheet> <Table> <!-- multiple Column tags --> <Column /> <!-- multiple Row blocks --> <Row> <Cell> <!-- Cell data type and contents --> </Cell> <!-- multiple Cell tags --> </Row> </Table> <WorksheetOptions> <!-- information about the Worksheet options --> </WorksheetOptions> <Sorting> <!-- information about sorting --> </Sorting> </Worksheet>
The contents of the Excel worksheet are contained within the <Table> element. The element contains two attributes, ExpandedColumnCount and ExpandedRowCount , which indicate the table size . The <Table> element contains a number of <Row> elements, which in turn contain <Cell> elements. A <Data> child element contains the content of each cell. It has an attribute Type , which indicates the datatype of the contents. Its also possible for a <Cell> to include a Formula attribute that reflects the Excel formula used to generate the data.
When Excel opens a SpreadsheetML document, it wont prompt you about how to open the document. It opens the document natively, as if it was an Excel workbook. This is one of the advantages of working with SpreadsheetML documents. When you work with other XML documents, Excel prompts about how the file should be opened.
If youre using Excel to generate XML content for Flash, you may find the structure of a SpreadsheetML document a little unwieldy. It contains formatting information that youre unlikely to need, and all of the content for inclusion within Flash will be in the <Row> and child <Cell> elements. Youd be better off exporting the XML content from Excel using an XML map to refine the document structure.