aspose file tools*
The moose likes Other Open Source Projects and the fly likes A simple web-app to retrieve and display an Excel Sheet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "A simple web-app to retrieve and display an Excel Sheet" Watch "A simple web-app to retrieve and display an Excel Sheet" New topic
Author

A simple web-app to retrieve and display an Excel Sheet

Shantanu Rathore
Greenhorn

Joined: Feb 12, 2010
Posts: 6
Hi,

What I am trying to do: Reading an Excel sheet from a remote location and passing it on to a JSP page.

What I have managed so far: I have managed to read the Excel Sheet from the remote location. This was done using a Java class and POI.

What I need help with:
1. How to pass the Excel Sheet(retrieved in the java file) to a JSP page which will display the excel sheet. I have researched somethings but am not clear how to go about doing it.
2. I am OK with the JSP page opening the excel sheet separately, but is it possible to display it within the JSP page itself? I was wondering about using iFrames but i think its client side basically. Is it possible to use it in a JSP?

Code Snippets:-

ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());

//baos is a ByteArrayOutputStrream whichread the Excel sheet from the remote location.

//POI Coding to read the excel file
POIFSFileSystem fs = new POIFSFileSystem(bais);
HSSFWorkbook wb = new HSSFWorkbook(fs);

Application FLow:- A HTML(user enters the filename here) ==> passes filename to ==> JSP==> passes filename to ==>Java (retrieves file)
Java==> passes File to ==>JSP : DISPLAYS THE FILE


Thanks in advance.


Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41574
    
  54
Firstly, you can't use JSPs for handling binary content. You will need to make this a servlet.

Secondly, do you want to show just some data from the sheet, or do you want to show the entire file? If the latter, then POI has no part in this - you would just stream the file to the client with an appropriate content type, and let the browser deal with it. Which *might* mean that it gets displayed in the browser, but it *might* also mean that the user is asked what to do with it (open it or save it), and it *might* also mean that the file is saved without the user being asked. But these are client-side settings that the web app can't influence.


Ping & DNS - my free Android networking tools app
Shantanu Rathore
Greenhorn

Joined: Feb 12, 2010
Posts: 6
Dear Ulf,

You are right. If I show the whole file then:-

1. It asks the user to open the file/save it.
2. If I chose open, then it shows the file in the screen and asks the user whether he/she wants to save the changes made if any thing is changed in the file.
3. If I chose open and make no changes and close the file after viewing it, it closes without saving.

I am not sure whether it is save somewhere in the temporary internet files.

I need to display some part of the excel sheet on the screen. Hence I have used poi.
I am working on displaying the code in a tabular format using table tags.

I didn't figure out:"then POI has no part in this - you would just stream the file to the client with an appropriate content type, and let the browser deal with it."

Thanks a lot.

Shantanu
niks Reddy
Greenhorn

Joined: Dec 26, 2010
Posts: 3
please anybody post a jsp program that reads data from microsoft excel and displays it in a table formatin the browser....(using apache tomcat poi) ......my project is that i should enter an excel file name and it should read that file and display in the form of table in webrowser by using jsp,apachetomcat,poi please.please.please.......
post as soon as possible.......


thanks in advance......hoping for your earliest replies
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
1. Bold fonts , caps, color etc will not accelerate any response.
2. You are much more likely to get help in solving your problem, not a complete gift-wrapped solution, - thats just the way the ranch works.
3. This old rancher advises the following:

Stay away from the JSP/servlet environment until you have a demonstration program which can read a spread sheet, extract value, and format a HTML page with the desired formatted table as output to a file. Take it from me, JSP/servlets introduces a whole new set of complications and slows down the edit/compile/test cycle.

Bill
niks Reddy
Greenhorn

Joined: Dec 26, 2010
Posts: 3
I am C.Nikhilesh Reddy.Thanks for Your replies to my post. Can't we really read data from excel and display it in web browser in the form of table(i.e retreiving and creating in a template form) using jsp,tomcat-poi,.If there are any alternatives by which we can really display please suggest them. Any how I want to do this project using any technology.

Thank you

Regards
Nikhil
Pawan Kr Gupta
Greenhorn

Joined: Nov 21, 2010
Posts: 26
There are following stpes to read the excel.

1- store the file at application Server using MultipartForm and uploadbean.jar
2- Read the excel files using jxl.jar
niks Reddy
Greenhorn

Joined: Dec 26, 2010
Posts: 3
Thanks all..
I managed to read the excel sheet using jsp,apache(poi) and display it in a web browser. But now the problem is the displayed content should go to an email in body(i.e., the present page should redirect to another page where in the output displayed by the present page should be used).I tried to use include file directive tag but it goes to an infinite loop.Is there any other way of doing it.
Any ideas, or a working code would be highly appreciated!
suhail awez
Greenhorn

Joined: Mar 16, 2011
Posts: 1
Hi Nikil,

Can you share your code so that it will be easy to sketch out the solution.

Thanks

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: A simple web-app to retrieve and display an Excel Sheet