poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From EP...@upstate.com
Subject RE: Streaming XLS file to screen
Date Mon, 14 Apr 2003 16:13:12 GMT
This topic has come up many times, and there are lots of weirdnesses
depending on browser version and tomcat/servlet container version.  I ended
up saving to disk because I could never get this to work reliable.  However,
others have said it works great every time!  So your milage may vary. 

I am hoping someone will add to poi/contrib a servlet that does all of
this..  Hand it a file or a stream, and out it comes on the browser window!

Eric

-----Original Message-----
From: Nate [mailto:nmcminn@charter.net]
Sent: Monday, April 14, 2003 12:12 PM
To: POI Users List
Subject: Re: Streaming XLS file to screen


Gotcha.  You should be able to do this without saving to disk.  Can you post
the source?  At least to the part of the servlet that sends the content to
the browser?  That would make things easier.

----- Original Message -----
From: "Lior Shliechkorn" <liorshliech@yahoo.com>
To: "POI Users List" <poi-user@jakarta.apache.org>
Sent: Monday, April 14, 2003 10:54 AM
Subject: Re: Streaming XLS file to screen


> App Details: Wind2k && Tomcat 4.0.5I don't want to save the files locally,
since there are a few options for
> each report to be run and I don't want to have a file create for each
report
> and for each user running a report. File sizes can vary drastically, and I
> don't want to have to take care of the storage and clean up of the files.
> So it's easier for the user to take care of that end. The process that
creates the report is as follows:
> 1. JSP page with a form for the report desired (with an option to view as
excel)
> 2. Servlet to process which report servlet to pass the (req, res) to.
> 3. Servlet for the report (2 flavors: 1) for HTML view 2) for excel format
view. I hope this gives you a better picture of what is being done. And the
higher ups of
> course want this to happen and not be saved locally.
>
>
> Nate <nmcminn@charter.net> wrote:You may have to set the content length.
If this doesn't work for you
> (without knowing the particulars of your app I can't say for sure). Just
> write it out to a temp directory on the server, and then do a
> response.sendRedirect(relative file path) to the saved file. For example
>
> tomcat app root
> c:\tomcat\webapps\myapp
>
> save file to c:\tomcat\webapps\myapp\temp\12345.xls
>
> from the myapp context, redirect like this
>
> response.sendRedirect("temp/12345.xls");
>
> Is there any reason in particular that you don't want to save it to disk
on
> the server?
>
> ----- Original Message -----
> From: "Lior Shliechkorn"
>
> To: "POI Users List"
>
> Sent: Monday, April 14, 2003 10:25 AM
> Subject: Re: Streaming XLS file to screen
>
>
> > Nate, Thanks again for the prompt resonse. I was not able to get this to
> work. The file download screen shows up and then an error message with the
> message that the internet site is unavailable pops up and terminates the
> download. Any ideas why this would be happening? Lior
> >
> > Nate wrote:Well, doing this in a servlet, you have a
> response object that you are
> > passed in your servlet service methods (POST, GET, etc). code like the
> > following should work
> >
> > //get an output stream to the browser
> > ServletOutputStream tobrowser = response.getOutputStream();
> >
> > //set the response content type
> > response.setContentType("application/octec-stream");
> >
> > //write the book out to the output stream
> > WorkBook.write(tobrowser);
> >
> > //close streams and clean up (flush may not be needed)
> > tobrowser.flush();
> > tobrowser.close();
> >
> > ----- Original Message -----
> > From: "Lior Shliechkorn"
> >
> > To: "POI Users List"
> >
> > Sent: Monday, April 14, 2003 9:58 AM
> > Subject: Re: Streaming XLS file to screen
> >
> >
> > > I'm very new to Java in general, would you be able to give me an
example
> > of what you're talking about. Do I need to put out.println("file
output")
> ?
> > I'm not quite certain. Thanks again.
> > >
> > > Nate wrote:If this is being done through a web
> > application, simply get the output
> > > stream to the browser, write the constructed excel document out. Oh,
and
> > > make sure that you set the content type to application/octet-stream
(or
> > > alternately, if you want it to open in the browser for MS users, set
the
> > > content type to application/vnd.ms-excel)
> > >
> > > --Nathan McMinn
> > >
> > > ----- Original Message -----
> > > From: "Lior Shliechkorn"
> > >
> > > To: "Poi"
> > >
> > > Sent: Monday, April 14, 2003 9:48 AM
> > > Subject: Streaming XLS file to screen
> > >
> > >
> > > > hello, I would like to be able to have the user save the file on
their
> > > system by outputting it to the screen, and not saving it to my disk
> after
> > it
> > > has been generated. I'm using POI to generate reports for Excel users,
> and
> > > would like to not have to save the file to my disk first and then have
> the
> > > users be able to access it. Is there a way to have a pop up to ask
them
> to
> > > open or save as so that it all happens on the user end? Thank you very
> > much
> > > for your time,Lior
> > > >
> > > >
> > > > ---------------------------------
> > > > Do you Yahoo!?
> > > > Yahoo! Tax Center - File online, calculators, forms, and more
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: poi-user-help@jakarta.apache.org
> > >
> > >
> > >
> > > ---------------------------------
> > > Do you Yahoo!?
> > > Yahoo! Tax Center - File online, calculators, forms, and more
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: poi-user-help@jakarta.apache.org
> >
> >
> >
> > ---------------------------------
> > Do you Yahoo!?
> > Yahoo! Tax Center - File online, calculators, forms, and more
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: poi-user-help@jakarta.apache.org
>
>
>
> ---------------------------------
> Do you Yahoo!?
> Yahoo! Tax Center - File online, calculators, forms, and more



---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-user-help@jakarta.apache.org

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message