Showing posts with label DOCX. Show all posts
Showing posts with label DOCX. Show all posts

Monday, September 08, 2008

Office 2007 document upload - files corrupt

Adding a file to SharePoint can be implemented through a web service as described in the note from Microsoft. It works fine - for all types of documents except for Office 2007 documents!

Upload goes fine - but when you try to open the file using Office you get the following errors:




The Office Open XML file cannot be opened because there are problems with the content.

Solution

SharePoint seems to have an error when adding documents to the filecollecting using the

SPFolder.Files.Add

function. If you add from a byte-array it simply fails with Office 2007 documents. But if you convert the byte-array into a stream, e.g. by saving the byte-array into a file and loading it into a stream, then it works. It's unclear to me why this error occurs - but Microsoft probably drops a single byte in the byte-scenario - which is critical for Office 2007 documents, but other documents seems to survive.

Input and comments very much appreciated.

Saturday, August 16, 2008

Create a DOCX programmatically

This blog provides a simple example on how to create an Office 2007 docx document.