Search code examples
exceljsfjsf-2primefaces

Export to xsl using PrimeFaces 5.0 is not working


I am using primefaces 5.0 and in my project i have to export my datatable to a excel format, i am attaching my code bellow. I am using poi.jar for download the excel. but when I click the download button nothing happen. It has not shown any error log . please check my code

<h:form  id="mainform">

            <p:dataTable   var="test" value="#{assignRollNoViewBean.rollNoAssignCandiadteList}" 
            paginator="true" rows="20" id="tbl">


             <p:column>
              <f:facet name="header">
               <h:outputText value="ID"></h:outputText>

              </f:facet>

                    <h:outputText value="#{test.formStatus.id}" />
             </p:column>

            <p:column>
              <f:facet name="header">
               <h:outputText value="Roll No"></h:outputText>

              </f:facet>

              <h:outputText value="#{test.rollNo}" />
            </p:column>


             <p:column>
              <f:facet name="header">
               <h:outputText value="Zone"></h:outputText>

              </f:facet>

              <h:outputText value="#{test.venue.center.name}" />
            </p:column>

              <p:column>
              <f:facet name="header">
               <h:outputText value="Zone"></h:outputText>

              </f:facet>

                <h:outputText value="#{test.venue.name}" />
            </p:column>

             <p:column>
              <f:facet name="header">
               <h:outputText value="Form Status"></h:outputText>

              </f:facet>

                <h:outputText value="#{test.formStatus.status}" />
            </p:column>

         </p:dataTable>


          <p:panel header="Export All Data">
             <h:commandLink id="excel" ajax="false">
                <p:graphicImage value="/images/excel.jpg" />
                  <p:dataExporter type="xsl"  target="tbl"   fileName="myexcel"  postProcessor="#{assignRollNoViewBean.postProcessXLS}"/>
            </h:commandLink>
              <p:spacer></p:spacer>
              <p:spacer></p:spacer>
            <h:commandLink id="pdf">
                <p:graphicImage value="/images/pdf.jpg" />
                   <p:dataExporter type="pdf"  target="tbl"   fileName="mypdf" />
            </h:commandLink>
         </p:panel>

      </h:form>  

Solution

  • <h:commandButton id="pdf"></h:commandButton > 
    

    work for me