A simple web-app to retrieve and display an Excel Sheet
Joined: Feb 12, 2010
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?
//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.
Joined: Mar 22, 2005
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.
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.
Joined: Dec 26, 2010
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
Author and all-around good cowpoke
Joined: Mar 22, 2000
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.
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.
Pawan Kr Gupta
Joined: Nov 21, 2010
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
Joined: Dec 26, 2010
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!
Joined: Mar 16, 2011
Can you share your code so that it will be easy to sketch out the solution.