开发者

docx "File is corrupt" error in Microsoft Word

I wrote a program, which open docx package and changes some <w:t>-text in "word/document.xml". When i open new generated docx i开发者_Python百科n Microsoft word, it gives me an error — "file is corrupted". But if look in "Open XML SDK Tool" diffs between template docx and result docx files — there is only two line changed in "word/document.xml". Look at screenshot:

docx "File is corrupt" error in Microsoft Word

Program doesn't touches document format, styles or smth. Only text in <w:t>

So, what's can provoke "file is corrupted" error in Microsoft Word?

And this error appears ONLY in Microsoft Word. For example OpenOffice and TextEdit on Mac OS X open generated files without any errors.

I upload these docx files, so you can look at them by yourself.


I'd make a blind guess and say that the document you modified contains UNIX-style line endings. Word 2003 does not tolerate a \n line ending, it requires \r\n whereas Word 2007/2010 is more tolerant and accepts both versions.

Make sure to only use \r\n when modifying the document.

Update: I checked your document, and indeed the document XML part uses a UNIX-style line ending.

Update 2: You have an additional file included in your result document: .DS_Store. Remove that from the archive and the document will open.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜