poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Fisher <dfis...@jmlafferty.com>
Subject Re: Servlet and Excel
Date Fri, 13 Jan 2006 16:28:06 GMT
Hi Daniele,

I think I can help. Here is an example using tomcat.

(1) In Tomcat 4.1.31, in your web.xml

    <servlet>
         <servlet-name>modelxls</servlet-name>
         <servlet-class>com.pathtoyour.XlsServlet</servlet-class>
     </servlet>

     <servlet-mapping>
         <servlet-name>modelxls</servlet-name>
         <url-pattern>/yourxls.jsp</url-pattern>
       </servlet-mapping>

The url-pattern doesn't  have to be yourxls.jsp, it could be *.xls or  
xls/*, etc.

(2) Your xls servlet.

public class XlsServlet extends HttpServlet {

     public void doGet(HttpServletRequest request,  
HttpServletResponse response) throws ServletException, IOException {

             response.setContentType("application/vnd.ms-excel");
             response.setHeader("Content-disposition",  
"inline;filename="+whatever+".xls");

	// output your poi output to response.getOutputStream()\

...

My experience indicates that this is the best Content Type and  
Disposition. You can change "inline" to "attachment" if you want to  
try to force the save as dialog. Note that I say try, as user's IE  
settings can get in the way and the only way to fix that is to go to  
the other Explorer - Windows Explorer and change the way that  
the .xls files (application/vnd.ms-excel) are "Viewed."

Good luck.

Regards,
Dave

On Jan 13, 2006, at 10:09 AM, Donahue, Michael wrote:

> Can you explain what you mean by "responding with a jsp page" a  
> little more.
> I have some code that will send back the spreadsheet into an IE  
> browser for
> display, but it wants the whole screen.  I can also send it as a  
> file for
> download.
>
> -----Original Message-----
> From: Vaccari, Daniele [mailto:Daniele.Vaccari@provincia.bz.it]
> Sent: Friday, January 13, 2006 2:28 AM
> To: poi-user@jakarta.apache.org
> Subject: Servlet and Excel
>
> Hi
>
> I need to find an example on how to produce an Excel file from a  
> servlet
> and how to send it to the user responding with a jsp page. Does anyone
> know where can I find a similar example?
>
> Thank you
> Daniele
>
> ********************************************************************** 
> ******
> This email may contain confidential material.
> If you were not an intended recipient,
> Please notify the sender and delete all copies.
> We may monitor email to and from our network.
> ********************************************************************** 
> ******
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
> Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
> The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/


Mime
View raw message