Instead of this,

Try the exportActionListener, so you dont need to write any java code:)

http://myfaces.apache.org/sandbox/tlddoc/index.html

showDisplayedPageOnly attribute tunes the amount of data to be exported.

It also support pdf and excel exporting.

Cheers,

Cagatay

On Tue, Nov 4, 2008 at 2:05 PM, mrfarhankhan <[EMAIL PROTECTED]> wrote:

>
> I am using the following code. Am i missing something ?
>
> <h:commandLink action="#{manageCountriesBB.exportHtmlTableToExcel}">
>  <h:outputText value="Export table to Excel" />
> </h:commandLink>
>
> public void exportHtmlTableToExcel() {
>
>                String filename = "test.xls";
>
>                // Setup the output
>                String contentType = "application/vnd.ms-excel";
>                FacesContext fc = FacesContext.getCurrentInstance();
>                HttpServletResponse response = (HttpServletResponse) fc
>                                .getExternalContext().getResponse();
>                response.setHeader("Content-disposition", "attachment;
> filename="
>                                + filename);
>                response.setContentType(contentType);
>
>                // Write the table back out
>                try {
>                        PrintWriter out = response.getWriter();
>                        out.print(htmlBuffer);
>                        out.close();
>                } catch (IOException ex) {
>                        spage.processException(ex);
>                }
>                fc.responseComplete();
>        }
>
>
>
> ===================================================================
>
>
> Cagatay Civici wrote:
> >
> > Are you using the export actionlistener?
> >
> > On Tue, Nov 4, 2008 at 9:33 AM, mrfarhankhan <[EMAIL PROTECTED]>
> > wrote:
> >
> >>
> >> Hi !
> >>
> >> I am following the following link to export my datatable to excel
> >> http://wiki.apache.org/myfaces/Exporting_DataTable_To_MS-Excel
> >>
> >> The problem is that I am using pagination with the table but the excel
> >> file
> >> only contains the rows that are currently being displayed in the
> >> datatable.
> >> I want all the rows to be exported.
> >>
> >> Looking for a solution
> >> Thanks in advance
> >> Farhan !
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/Export-datatable-to-excel-problem-with-pagination-tp20318897p20318897.html
> >> Sent from the MyFaces - Users mailing list archive at Nabble.com.
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Export-datatable-to-excel-problem-with-pagination-tp20318897p20322901.html
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>

Reply via email to