aspose file tools*
The moose likes Java in General and the fly likes cannot open office2007 documents from the java application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "cannot open office2007 documents from the java application" Watch "cannot open office2007 documents from the java application" New topic
Author

cannot open office2007 documents from the java application

Saurav Das
Greenhorn

Joined: Jul 20, 2009
Posts: 7
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
Marshal

Joined: Mar 22, 2005
Posts: 39544
    
  27
Welcome to JavaRanch.

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


Ping & DNS - updated with new look and Ping home screen widget
Saurav Das
Greenhorn

Joined: Jul 20, 2009
Posts: 7
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

Joined: Apr 14, 2004
Posts: 10336

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.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Saurav Das
Greenhorn

Joined: Jul 20, 2009
Posts: 7
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

Joined: Apr 14, 2004
Posts: 10336

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

Joined: Jul 20, 2009
Posts: 7
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

Joined: Apr 14, 2004
Posts: 10336


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

Joined: Jul 20, 2009
Posts: 7
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

Joined: Apr 14, 2004
Posts: 10336

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

Joined: Jul 20, 2009
Posts: 7
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

Joined: Jul 15, 2009
Posts: 377

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.


I love this place!
Saurav Das
Greenhorn

Joined: Jul 20, 2009
Posts: 7
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

Joined: Jan 10, 2002
Posts: 60048
    
  65

Please read this.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: cannot open office2007 documents from the java application
 
Similar Threads
MIME Types
Java Html parser
.xlsx file not uploading properly
Java API for RTF to DOCX Conversion
Issue with MIME settings in WebSphere