This project has moved and is read-only. For the latest updates, please go here.

openxml sdk v2.0 - corrupted document

Oct 28, 2011 at 2:56 PM
Edited Oct 28, 2011 at 3:02 PM

I just realized, I have posted it on 'python tools' and not ironpython forum. Please, ignore



I am trying to use openxml sdk v2.0 together with python 2.7.1 (was 2.7.0). I have managed to generate the mini document out of the csharp (

However if I try to do it from python, the produced document is corrupted. Word complains about 'parts missing or invalid'. Unzip spits the following:


$ unzip -t ../foobar.docx
Archive:  ../foobar.docx
    testing: word/document.xml      
  error:  invalid compressed data to inflate
    testing: _rels/.rels              OK
At least one error was detected in ../foobar.docx.

Is there some sort of fundamental incompatibility between openxml sdk and ironpython? Mixed zip libraries?



And the code I use for testing:


import clr
clr.AddReferenceToFileAndPath("C:\Program Files\Open XML SDK\V2.0\lib\DocumentFormat.OpenXml.dll")
from DocumentFormat.OpenXml.Packaging import WordprocessingDocument
from DocumentFormat.OpenXml import WordprocessingDocumentType
from DocumentFormat.OpenXml.Wordprocessing import Text,Paragraph,Run,Document, Body

package = WordprocessingDocument.Create( 'c:/Users/rejap/Desktop/foobar.docx', WordprocessingDocumentType.Document)
package.MainDocumentPart.Document = Document(Body(Paragraph(Run(Text("""asdfasdfasdfaasdfa""")))))