简体   繁体   中英

PrimeFaces DataExporter to XLS for multiple tables

Am trying to Export XLS format from multiple tables. I have browsed and used some code, But its not working. Using primefaces extensions code is there but complete code is not there it seems in this link. I need solution for this.

Code i have used : Tbl1, Tbl2, Tbl3 are table widgetVar's.

    <p:commandLink id="xls" ajax="false" >  
                <p:graphicImage value="/images/excel.png" />   
                <pe:exporter type="xlsx" target="Tbl1, Tbl2, Tbl3" fileName="tables"/>
    </p:commandLink>

You should not address them by widgetVar. From the PrimeFaces Extensions Exporter (emphasis mine):

Here we can export multiple tables by providing multiple datatable server ids with the delimiter as "comma"(or ",").

I work with primefaces 6.2 and this works for me (I'm not sure about other versions) without use primefaces extension

<p:dataTable id="tbl1" value="#{ManagedBean.listValues}" var="vt">
    <p:column headerText="LabelPrint">
        <h:outputText value="#{vt.id}"/> 
    </p:column>
</p:dataTable>

<p:dataTable id="tbl2" value="#{ManagedBean.otherList}" var="vt2">
     <p:column headerText="Name Field Print">
         <h:outputText value="#{vt2.name}"/> 
     </p:column>
</p:dataTable>

<h:commandLink>
 <p:graphicImage url="#{resource['/images/icons/table-xls.png']}"/>
 <p:dataExporter type="xls" target="tbl1, tbl2" fileName="My Data" pageOnly="true" />
</h:commandLink>

You separate your "id" of tables for export with (,) in attribute target of p:dataexporter object.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM