You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Altuğ Bilgin Altıntaş <al...@gmail.com> on 2010/09/16 20:25:06 UTC

Re: Export Excel file containing string and rendered component

Hi;

After using  WebResponse to export excel then clicking a Link gives *Page
expired* error.

Any suggestion ?


2009/6/4 Igor Vaynberg <ig...@gmail.com>

> you have the webresponse, can you not simply write into it?
>
> -igor
>
> On Thu, Jun 4, 2009 at 9:49 AM, Frank Silbermann
> <fr...@fedex.com> wrote:
> >
> > I, too, am trying to have my application download MS Excel files.  Until
> now,
> > mine have contained the content of a DataTable, using the code I received
> > from the mailing list three years ago:
> >
> > Button button = new Button("excelExport") {
> >    public void onSubmit() {
> >        getRequestCycle().setRequestTarget(
> >                        new ComponentRequestTarget(dataTable)
> >        );
> >        WebResponse wr = (WebResponse)getResponse();
> >        wr.setContentType( "excel/ms-excel; name="+getMSExcelFilename() );
> >        wr.setHeader( "content-disposition",
> > "attachment;filename="+getMSExcelFilename() );
> >    }
> > };
> >
> > The file downloaded contains an HTML fragment that both MS Excel and MS
> Word
> > can interpret, if one opens the resulting file in those applications.
> >
> > Now my users told me they would like the download to contain not just the
> > data, but the date of its creation.  Is there an easy way to pre-pend an
> > arbitrary string to that HTML fragment?  I don't really understand the
> > details of Wicket's page rendering process, and looking at the classes
> I've
> > been using there don't seem to be any obvious hooks.
> >
> >
> >
> >
> >    stream = class AbstractResourceStreamWriter()
> >                    {
> >                          public void write(OutputStream output)
> >                         {
> >                               // do your writing
> >                         }
> >                    }
> >
> >     getRequestCycle().setRequestTarget(
> >                     new ResourceStreamRequestTarget( stream
> ).setFileName(
> > "file.xls" )
> >    );
> >
> > johan
> >
> >
> > On Tue, Apr 1, 2008 at 9:31 AM, <dv...@newfoundmarket.com> wrote:
> >
> >> Hello:
> >> I am trying to export dynamically generated excel file.
> >> The generator would send the file.xls to an OutputStream.
> > ...
> >
> > --
> > View this message in context:
> http://www.nabble.com/export-excel-file-via-an-OutputStream-tp16416239p23873774.html
> > Sent from the Wicket - User mailing list archive at Nabble.com.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Export Excel file containing string and rendered component

Posted by rainIsWet <or...@hotmail.de>.
If You try to use Frank Silbermanns suggestion this should be the normal
behavior because it breaks the RequestCycle...

Use Johan Compagners solution with something like a ByteArrayOutputstream as
the stream-source of "public void write(Response output)". Worked fine for
me.

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/export-excel-file-via-an-OutputStream-tp1883922p4260504.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org