Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

cannot open office2007 documents from the java application

 
Saurav Das
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

one of my application based on J2EE, needs to eb upgraded to open office 2007 documents from the application web pages. But when tried to open the files, its opening in open-xml formats and says its corrupted before actually opening up. fyi, we use MS office 97-2003 documents MIME type as
doc=application/msword with this i am able to open the .doc files. But when tried with docx MIME types as
docx=application/vnd.openxmlformats-officedocument.wordprocessingml.document, the file is not opening properly and it asks to save the file again, which is wrong.

Can anybody please help me in this situation???
Appreciate an urgent help!
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

Can the client (an up-to-date version of MS Office, I assume?) open the files directly from a file system?
 
Saurav Das
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:Welcome to JavaRanch.

Can the client (an up-to-date version of MS Office, I assume?) open the files directly from a file system?



yes, users system is up-to-date with MS Office. When i try to open, suppose sample.docx, its opening fine. But while same docx file i want to open from the Application , it is not opening properly. It shows the file corrupted while opening
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What process opens it? Have a look at task manager and see; my suspicioun is it may be IE itself rather than Office 2007. If your content type header is application/vnd.openxmlformats-officedocument.wordprocessingml.document it should work (assuming Office 2007 is properly installed).

If it is IE, check the content type again to make sure the mime type is correct.
 
Saurav Das
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using IE6 and IE7 but MIME type i am using
docx=application/vnd.openxmlformats-officedocument.wordprocessingml.document

what it would be for IE6 or IE7? please help!
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Exactly the same, the MIME type doesn't need to change based on the target browser. What process is opening your document?
 
Saurav Das
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Sturrock wrote:Exactly the same, the MIME type doesn't need to change based on the target browser. What process is opening your document?


Whenever we are trying to open the 'docx' files through Website, it opens a new window pop-up and ask whether to open/save/cancel the file.

If I click on 'open' , it opens the file but its acorrupted one.

The process is something like it checks in the java code for extension type like:

docx=application/vnd.openxmlformats-officedocument.wordprocessingml.document;

and accordingly it opens up the file.

for doc type files, we have like:

doc=application/msword;

Please advise!
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

If I click on 'open' , it opens the file but its acorrupted one.

What process does the operating system use to open this? Look at task manager and see what process starts when you click open. Is it Word 2007?
 
Saurav Das
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, while opening it, i just checked the process in task manager in my system, it shows WINWORD.exe

is it correct?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, this tells you that IE is probably correctly interpreting the MIME type in the response and using Word to open it so you know its probably not the MIME type mapping.

Do you have more than one version of Office installed on this machine? If you save the file first then open it by running Word 2007 and selecting it from the file menu is it still corrupted?
 
Saurav Das
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul, I still find .docx file corrupted while save the it and then opening it. It happens like:

The Office Open XML file,say, sample.docx cannot be opened because there are problems with the contents.

The file is corrupt and cannot be opened.

NEXT it says, word found unreadable content in Sample.docx Do you want to recover the contents of this document? If you trust the source of this document,click YES

and if i click the 'yes', it somehow opens the file but the entire process is not what it should be. Even the file opened is asking for 'Save' once i am closing it.

this much make sense?
 
Sean Clark
Rancher
Posts: 377
Android Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happens if you try to save the file rather than opening it from within the browser?
Try saving it to your desktop and opening from there.
 
Saurav Das
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It gives me the same error. The docx file is still corrupted. No luck

Please help me ..it's urgent!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64822
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please read this.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Saurav Das wrote:It gives me the same error. The docx file is still corrupted. No luck

Please help me ..it's urgent!

OK, so you know its probably not the MIME type that is the issue, it sounds like the document itself is corrupted for some reason or another (just as Office is telling you). With regards to the download I suppose the only other possibility is you are not streaming the whole document? Other than that, I would turn my attention to how the document was created in the first place.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic