You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Christian GARDERES <ch...@dpma.finances.gouv.fr> on 2001/10/15 10:51:39 UTC

[Fwd: Re: MS Excel and setContentType]

You said in this previous message that we can even embed some formating
and formulas in the velocitry template. Could you post some examples?

Thanks a lot.

-------- Original Message --------
De: "Chris Crossen" <cc...@home.com>
Objet: Re: MS Excel and setContentType
A: <tu...@jakarta.apache.org>

Excel recognizes html. An html table passed to Excel will be rendered
as a spreadsheet.

Have you tried the sample from my previous message? I put it into my
template directory, invoked it from IE, and Excel opened with the
spreadsheet you would expect to see.

----- Original Message -----
From: "Stephane Bailliez" <sb...@imediation.com>
To: <tu...@jakarta.apache.org>
Sent: Monday, October 15, 2001 1:11 AM
Subject: RE: MS Excel and setContentType



May I ask how you manage to disable the page assembler to stuff a
different
content type in the response ?

I don't see how you can send back something else correct since the
page
assembler will add html tags around your data...unless I missed
something I
don't see how we can do this without creating our own VelocityPage
that
implements a different strategy for assembling a page.

--
 Stéphane Bailliez
 Software Engineer, Paris - France
 iMediation - http://www.imediation.com
 Disclaimer: All the opinions expressed above are mine and not those
from my
company.



> -----Original Message-----
> From: Chris Crossen [mailto:ccrossen@home.com]
> Sent: Thursday, October 11, 2001 12:02 AM
> To: turbine-user@jakarta.apache.org
> Subject: Re: MS Excel and setContentType
>
>
> If you have Excel on the client (and probably if you are running the
> IE browser on the client), you can cause Excel to open from a page.
> You are on the right track with setting the content type. Put this
in
> a template and try it.
>
> $data.setContentType( "application/vnd.ms-excel" )
> <table>
>   <tr>
>     <td>text1</td>
>     <td>1</td>
>   </tr>
>   <tr>
>     <td>text2</td>
>     <td>2</td>
>   </tr>
> </table>
>
> It is even possible to put special strings in the TD tags to use
Excel
> formatting and Excel formulas in the resulting spreadsheet. Let me
> know if you want more information.
>
> Chris
>
> ----- Original Message -----
> From: "Fedor Karpelevitch" <fe...@Barra.COM>
> To: <tu...@jakarta.apache.org>
> Sent: Wednesday, October 10, 2001 2:00 PM
> Subject: RE: MS Excel and setContentType
>
>
> > Cross your fingers.
> >
> > seriously. if you set cont type to something which the file is not
> (like in
> > your case html is not an xml spreadsheet whatever you are trying
to
> claim).
> > If you want to have a certain type of file to be open with certain
> app you
> > have to configure the client machine to associate this type with
> that app.
> > Or use an existing association (s.a. the csv hack proposed)
> >
> > fedor.
> >
> > -------------------------------
> > Amicus Plato amicus Aristoteles magis amica veritas
> >
> > > -----Original Message-----
> > > From: Wei Ru [mailto:Wei.Ru@botcc.com]
> > > Sent: Wednesday, October 10, 2001 1:05 PM
> > > To: turbine-user@jakarta.apache.org
> > > Subject: MS Excel and setContentType
> > >
> > >
> > > Hi,
> > >
> > > I am trying to generate a report using html and open it on the
> browser
> > > by MS Excel. I am trying to use
> > > data.setContentType("application/vnd.ms-excel"); then feed the
> content
> > > some dynamicly generated html text
> > > Can any one suggest me a best way to do that?
> > >
> > > Thanks
> > >
> > > Wei Ru
> > >
> >
>
> --------------------------------------------------------------------
> -
> > > To unsubscribe, e-mail:
> turbine-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail:
> turbine-user-help@jakarta.apache.org
> > >
> >
>
> --------------------------------------------------------------------
> -
> > To unsubscribe, e-mail:
turbine-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> turbine-user-help@jakarta.apache.org
> >
>
>
> --------------------------------------------------------------------
-
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
turbine-user-help@jakarta.apache.org
>

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




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

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


Re: Re: MS Excel and setContentType]

Posted by Chris Crossen <cc...@home.com>.
I'm about to go to bed. It's after 2:00 am here on the west coast of
the US. I'll put something together later today.

Chris

----- Original Message -----
From: "Christian GARDERES" <ch...@dpma.finances.gouv.fr>
To: <tu...@jakarta.apache.org>
Sent: Monday, October 15, 2001 1:51 AM
Subject: [Fwd: Re: MS Excel and setContentType]



You said in this previous message that we can even embed some
formating
and formulas in the velocitry template. Could you post some examples?

Thanks a lot.

-------- Original Message --------
De: "Chris Crossen" <cc...@home.com>
Objet: Re: MS Excel and setContentType
A: <tu...@jakarta.apache.org>

Excel recognizes html. An html table passed to Excel will be rendered
as a spreadsheet.

Have you tried the sample from my previous message? I put it into my
template directory, invoked it from IE, and Excel opened with the
spreadsheet you would expect to see.

----- Original Message -----
From: "Stephane Bailliez" <sb...@imediation.com>
To: <tu...@jakarta.apache.org>
Sent: Monday, October 15, 2001 1:11 AM
Subject: RE: MS Excel and setContentType



May I ask how you manage to disable the page assembler to stuff a
different
content type in the response ?

I don't see how you can send back something else correct since the
page
assembler will add html tags around your data...unless I missed
something I
don't see how we can do this without creating our own VelocityPage
that
implements a different strategy for assembling a page.

--
 Stéphane Bailliez
 Software Engineer, Paris - France
 iMediation - http://www.imediation.com
 Disclaimer: All the opinions expressed above are mine and not those
from my
company.



> -----Original Message-----
> From: Chris Crossen [mailto:ccrossen@home.com]
> Sent: Thursday, October 11, 2001 12:02 AM
> To: turbine-user@jakarta.apache.org
> Subject: Re: MS Excel and setContentType
>
>
> If you have Excel on the client (and probably if you are running the
> IE browser on the client), you can cause Excel to open from a page.
> You are on the right track with setting the content type. Put this
in
> a template and try it.
>
> $data.setContentType( "application/vnd.ms-excel" )
> <table>
>   <tr>
>     <td>text1</td>
>     <td>1</td>
>   </tr>
>   <tr>
>     <td>text2</td>
>     <td>2</td>
>   </tr>
> </table>
>
> It is even possible to put special strings in the TD tags to use
Excel
> formatting and Excel formulas in the resulting spreadsheet. Let me
> know if you want more information.
>
> Chris
>
> ----- Original Message -----
> From: "Fedor Karpelevitch" <fe...@Barra.COM>
> To: <tu...@jakarta.apache.org>
> Sent: Wednesday, October 10, 2001 2:00 PM
> Subject: RE: MS Excel and setContentType
>
>
> > Cross your fingers.
> >
> > seriously. if you set cont type to something which the file is not
> (like in
> > your case html is not an xml spreadsheet whatever you are trying
to
> claim).
> > If you want to have a certain type of file to be open with certain
> app you
> > have to configure the client machine to associate this type with
> that app.
> > Or use an existing association (s.a. the csv hack proposed)
> >
> > fedor.
> >
> > -------------------------------
> > Amicus Plato amicus Aristoteles magis amica veritas
> >
> > > -----Original Message-----
> > > From: Wei Ru [mailto:Wei.Ru@botcc.com]
> > > Sent: Wednesday, October 10, 2001 1:05 PM
> > > To: turbine-user@jakarta.apache.org
> > > Subject: MS Excel and setContentType
> > >
> > >
> > > Hi,
> > >
> > > I am trying to generate a report using html and open it on the
> browser
> > > by MS Excel. I am trying to use
> > > data.setContentType("application/vnd.ms-excel"); then feed the
> content
> > > some dynamicly generated html text
> > > Can any one suggest me a best way to do that?
> > >
> > > Thanks
> > >
> > > Wei Ru
> > >
> >
>
> --------------------------------------------------------------------
> -
> > > To unsubscribe, e-mail:
> turbine-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail:
> turbine-user-help@jakarta.apache.org
> > >
> >
>
> --------------------------------------------------------------------
> -
> > To unsubscribe, e-mail:
turbine-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> turbine-user-help@jakarta.apache.org
> >
>
>
> --------------------------------------------------------------------
-
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
turbine-user-help@jakarta.apache.org
>

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




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

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



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


Re: Re: MS Excel and setContentType]

Posted by Chris Crossen <cc...@home.com>.
The example below uses Excel formatting and a formula. If you have any
header stuff in your default template, you may have to adjust the row
numbers in the formula to make it work.

One thing I ran into putting this example together is the number sign
(#). A typical Excel numberformat might look like:
style="vnd.ms-excel.numberformat:$#,##0.00"
but velocity thinks the number signs are for it. I presume there is a
way to escape them.

Notice that in addition to the formatting style and formula, normal
html formatting like <font> and <b> are recognized by Excel.

Have fun,
Chris



$data.setContentType( "application/vnd.ms-excel" )
<table>
  <tr>
    <td align="right"><font color=red><b>qty</b></font></td>
    <td align="left"><font color=red><b>item</b></td>
    <td align="right"><font color=red><b>unit price</b></td>
    <td align="right"><font color=red><b>extension</b></td>
  </tr>
  <tr>
    <td>2</td>
    <td align="left">widget</td>
    <td align="right" style="vnd.ms-excel.numberformat:0.00">5</td>
    <td aligh="right" style="vnd.ms-excel.numberformat:0.00">10</td>
  </tr>
  <tr>
    <td>2</td>
    <td align="left">widget case</b></td>
    <td align="right" style="vnd.ms-excel.numberformat:0.00">3</td>
    <td align="right" style="vnd.ms-excel.numberformat:0.00">6</td>
  </tr>
  <tr>
    <td colspan=3><font color=blue><b>Total</b></td>
    <td align="right" style="vnd.ms-excel.numberformat:$0.00"
formula="=sum(d2:d3)"><b>whatever</b></td>
  </tr>
</table>

----- Original Message -----
From: "Christian GARDERES" <ch...@dpma.finances.gouv.fr>
To: <tu...@jakarta.apache.org>
Sent: Monday, October 15, 2001 1:51 AM
Subject: [Fwd: Re: MS Excel and setContentType]



You said in this previous message that we can even embed some
formating
and formulas in the velocitry template. Could you post some examples?

Thanks a lot.

-------- Original Message --------
De: "Chris Crossen" <cc...@home.com>
Objet: Re: MS Excel and setContentType
A: <tu...@jakarta.apache.org>

Excel recognizes html. An html table passed to Excel will be rendered
as a spreadsheet.

Have you tried the sample from my previous message? I put it into my
template directory, invoked it from IE, and Excel opened with the
spreadsheet you would expect to see.

----- Original Message -----
From: "Stephane Bailliez" <sb...@imediation.com>
To: <tu...@jakarta.apache.org>
Sent: Monday, October 15, 2001 1:11 AM
Subject: RE: MS Excel and setContentType



May I ask how you manage to disable the page assembler to stuff a
different
content type in the response ?

I don't see how you can send back something else correct since the
page
assembler will add html tags around your data...unless I missed
something I
don't see how we can do this without creating our own VelocityPage
that
implements a different strategy for assembling a page.

--
 Stéphane Bailliez
 Software Engineer, Paris - France
 iMediation - http://www.imediation.com
 Disclaimer: All the opinions expressed above are mine and not those
from my
company.



> -----Original Message-----
> From: Chris Crossen [mailto:ccrossen@home.com]
> Sent: Thursday, October 11, 2001 12:02 AM
> To: turbine-user@jakarta.apache.org
> Subject: Re: MS Excel and setContentType
>
>
> If you have Excel on the client (and probably if you are running the
> IE browser on the client), you can cause Excel to open from a page.
> You are on the right track with setting the content type. Put this
in
> a template and try it.
>
> $data.setContentType( "application/vnd.ms-excel" )
> <table>
>   <tr>
>     <td>text1</td>
>     <td>1</td>
>   </tr>
>   <tr>
>     <td>text2</td>
>     <td>2</td>
>   </tr>
> </table>
>
> It is even possible to put special strings in the TD tags to use
Excel
> formatting and Excel formulas in the resulting spreadsheet. Let me
> know if you want more information.
>
> Chris
>
> ----- Original Message -----
> From: "Fedor Karpelevitch" <fe...@Barra.COM>
> To: <tu...@jakarta.apache.org>
> Sent: Wednesday, October 10, 2001 2:00 PM
> Subject: RE: MS Excel and setContentType
>
>
> > Cross your fingers.
> >
> > seriously. if you set cont type to something which the file is not
> (like in
> > your case html is not an xml spreadsheet whatever you are trying
to
> claim).
> > If you want to have a certain type of file to be open with certain
> app you
> > have to configure the client machine to associate this type with
> that app.
> > Or use an existing association (s.a. the csv hack proposed)
> >
> > fedor.
> >
> > -------------------------------
> > Amicus Plato amicus Aristoteles magis amica veritas
> >
> > > -----Original Message-----
> > > From: Wei Ru [mailto:Wei.Ru@botcc.com]
> > > Sent: Wednesday, October 10, 2001 1:05 PM
> > > To: turbine-user@jakarta.apache.org
> > > Subject: MS Excel and setContentType
> > >
> > >
> > > Hi,
> > >
> > > I am trying to generate a report using html and open it on the
> browser
> > > by MS Excel. I am trying to use
> > > data.setContentType("application/vnd.ms-excel"); then feed the
> content
> > > some dynamicly generated html text
> > > Can any one suggest me a best way to do that?
> > >
> > > Thanks
> > >
> > > Wei Ru
> > >
> >
>
> --------------------------------------------------------------------
> -
> > > To unsubscribe, e-mail:
> turbine-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail:
> turbine-user-help@jakarta.apache.org
> > >
> >
>
> --------------------------------------------------------------------
> -
> > To unsubscribe, e-mail:
turbine-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> turbine-user-help@jakarta.apache.org
> >
>
>
> --------------------------------------------------------------------
-
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
turbine-user-help@jakarta.apache.org
>

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




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

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



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