April 23, 2011, 5:02 p.m.
posted by ska
Excel-Friendly XML Schemas
Several characteristics make an XML schema more amenable to being mapped into Excel. First, an XML schema should have one root element. In our example in this chapter, the root element is Order. If a schema supports more than one root element, you must choose which element will be the root element when adding the XML map to the spreadsheet.
Unsupported XML Schema Constructs
Excel does not support several XML schema constructs. Figure lists these constructs.
Constructs That Can Be Mapped But Not Exported
There are also several things that can be mapped, but the generated mappings cannot be exported as XML. You have already seen that if an XML mapping is denormalized, it cannot be exported. You also cannot export a list of items containing a second list of items. Choice elements also cannot be exported.
The other general class of issues that prevents exporting is when a mapped element's relationship with another element it is related to cannot be preserved by the mapping. For more information on these types of mapping issues, consult the Excel documentation.
VSTO puts some additional requirements on schema mapping if you want to use a schema-mapped spreadsheet with VSTO. First, you need to have a schema mapping that can be exported. Second, all the schema mapping must be within a single worksheet. Although Excel will let you map some elements of the schema to Sheet1 and other elements to Sheet2, VSTO requires that all schema mapping for a given schema be on the same sheet.
As you saw earlier in this book when mapping dates, Excel can automatically pick cell formatting based on the type in the schema. When we dragged a date into Excel, Excel prompted to change the cell formatting. Figure shows how Excel maps schema types to Excel cell-formatting settings.