Those previous two posts were meant to help people unfamiliar with Office XML get a taste of how you would go about building your own spreadsheets. The power of doing this with XML is that you can read and generate these files anywhere you want. You don't need Office on the machines you are using to work with the files. This is especially important when dealing with large numbers of documents or as part of a web service, as the Office applications are not supported running in an unattended mode on a server. XML lets you do it in a supported, and very efficient way.
As you start to experiment with XML in the Office applications, you will no doubt create XML files that can't be opened. By default there aren't great error messages reported, because we don't want to confuse the average end user. If the file can't be opened, then it can't be opened, there isn't much that the average user can do to fix it. If you are a developer or solution builder though and you actually generated that file, then it would be nice to get some more information on the problem. There are a number of options you have to make debugging your files easier. Here are the steps you should take when you have trouble opening a file:
- Check the Error Message: Look at the error message. In Excel for instance, there will be a log file generated that has the information on the error. In Word, there is an advanced mode for the error dialog that gives you more information on what happened. In Word, you should pretty print your files first as the error message reports the column and line number of the problem (and a error saying Line 1 Column 2043 isn't too helpful)
- Check for Well Formed XML: One common problem if you weren't using an XML editor to generate your file is that your files might not be well formed XML. To check for well formedness, you can just open the file in IE. If the XML isn't well formed, IE will tell you so and notify you where the problem is.
- Make sure it's Valid: Your files need should be valid according to our schemas. The schemas are freely available to download here: http://www.microsoft.com/office/xml/default.mspx. You can take an XML parser that supports schema validation such as MSXML and validate your file against the schema.