You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mark Galbreath <ma...@qat.com> on 2003/05/15 16:35:46 UTC

Rendered Table to Excel?

I've got a JSP that includes 3 more JSPs, each rendering a table =3D =
populated with default values from the ActionForm.  The user may change any
of the values <html:text> except totals, which are calculated by a helper
=3D = utility class via the associated Action class and then displayed via
=3D = <bean:write> invocations. Once the user is finished entering values
and calculating totals, I want to display the result as an Excel
spreadsheet.

I've tried response.setContentType( "application/vnd.ms-excel" ) but get =
=3D all kinds of syntax errors at runtime.  I'm sure this is due to the
<jsp:include>s bringing in the other JSPs into the main JSP (I had to do
this to avoid the 64k byte method limit barrier), so what I need to do = =3D
is take the RENDERED HTML resulting from the calculations and change the
content type.

Anybody have any ideas about how (if) this can be done and like to share
them?  I've attached a partial screenshot of the rendered table for the
list's edification.

tia,
Mark


RE: Rendered Table to Excel?

Posted by Mark Galbreath <ma...@qat.com>.
Thanks for the tip - I had forgotten about POI.  HSSF is hysterical!

Mark

-----Original Message-----
From: mailinglist [mailto:mlst@mangoosta.fr] 
Sent: Thursday, May 15, 2003 10:48 AM
To: Struts Users Mailing List
Subject: Re: Rendered Table to Excel?


Le Jeudi 15 Mai 2003 16:35, Mark Galbreath a écrit :
> I've got a JSP that includes 3 more JSPs, each rendering a table =3D = 
> populated with default values from the ActionForm.  The user may 
> change any of the values <html:text> except totals, which are 
> calculated by a helper =3D = utility class via the associated Action 
> class and then displayed via =3D = <bean:write> invocations. Once the 
> user is finished entering values and calculating totals, I want to 
> display the result as an Excel spreadsheet.

Mark, you should have a look at POI, it may be what you're looking for :
http://jakarta.apache.org/poi/ and "Reading and Writing Excel Files with
POI": http://www.onjava.com/pub/a/onjava/2003/04/16/poi_excel.html

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



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


Re: Rendered Table to Excel?

Posted by mailinglist <ml...@mangoosta.fr>.
Le Jeudi 15 Mai 2003 16:35, Mark Galbreath a écrit :
> I've got a JSP that includes 3 more JSPs, each rendering a table =3D =
> populated with default values from the ActionForm.  The user may change
> any of the values <html:text> except totals, which are calculated by a
> helper =3D = utility class via the associated Action class and then
> displayed via =3D = <bean:write> invocations. Once the user is finished
> entering values and calculating totals, I want to display the result as
> an Excel spreadsheet.

Mark, you should have a look at POI, it may be what you're looking for :
http://jakarta.apache.org/poi/
and "Reading and Writing Excel Files with POI":
http://www.onjava.com/pub/a/onjava/2003/04/16/poi_excel.html

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


RE: Rendered Table to Excel?

Posted by Mark Galbreath <ma...@qat.com>.
That's pretty much the idea I was tossing over in my head; thanks for the
validation.  I'll give this a shot before delving into HSSF.

Mark

-----Original Message-----
From: Andreas Mack [mailto:vasquez@mediales.net] 
Sent: Thursday, May 15, 2003 11:35 AM
To: Struts Users Mailing List
Subject: Re: Rendered Table to Excel?


On Thu, 2003-05-15 at 16:35, Mark Galbreath wrote:

> I've tried response.setContentType( "application/vnd.ms-excel" ) but 
> get = =3D all kinds of syntax errors at runtime.  I'm sure this is due 
> to the <jsp:include>s bringing in the other JSPs into the main JSP (I 
> had to do this to avoid the 64k byte method limit barrier), so what I 
> need to do = =3D is take the RENDERED HTML resulting from the 
> calculations and change the content type.

What code produces the excel stream ? Your action should not forward to a
jsp, but just send out the excel stuff to the response output stream with
encodingf contentType and contentLength properly set. Return from this
action with null. I do this with pdf and it works very nicely - except for
small pdfs: IE feels better if the URL ends with .pdf. I had to write my own
map serializer for the download link to have a dummy parameter at the end.

> 
> Anybody have any ideas about how (if) this can be done and like to 
> share them?  I've attached a partial screenshot of the rendered table 
> for the list's edification.

I somehow can't see the screenshot. Hope the upper helps anyway.

-- 
Andreas Mack <va...@mediales.net>
mediales. GmbH


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



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


Re: Rendered Table to Excel?

Posted by Andreas Mack <va...@mediales.net>.
On Thu, 2003-05-15 at 16:35, Mark Galbreath wrote:

> I've tried response.setContentType( "application/vnd.ms-excel" ) but get =
> =3D all kinds of syntax errors at runtime.  I'm sure this is due to the
> <jsp:include>s bringing in the other JSPs into the main JSP (I had to do
> this to avoid the 64k byte method limit barrier), so what I need to do = =3D
> is take the RENDERED HTML resulting from the calculations and change the
> content type.

What code produces the excel stream ? Your action should not forward to
a jsp, but just send out the excel stuff to the response output stream
with encodingf contentType and contentLength properly set. Return from
this action with null. I do this with pdf and it works very nicely -
except for small pdfs: IE feels better if the URL ends with .pdf. I had
to write my own map serializer for the download link to have a dummy
parameter at the end.

> 
> Anybody have any ideas about how (if) this can be done and like to share
> them?  I've attached a partial screenshot of the rendered table for the
> list's edification.

I somehow can't see the screenshot. Hope the upper helps anyway.

-- 
Andreas Mack <va...@mediales.net>
mediales. GmbH


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


RE: Rendered Table to Excel?

Posted by Mark Galbreath <ma...@qat.com>.
Apparently, the mail server transforms GIFs to TXT documents.  The rendered
table looks like a typical HTML spreadsheet.

Mark

-----Original Message-----
From: Mark Galbreath [mailto:mark_galbreath@qat.com] 
Sent: Thursday, May 15, 2003 10:36 AM

I've got a JSP that includes 3 more JSPs, each rendering a table populated
with default values from the ActionForm.  The user may change any of the
values <html:text> except totals, which are calculated by a helper utility
class via the associated Action class and then displayed via <bean:write>
invocations. Once the user is finished entering values and calculating
totals, I want to display the result as an Excel spreadsheet.

I've tried response.setContentType( "application/vnd.ms-excel" ) but get all
kinds of syntax errors at runtime.  I'm sure this is due to the
<jsp:include>s bringing in the other JSPs into the main JSP (I had to do
this to avoid the 64k byte method limit barrier), so what I need to do is
take the RENDERED HTML resulting from the calculations and change the
content type.

Anybody have any ideas about how (if) this can be done and like to share
them?  I've attached a partial screenshot of the rendered table for the
list's edification.

tia,
Mark



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