다음을 통해 공유


Simple debugging of Office XML files

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:

  1. 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) 
  2. 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.
  3. Make sure it's Valid: Your files need should be valid according to our schemas. The schemas are freely available to download here: https://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.

-Brian

Comments

  • Anonymous
    July 01, 2005
    If you are a developer, I would recommend a much better option. Open the document in the XML Editor (VS 2005). The error list will tell you what's wrong with the file. There are a lot more great features in the new XML Editor. To see some of them, read this article (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnxmlnet/html/xmltools.asp) by Neetu Rajpal - Lead PM on the XML Tools team or view a video presentation by Ken Levy (http://channel9.msdn.com/ShowPost.aspx?PostID=64642).

    Stan Kitsis
  • Anonymous
    July 05, 2005
    Great suggestion Stan, thanks.
    VS 2005 makes it a lot easier to work against the schemas and debug any well formedness errors. This in combination with the error messages returned by the Office applications should have you in pretty good shape.

    -Brian
  • Anonymous
    July 12, 2005
    Hi Brian;
    I'm sorry for using this space not to write a comment to your post but I would like to ask you something about XML file.
    I try to explain you my problem: I have XML files that use different DTDs, so when I Load one of them how cuold I be sure that I' reading right file? I though that I could compare DTD of the opening XML file and one Iexpected to read. To do this I use comparison between file content but it cuold be very long. Is there a method to make this comparision more quickly?
    Thank you for your attention and your kindness.

    Francesca
  • Anonymous
    July 21, 2005
    The comment has been removed
  • Anonymous
    July 21, 2005
    Hi Eric,
    Right now, we aren't really talking much about the rest of what's to come in Office 12. PDC, which is in September will carry the next wave of announcements (as you can see from the lineup of sessions).
    We announced the file formats really early so we had enough time to educate folks on the implications as well as gather tons of feedback. The first beta isn't for a few months still though, so you can expect to hear a lot more leading up to that.
    -Brian
  • Anonymous
    February 06, 2006
    Hi Brian

    Can you comment on how will the Office 12 SpreadsheetML support macros, pivot tables, and Excel charts? These were some of the features that Office 2002 Excel XML did not support.

    Thanks
  • Anonymous
    February 13, 2006
    Abhinav,
    Macros are only supported in the macro-enabled format, and they are stored the same as in Word and PPT (a seperate binary part within the ZIP package). Charts are also stored as their own seperate part in the package, but they are represented with XML. Pivot tables will also be represented in XML (I'll try to post some examples).

    -Brian
  • Anonymous
    April 04, 2006
    Hello,
    I'm a developper who is generating reports in excel programming with PHP. My problem is when I try to open one file excel I get one error message and indications about one error log created in some directory... but that directory and that file doesn't exists.
    ¿Can anyone help me?

    Thanks a lot for your help.


    Rafael
  • Anonymous
    April 05, 2006
    Hello again,
    Yesterday I forget to mention that I'm using Office 2003 Professional.

    Thanks a lot.

    Rafael
  • Anonymous
    April 05, 2006
    I founded the location of the error logs... It was strong hidden.
    Thanks anyways.

    Rafael
  • Anonymous
    June 15, 2009
    PingBack from http://unemploymentofficeresource.info/story.php?id=9224