docx“文件已损坏"; Microsoft Word中的错误 [英] docx "File is corrupt" error in Microsoft Word

查看:196
本文介绍了docx“文件已损坏"; Microsoft Word中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个程序,该程序打开docx包并更改"word/document.xml"中的某些<w:t>-文本.当我用Microsoft Word打开新生成的docx时,它给我一个错误-文件已损坏".但是,如果在"Open XML SDK Tool"中查找模板docx和结果docx文件之间的差异,则"word/document.xml"中只有两行更改.看截图:

I wrote a program, which open docx package and changes some <w:t>-text in "word/document.xml". When i open new generated docx in 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:

程序不涉及文档格式,样式或内容.仅<w:t>

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

那么,什么会引起Microsoft Word中的文件已损坏"错误?

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

并且此错误仅出现在Microsoft Word中.例如,Mac OS X上的OpenOffice和TextEdit可以打开生成的文件而不会出现任何错误.

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

我上传了这些 docx文件,因此您可以自己查看它们.

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

推荐答案

我会盲目的猜测,并说您修改的文档包含UNIX样式的行尾. Word 2003不能容忍\n行尾,它需要\r\n,而Word 2007/2010更能容忍并接受两个版本.

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.

请确保在修改文档时仅使用\r\n.

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

更新:我检查了您的文档,实际上文档XML部分使用UNIX样式的行结尾.

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

更新2:您的结果文档中包含一个附加文件:.DS_Store.从存档中删除该文件,文档将打开.

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

这篇关于docx“文件已损坏"; Microsoft Word中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆