Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

unable to open excel document

 
rutuja patil
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to open the excel document in my web application. I am using apache poi api for excel documents. My application runs on jboss and it is not able to open the excel sheet. It works fine on weblogic. But when I run it on jboss it doesn't open the excel document.

Thanks
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does "it doesn't open" mean? What happens when you run the code that is supposed to open the file? Also post the code using CODE tags.
 
rutuja patil
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
actually in application there is a jsp page which opens the excel document in new window:


when user clicks on Excel link it gives the pop up box saying could not open the userList.xls document.

As per application, when user clicks on Excel link it calls the servelet which creates the excel document using apache poi. I put some log messages in app code and all code getting executed successfully.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How have you verified that what the server streams to the browser upon clicking the link is, in fact, a proper Excel document?
 
rutuja patil
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The server didn't have a problem creating this stream in WebLogic 9.2. The code used to create the document and associated stream have not been altered in the conversion to JBoss. Upon examining the logs it also appears that the stream is created successfully, but the results don't show up in the browser tab. IE will display the message "Microsoft Office Excel cannot access the file. There are several possible reasons: The filename or path doesn't exist, The file is being used by another program, The workbook you are trying to save has the same name as a currently open workbook." I believe that this message is a red herring to the real problem, but the application logs have been less than forthcoming.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what's the answer to my question?
 
rutuja patil
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am sorry, but I don't know how to verify the stream. can you please tell me how to verify? i just tried to explain what i did to figure out the problem...
 
rutuja patil
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found the solution. I added the following two lines in servelet and it worked:
response.setHeader("Pragma", "public");
response.setHeader("Cache-Control", "max-age=0");

Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic