Hi,

I've played with this extensively.  The short answer is "yes", but not with
DisplayTag.  You should create a web page that is a cleanly formatted table
of row/column data, with nothing else in the page.  (Other stuff, like
paragraphs or subtables confuse the row/column mapping algorithm and cause
Excel to be idiosyncratic about formatting).  Use CSS to format the cells
with colors, borders, etc.  Put this in a style sheet or at the top of the
page to set landscape mode.

<style>
@page
{margin:0.5in .75in 0.5in .75in;
mso-header-margin:.5in;
mso-footer-margin:.5in;
mso-page-orientation:landscape;}
</style>

You'll also need to set the content type to Excel (directing the browser to
open Excel automatically).  Do something like this:

response.setContentType("application/vnd.ms-excel;charset=iso-8859-1");
response.addHeader("Content-disposition","attachment; filename=" +
"export.xls" );

Incidentally, there's actually 4 ways for a webapp to output an Excel
spreadsheet, not just two:

(1) Output a comma separated set of numbers like DisplayTag (with the
appropriate content type)

(2) Output a HTML row/column table.  Use CSS attributes to define
formatting, and embedded XML (Excel2000+) to define document characteristics
like sheet names.  Most standard CSS attributes work, plus Microsoft has
defined a number of special ones for things like Excel formatting).  Works
for Excel 97+.

(3) Output an XML file in Excel 2003's XML format.  (won't work for earlier
versions).

(4) Use POI (or one of the commercial products) to insert data into an
existing XLS file used as a template, then send this binary file back to the
user.

There's pros and cons to each of these.  I usually do #2.  It surprises me
that DisplayTag doesn't (this must mean the formatting is lost when you
output to Excel).

Best,
WILL

> >
> > On May 22, 2004, at 11:30 AM, Phil Ardaugh wrote:
> >
> > > Is it possible to pass to Excel certain formatting
> > > such as landscape format using the display tag?
> > >
> > > Thanks
> > >
> >
> >
> >
> > -------------------------------------------------------
> > This SF.Net email is sponsored by: Oracle 10g
> > Get certified on the hottest thing ever to hit the market... Oracle 10g.
> >
> > Take an Oracle 10g class now, and we'll give you the exam FREE.
> > http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
> > _______________________________________________
> > displaytag-user mailing list
> > [EMAIL PROTECTED]
> > https://lists.sourceforge.net/lists/listinfo/displaytag-user
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by: Oracle 10g
> Get certified on the hottest thing ever to hit the market... Oracle 10g.
> Take an Oracle 10g class now, and we'll give you the exam FREE.
> http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
> _______________________________________________
> displaytag-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/displaytag-user



-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g. 
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
displaytag-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/displaytag-user

Reply via email to