Joel on Software had article about the file formats several years ago. Apparently big chunks of the files are basically just memdumps. http://www.joelonsoftware.com/items/2008/02/19.html
I don't know if this is still the best way. LibreOffice has came a long way for sure, but still doesn't reproduce Word's layout perfectly (which is still the expectation).
E.g. if I open a word document in libreoffice (to do e.g. review and commenting), save it without any changes to the layout, then I'd expect the original author to have the same document layout as before... and that is not so. The same applies to LibreOffice Calc - opening and saving the document produces changes.
Can't you just have a unit test that verifies that reading and immediately writing a document should keep it completely unchanged, except possibly for metadata?
I do not envy those who have spent years of their life trying to reverse engineer .doc and .xls formats... those are pretty nasty.