• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.


 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Shantanu Rathore
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 3
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Nikil,

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

Thanks

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Where can I get the code for the explanation you have given.
 
Saloon Keeper
Posts: 7582
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Where can I get the code for the explanation you have given.



Welcome to the Ranch. The code for what,exactly? Several things were discussed in this topic. After 11 years, it's unlikely that any of the original participants are still around.
 
Tomorrow is the first day of the new metric calendar. Comfort me tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic