How to correctly export footer with Xtensions primefaces

Asked

Viewed 618 times

1

Use JSF 2.2 and Primefaces 5.0

Using the Extensions primefaces to export, in a single excel file, three tables of a system, I’m having problems with the exported information: The table footer with dynamic columns, rendered in a page according to the procedure in the bean and use of Boolean variables (used in rendere) are not being exported as desired (same visual of the screen).

See image:


Tela e Arquivo Exportado


Follow below the page code:

<?xml version='1.0' encoding='UTF-8' ?>

Control Panel - Event Notification System

<p:layout fullPage="true">

    <ui:include src="/paginas/admin/includes/topo.xhtml" />

    <p:layoutUnit position="center">
        <h:form id="cadastro" prependId="false" styleClass="formCadastro">
            <h:panelGrid columns="2">
                <p:outputLabel colspan="1" value="ANO:" for="ano" />
                <h:panelGroup>
                    <p:spacer width="5" height="10" />
                    <p:selectOneMenu id="ano" value="#{relatoriosMB.ano}"
                        required="true" requiredMessage="É obrigatório informar o Ano.">
                        <f:selectItem itemValue="" itemLabel="Selecione..." />
                        <f:selectItems value="#{relatoriosMB.listaAnos}" var="intAno"
                            itemLabel="#{intAno.intValue()}"
                            itemValue="#{intAno.intValue()}" />
                    </p:selectOneMenu>
                    <p:message for="ano" />
                </h:panelGroup>
                <p:outputLabel colspan="1" value="MES INICIAL:" for="mesIni" />
                <h:panelGroup>
                    <p:spacer width="5" height="10" />
                    <p:selectOneMenu id="mesIni" value="#{relatoriosMB.mesIni}" required="true" requiredMessage="É obrigatório informar o Mes Inicial">
                        <f:selectItem itemValue="" itemLabel="Selecione..." />
                        <f:selectItem itemValue="1" itemLabel="JANEIRO" />
                        <f:selectItem itemValue="2" itemLabel="FEVEREIRO" />
                        <f:selectItem itemValue="3" itemLabel="MARÇO" />
                        <f:selectItem itemValue="4" itemLabel="ABRIL" />
                        <f:selectItem itemValue="5" itemLabel="MAIO" />
                        <f:selectItem itemValue="6" itemLabel="JUNHO" />
                        <f:selectItem itemValue="7" itemLabel="JULHO" />
                        <f:selectItem itemValue="8" itemLabel="AGOSTO" />
                        <f:selectItem itemValue="9" itemLabel="SETEMBRO" />
                        <f:selectItem itemValue="10" itemLabel="OUTUBRO" />
                        <f:selectItem itemValue="11" itemLabel="NOVEMBRO" />
                        <f:selectItem itemValue="12" itemLabel="DEZEMBRO" />
                    </p:selectOneMenu>
                    <p:message for="mesIni" />
                </h:panelGroup>
                <p:outputLabel colspan="1" value="MES FINAL:" for="mesFim" />
                <h:panelGroup>
                    <p:spacer width="5" height="10" />
                    <p:selectOneMenu id="mesFim" value="#{relatoriosMB.mesFim}"
                        required="true"
                        requiredMessage="É obrigatório informar o Mes Final">
                        <f:selectItem itemValue="" itemLabel="Selecione..." />
                        <f:selectItem itemValue="1" itemLabel="JANEIRO" />
                        <f:selectItem itemValue="2" itemLabel="FEVEREIRO" />
                        <f:selectItem itemValue="3" itemLabel="MARÇO" />
                        <f:selectItem itemValue="4" itemLabel="ABRIL" />
                        <f:selectItem itemValue="5" itemLabel="MAIO" />
                        <f:selectItem itemValue="6" itemLabel="JUNHO" />
                        <f:selectItem itemValue="7" itemLabel="JULHO" />
                        <f:selectItem itemValue="8" itemLabel="AGOSTO" />
                        <f:selectItem itemValue="9" itemLabel="SETEMBRO" />
                        <f:selectItem itemValue="10" itemLabel="OUTUBRO" />
                        <f:selectItem itemValue="11" itemLabel="NOVEMBRO" />
                        <f:selectItem itemValue="12" itemLabel="DEZEMBRO" />
                    </p:selectOneMenu>
                    <p:message for="mesFim" />
                </h:panelGroup>
            </h:panelGrid>
            <br></br>
            <p:commandButton value="GERAR RELATÓRIO" action="#{relatoriosMB.gerarRelatorioTipoClassificacao}" update=":edicao:dataTableAnual, :edicao, :cadastro"/>
            <br></br>
            <br></br>
            <p:panel header="Exportar PDF e Excel" rendered="#{not empty relatoriosMB.listaAnual}" style="width: 300px">
                <p:commandLink id="pdf" ajax="false">
                    <p:graphicImage value="/resources/icones/PDF-icon.png" width="50"/>
                    <f:setPropertyActionListener value="false"
                        target="#{exporterController.customExporter}" />
                    <pe:exporter type="pdf" target=":edicao:dataTableAnual,:edicao:dataTablePeriodo,:edicao:dataTableIncidentePeriodo"
                        fileName="TipoClassificação" datasetPadding="3" />
                </p:commandLink>
                <p:spacer width="20" />
                <p:commandLink id="xls" ajax="false">
                    <p:graphicImage value="/resources/icones/excel-icon.png" width="50" />
                    <f:setPropertyActionListener value="false"
                        target="#{exporterController.customExporter}" />
                    <pe:exporter type="xlsx" target=":edicao:dataTableAnual,:edicao:dataTablePeriodo,:edicao:dataTableIncidentePeriodo"
                        fileName="TipoClassificação" datasetPadding="3" postProcessor="#{managerexcel.postProcessXLS}"/>
                </p:commandLink>
            </p:panel>
        </h:form>
        <br></br>
        <br></br>
        <h:form id="edicao" prependId="false">
            <p:growl id="msgs" showDetail="true" globalOnly="true" escape="false" />
            <p:dataTable id="dataTableAnual" var="linhaAnual"
                value="#{relatoriosMB.listaAnual}" editable="true"
                draggableColumns="true"
                rendered="#{not empty relatoriosMB.listaAnual}"
                widgetVar="tableClassAnual"
                filteredValue="#{relatoriosMB.filteredAnual}"
                emptyMessage="Não existem registros Anuais."
                resizableColumns="true" liveResize="true">
                <f:facet name="header" style="text-allign:center">
                    Tabela Tipo de Classificação - ANUAL
                </f:facet>
                <p:column headerText="TIPO CLASSIFICAÇÃO"
                    sortBy="#{linhaAnual.objeto}"
                    style="width:200px;text-align: center">
                    <f:facet name="header">
                        <h:outputText value="TIPO CLASSIFICAÇÃO" />
                    </f:facet>
                    <p:outputLabel value="#{linhaAnual.objeto}" />
                </p:column>
                <p:column headerText="JAN" style="width:50px;text-align: center">
                    <f:facet name="header">
                        <h:outputText value="JAN" />
                    </f:facet>
                    <p:outputLabel value="#{linhaAnual.janeiro}" />
                </p:column>
                <p:column headerText="FEV" style="width:50px;text-align: center">
                    <f:facet name="header">
                        <h:outputText value="FEV" />
                    </f:facet>
                    <p:outputLabel value="#{linhaAnual.fevereiro}" />
                </p:column>
                <p:column headerText="MAR" style="width:50px;text-align: center">
                    <f:facet name="header">
                        <h:outputText value="MAR" />
                    </f:facet>
                    <p:outputLabel value="#{linhaAnual.marco}" />
                </p:column>
                <p:column headerText="ABR" style="width:50px;text-align: center">
                    <f:facet name="header">
                        <h:outputText value="ABR" />
                    </f:facet>
                    <p:outputLabel value="#{linhaAnual.abril}" />
                </p:column>
                <p:column headerText="MAI" style="width:50px;text-align: center">
                    <f:facet name="header">
                        <h:outputText value="MAI" />
                    </f:facet>
                    <p:outputLabel value="#{linhaAnual.maio}" />
                </p:column>
                <p:column headerText="JUN" style="width:50px;text-align: center">
                    <f:facet name="header">
                        <h:outputText value="JUN" />
                    </f:facet>
                    <p:outputLabel value="#{linhaAnual.junho}" />
                </p:column>
                <p:column headerText="JUL" style="width:50px;text-align: center">
                    <f:facet name="header">
                        <h:outputText value="JUL" />
                    </f:facet>
                    <p:outputLabel value="#{linhaAnual.julho}" />
                </p:column>
                <p:column headerText="AGO" style="width:50px;text-align: center">
                    <f:facet name="header">
                        <h:outputText value="AGO" />
                    </f:facet>
                    <p:outputLabel value="#{linhaAnual.agosto}" />
                </p:column>
                <p:column headerText="SET" style="width:50px;text-align: center">
                    <f:facet name="header">
                        <h:outputText value="SET" />
                    </f:facet>
                    <p:outputLabel value="#{linhaAnual.setembro}" />
                </p:column>
                <p:column headerText="OUT" style="width:50px;text-align: center">
                    <f:facet name="header">
                        <h:outputText value="OUT" />
                    </f:facet>
                    <p:outputLabel value="#{linhaAnual.outubro}" />
                </p:column>
                <p:column headerText="NOV" style="width:50px;text-align: center">
                    <f:facet name="header">
                        <h:outputText value="NOV" />
                    </f:facet>
                    <p:outputLabel value="#{linhaAnual.novembro}" />
                </p:column>
                <p:column headerText="DEZ" style="width:50px;text-align: center">
                    <f:facet name="header">
                        <h:outputText value="DEZ" />
                    </f:facet>
                    <p:outputLabel value="#{linhaAnual.dezembro}" />
                </p:column>
                <p:column headerText="TOTAL" style="width:100px;text-align: center">
                    <f:facet name="header">
                        <h:outputText value="TOTAL" />
                    </f:facet>
                    <p:outputLabel value="#{linhaAnual.totalLinha}" />
                </p:column>
                <p:columnGroup type="footer">
                    <p:row>
                        <p:column colspan="1" style="text-align:right" footerText="Total Anual:" />
                        <p:column footerText="#{relatoriosMB.qtdTotalMesesAnual[1]}" />
                        <p:column footerText="#{relatoriosMB.qtdTotalMesesAnual[2]}" />
                        <p:column footerText="#{relatoriosMB.qtdTotalMesesAnual[3]}" />
                        <p:column footerText="#{relatoriosMB.qtdTotalMesesAnual[4]}" />
                        <p:column footerText="#{relatoriosMB.qtdTotalMesesAnual[5]}" />
                        <p:column footerText="#{relatoriosMB.qtdTotalMesesAnual[6]}" />
                        <p:column footerText="#{relatoriosMB.qtdTotalMesesAnual[7]}" />
                        <p:column footerText="#{relatoriosMB.qtdTotalMesesAnual[8]}" />
                        <p:column footerText="#{relatoriosMB.qtdTotalMesesAnual[9]}" />
                        <p:column footerText="#{relatoriosMB.qtdTotalMesesAnual[10]}" />
                        <p:column footerText="#{relatoriosMB.qtdTotalMesesAnual[11]}" />
                        <p:column footerText="#{relatoriosMB.qtdTotalMesesAnual[12]}" />
                        <p:column footerText="#{relatoriosMB.totalGeralAnual}" />
                    </p:row>
                </p:columnGroup>
            </p:dataTable>
            <br />
            <br />
            <p:dataTable id="dataTablePeriodo" var="linhaPeriodo"
                value="#{relatoriosMB.listaObjeto1}" editable="true"
                draggableColumns="true"
                rendered="#{not empty relatoriosMB.listaObjeto1}"
                widgetVar="tableClassPeriodo"
                filteredValue="#{relatoriosMB.filteredObjeto1}"
                emptyMessage="Não existem registros para o período informado."
                resizableColumns="true" liveResize="true">
                <f:facet name="header" style="text-allign:center">
                    Tabela Incidente - PERÍODO
                </f:facet>
                <p:column headerText="INCIDENTE"
                    sortBy="#{linhaPeriodo.objeto}"
                    style="width:200px;text-align: center">
                    <f:facet name="header">
                        <h:outputText value="INCIDENTE" />
                    </f:facet>
                    <p:outputLabel value="#{linhaPeriodo.objeto}" />
                </p:column>
                <p:column headerText="JAN" style="width:50px;text-align: center" rendered="#{relatoriosMB.janeiro}" exportable="#{relatoriosMB.janeiro}">
                    <f:facet name="header">
                        <h:outputText value="JAN"/>
                    </f:facet>
                    <p:outputLabel value="#{linhaPeriodo.janeiro}" />
                </p:column>
                <p:column headerText="FEV" style="width:50px;text-align: center" rendered="#{relatoriosMB.fevereiro}" exportable="#{relatoriosMB.fevereiro}">
                    <f:facet name="header">
                        <h:outputText value="FEV"/>
                    </f:facet>
                    <p:outputLabel value="#{linhaPeriodo.fevereiro}" />
                </p:column>
                <p:column headerText="MAR" style="width:50px;text-align: center" rendered="#{relatoriosMB.marco}" exportable="#{relatoriosMB.marco}">
                    <f:facet name="header">
                        <h:outputText value="MAR"/>
                    </f:facet>
                    <p:outputLabel value="#{linhaPeriodo.marco}" />
                </p:column>
                <p:column headerText="ABR" style="width:50px;text-align: center" rendered="#{relatoriosMB.abril}" exportable="#{relatoriosMB.abril}">
                    <f:facet name="header">
                        <h:outputText value="ABR"/>
                    </f:facet>
                    <p:outputLabel value="#{linhaPeriodo.abril}" />
                </p:column>
                <p:column headerText="MAI" style="width:50px;text-align: center" rendered="#{relatoriosMB.maio}" exportable="#{relatoriosMB.maio}">
                    <f:facet name="header">
                        <h:outputText value="MAI"/>
                    </f:facet>
                    <p:outputLabel value="#{linhaPeriodo.maio}" />
                </p:column>
                <p:column headerText="JUN" style="width:50px;text-align: center" rendered="#{relatoriosMB.junho}" exportable="#{relatoriosMB.junho}">
                    <f:facet name="header">
                        <h:outputText value="JUN"/>
                    </f:facet>
                    <p:outputLabel value="#{linhaPeriodo.junho}" />
                </p:column>
                <p:column headerText="JUL" style="width:50px;text-align: center" rendered="#{relatoriosMB.julho}" exportable="#{relatoriosMB.julho}">
                    <f:facet name="header">
                        <h:outputText value="JUL"/>
                    </f:facet>
                    <p:outputLabel value="#{linhaPeriodo.julho}" />
                </p:column>
                <p:column headerText="AGO" style="width:50px;text-align: center" rendered="#{relatoriosMB.agosto}" exportable="#{relatoriosMB.agosto}">
                    <f:facet name="header">
                        <h:outputText value="AGO"/>
                    </f:facet>
                    <p:outputLabel value="#{linhaPeriodo.agosto}" />
                </p:column>
                <p:column headerText="SET" style="width:50px;text-align: center" rendered="#{relatoriosMB.setembro}" exportable="#{relatoriosMB.setembro}">
                    <f:facet name="header">
                        <h:outputText value="SET"/>
                    </f:facet>
                    <p:outputLabel value="#{linhaPeriodo.setembro}" />
                </p:column>
                <p:column headerText="OUT" style="width:50px;text-align: center" rendered="#{relatoriosMB.outubro}" exportable="#{relatoriosMB.outubro}">
                    <f:facet name="header">
                        <h:outputText value="OUT"/>
                    </f:facet>
                    <p:outputLabel value="#{linhaPeriodo.outubro}" />
                </p:column>
                <p:column headerText="NOV" style="width:50px;text-align: center" rendered="#{relatoriosMB.novembro}" exportable="#{relatoriosMB.novembro}">
                    <f:facet name="header">
                        <h:outputText value="NOV"/>
                    </f:facet>
                    <p:outputLabel value="#{linhaPeriodo.novembro}" />
                </p:column>
                <p:column headerText="DEZ" style="width:50px;text-align: center" rendered="#{relatoriosMB.dezembro}" exportable="#{relatoriosMB.dezembro}">
                    <f:facet name="header">
                        <h:outputText value="DEZ"/>
                    </f:facet>
                    <p:outputLabel value="#{linhaPeriodo.dezembro}" />
                </p:column>
                <p:column headerText="TOTAL" style="width:100px;text-align: center">
                    <f:facet name="header">
                        <h:outputText value="TOTAL"/>
                    </f:facet>
                    <p:outputLabel value="#{linhaPeriodo.totalLinha}" />
                </p:column>
                <p:columnGroup type="footer">
                    <p:row>
                        <p:column colspan="1" style="text-align:right"
                            footerText="Total Período:" />
                        <p:column exportable="#{relatoriosMB.janeiro}"
                            footerText="#{relatoriosMB.qtdTotalMesesObjeto1Periodo[1]}"
                            rendered="#{relatoriosMB.janeiro}" />
                        <p:column exportable="#{relatoriosMB.fevereiro}"
                            footerText="#{relatoriosMB.qtdTotalMesesObjeto1Periodo[2]}"
                            rendered="#{relatoriosMB.fevereiro}" />
                        <p:column exportable="#{relatoriosMB.marco}"
                            footerText="#{relatoriosMB.qtdTotalMesesObjeto1Periodo[3]}"
                            rendered="#{relatoriosMB.marco}" />
                        <p:column exportable="#{relatoriosMB.abril}"
                            footerText="#{relatoriosMB.qtdTotalMesesObjeto1Periodo[4]}"
                            rendered="#{relatoriosMB.abril}" />
                        <p:column exportable="#{relatoriosMB.maio}"
                            footerText="#{relatoriosMB.qtdTotalMesesObjeto1Periodo[5]}"
                            rendered="#{relatoriosMB.maio}" />
                        <p:column exportable="#{relatoriosMB.junho}"
                            footerText="#{relatoriosMB.qtdTotalMesesObjeto1Periodo[6]}"
                            rendered="#{relatoriosMB.junho}" />
                        <p:column exportable="#{relatoriosMB.julho}"
                            footerText="#{relatoriosMB.qtdTotalMesesObjeto1Periodo[7]}"
                            rendered="#{relatoriosMB.julho}" />
                        <p:column exportable="#{relatoriosMB.agosto}"
                            footerText="#{relatoriosMB.qtdTotalMesesObjeto1Periodo[8]}"
                            rendered="#{relatoriosMB.agosto}" />
                        <p:column exportable="#{relatoriosMB.setembro}"
                            footerText="#{relatoriosMB.qtdTotalMesesObjeto1Periodo[9]}"
                            rendered="#{relatoriosMB.setembro}" />
                        <p:column exportable="#{relatoriosMB.outubro}"
                            footerText="#{relatoriosMB.qtdTotalMesesObjeto1Periodo[10]}"
                            rendered="#{relatoriosMB.outubro}" />
                        <p:column exportable="#{relatoriosMB.novembro}"
                            footerText="#{relatoriosMB.qtdTotalMesesObjeto1Periodo[11]}"
                            rendered="#{relatoriosMB.novembro}" />
                        <p:column exportable="#{relatoriosMB.dezembro}"
                            footerText="#{relatoriosMB.qtdTotalMesesObjeto1Periodo[12]}"
                            rendered="#{relatoriosMB.dezembro}"/>
                        <p:column footerText="#{relatoriosMB.totalGeralObjeto1Periodo}"/>
                    </p:row>
                </p:columnGroup>
            </p:dataTable>

            <p:dataTable id="dataTableIncidentePeriodo"
                var="linhaIncidentePeriodo" value="#{relatoriosMB.listaObjeto2}"
                editable="true" draggableColumns="true"
                rendered="#{not empty relatoriosMB.listaObjeto2}"
                widgetVar="tableClassIncidentePeriodo"
                filteredValue="#{relatoriosMB.filteredObjeto2}"
                emptyMessage="Não existem registros para o período informado."
                resizableColumns="true" liveResize="true">
                <f:facet name="header" style="text-allign:center">
                    Tabela Grau do Incidente - PERÍODO
                </f:facet>
                <p:column headerText="GRAU DO INCIDENTE"
                    sortBy="#{linhaIncidentePeriodo.objeto}"
                    style="width:200px;text-align: center">
                    <f:facet name="header">
                        <h:outputText value="GRAU DO INCIDENTE"/>
                    </f:facet>
                    <p:outputLabel value="#{linhaIncidentePeriodo.objeto}" />
                </p:column>
                <p:column headerText="JAN" style="width:50px;text-align: center" rendered="#{relatoriosMB.janeiro}" exportable="#{relatoriosMB.janeiro}">
                    <f:facet name="header">
                        <h:outputText value="JAN"/>
                    </f:facet>
                    <p:outputLabel value="#{linhaIncidentePeriodo.janeiro}" />
                </p:column>
                <p:column headerText="FEV" style="width:50px;text-align: center" rendered="#{relatoriosMB.fevereiro}" exportable="#{relatoriosMB.fevereiro}">
                    <f:facet name="header">
                        <h:outputText value="FEV"/>
                    </f:facet>
                    <p:outputLabel value="#{linhaIncidentePeriodo.fevereiro}" />
                </p:column>
                <p:column headerText="MAR" style="width:50px;text-align: center" rendered="#{relatoriosMB.marco}" exportable="#{relatoriosMB.marco}">
                    <f:facet name="header">
                        <h:outputText value="MAR"/>
                    </f:facet>
                    <p:outputLabel value="#{linhaIncidentePeriodo.marco}" />
                </p:column>
                <p:column headerText="ABR" style="width:50px;text-align: center" rendered="#{relatoriosMB.abril}" exportable="#{relatoriosMB.abril}">
                    <f:facet name="header">
                        <h:outputText value="ABR"/>
                    </f:facet>
                    <p:outputLabel value="#{linhaIncidentePeriodo.abril}" />
                </p:column>
                <p:column headerText="MAI" style="width:50px;text-align: center" rendered="#{relatoriosMB.maio}" exportable="#{relatoriosMB.maio}">
                    <f:facet name="header">
                        <h:outputText value="MAI"/>
                    </f:facet>
                    <p:outputLabel value="#{linhaIncidentePeriodo.maio}" />
                </p:column>
                <p:column headerText="JUN" style="width:50px;text-align: center" rendered="#{relatoriosMB.junho}" exportable="#{relatoriosMB.junho}">
                    <f:facet name="header">
                        <h:outputText value="JUN"/>
                    </f:facet>
                    <p:outputLabel value="#{linhaIncidentePeriodo.junho}" />
                </p:column>
                <p:column headerText="JUL" style="width:50px;text-align: center" rendered="#{relatoriosMB.julho}" exportable="#{relatoriosMB.julho}">
                    <f:facet name="header">
                        <h:outputText value="JUL"/>
                    </f:facet>
                    <p:outputLabel value="#{linhaIncidentePeriodo.julho}" />
                </p:column>
                <p:column headerText="AGO" style="width:50px;text-align: center" rendered="#{relatoriosMB.agosto}" exportable="#{relatoriosMB.agosto}">
                    <f:facet name="header">
                        <h:outputText value="AGO"/>
                    </f:facet>
                    <p:outputLabel value="#{linhaIncidentePeriodo.agosto}" />
                </p:column>
                <p:column headerText="SET" style="width:50px;text-align: center" rendered="#{relatoriosMB.setembro}" exportable="#{relatoriosMB.setembro}">
                    <f:facet name="header">
                        <h:outputText value="SET"/>
                    </f:facet>
                    <p:outputLabel value="#{linhaIncidentePeriodo.setembro}" />
                </p:column>
                <p:column headerText="OUT" style="width:50px;text-align: center" rendered="#{relatoriosMB.outubro}" exportable="#{relatoriosMB.outubro}">
                    <f:facet name="header">
                        <h:outputText value="OUT"/>
                    </f:facet>
                    <p:outputLabel value="#{linhaIncidentePeriodo.outubro}" />
                </p:column>
                <p:column headerText="NOV" style="width:50px;text-align: center" rendered="#{relatoriosMB.novembro}" exportable="#{relatoriosMB.novembro}">
                    <f:facet name="header">
                        <h:outputText value="NOV"/>
                    </f:facet>
                    <p:outputLabel value="#{linhaIncidentePeriodo.novembro}" />
                </p:column>
                <p:column headerText="DEZ" style="width:50px;text-align: center" rendered="#{relatoriosMB.dezembro}" exportable="#{relatoriosMB.dezembro}">
                    <f:facet name="header">
                        <h:outputText value="DEZ"/>
                    </f:facet>
                    <p:outputLabel value="#{linhaIncidentePeriodo.dezembro}" />
                </p:column>
                <p:column headerText="TOTAL" style="width:100px;text-align: center">
                    <f:facet name="header">
                        <h:outputText value="TOTAL"/>
                    </f:facet>
                    <p:outputLabel value="#{linhaIncidentePeriodo.totalLinha}" />
                </p:column>
                <p:columnGroup type="footer">
                    <p:row>
                        <p:column colspan="1" style="text-align:right"
                            footerText="Total Incidente Período:" />
                        <p:column exportable="#{relatoriosMB.janeiro}"
                            footerText="#{relatoriosMB.qtdTotalMesesObjeto2Periodo[1]}"
                            rendered="#{relatoriosMB.janeiro}" />
                        <p:column exportable="#{relatoriosMB.fevereiro}"
                            footerText="#{relatoriosMB.qtdTotalMesesObjeto2Periodo[2]}"
                            rendered="#{relatoriosMB.fevereiro}" />
                        <p:column exportable="#{relatoriosMB.marco}"
                            footerText="#{relatoriosMB.qtdTotalMesesObjeto2Periodo[3]}"
                            rendered="#{relatoriosMB.marco}" />
                        <p:column exportable="#{relatoriosMB.abril}"
                            footerText="#{relatoriosMB.qtdTotalMesesObjeto2Periodo[4]}"
                            rendered="#{relatoriosMB.abril}" />
                        <p:column exportable="#{relatoriosMB.maio}"
                            footerText="#{relatoriosMB.qtdTotalMesesObjeto2Periodo[5]}"
                            rendered="#{relatoriosMB.maio}" />
                        <p:column exportable="#{relatoriosMB.junho}"
                            footerText="#{relatoriosMB.qtdTotalMesesObjeto2Periodo[6]}"
                            rendered="#{relatoriosMB.junho}" />
                        <p:column exportable="#{relatoriosMB.julho}"
                            footerText="#{relatoriosMB.qtdTotalMesesObjeto2Periodo[7]}"
                            rendered="#{relatoriosMB.julho}" />
                        <p:column exportable="#{relatoriosMB.agosto}"
                            footerText="#{relatoriosMB.qtdTotalMesesObjeto2Periodo[8]}"
                            rendered="#{relatoriosMB.agosto}" />
                        <p:column exportable="#{relatoriosMB.setembro}"
                            footerText="#{relatoriosMB.qtdTotalMesesObjeto2Periodo[9]}"
                            rendered="#{relatoriosMB.setembro}" />
                        <p:column exportable="#{relatoriosMB.outubro}"
                            footerText="#{relatoriosMB.qtdTotalMesesObjeto2Periodo[10]}"
                            rendered="#{relatoriosMB.outubro}" />
                        <p:column exportable="#{relatoriosMB.novembro}"
                            footerText="#{relatoriosMB.qtdTotalMesesObjeto2Periodo[11]}"
                            rendered="#{relatoriosMB.novembro}" />
                        <p:column exportable="#{relatoriosMB.dezembro}"
                            footerText="#{relatoriosMB.qtdTotalMesesObjeto2Periodo[12]}"
                            rendered="#{relatoriosMB.dezembro}"/>
                        <p:column footerText="#{relatoriosMB.totalGeralObjeto2Periodo}" />
                    </p:row>
                </p:columnGroup>
            </p:dataTable>
        </h:form>
    </p:layoutUnit>

    <ui:include src="/paginas/admin/includes/rodape.xhtml" />

</p:layout>


As we can see already tried to use rendered and Exportable, both with Boolean attributes, even so it didn’t work.

1 answer

2


I realized the implementation of Custom Exporter, the same steps provided on the site Steps to Custom Exporter

After the implementation of custom export mode I debugged the standard export code, specifically the "Excelcustomexporter" class and verified that there was no consistency, as the footers components Exportable tag. Debugging the code identified the method that created the grouped footer columns and inserted the consistency of the Exportable tag, of the component in use. I changed the "tableColumnGroup" method, starting to create the cell and insert value to it when Exportable was true.

Below is the modified code:

protected void tableColumnGroup(Sheet sheet, DataTable table, String facetType) {
    ColumnGroup cg = table.getColumnGroup(facetType);
    List<UIComponent> headerComponentList = null;
    if (cg != null) {
        headerComponentList = cg.getChildren();
    }
    if (headerComponentList != null) {
        for (UIComponent component : headerComponentList) { 
            if (component instanceof org.primefaces.component.row.Row) {
                org.primefaces.component.row.Row row = (org.primefaces.component.row.Row) component;
                int sheetRowIndex = sheet.getLastRowNum() + 1;
                Row xlRow = sheet.createRow(sheetRowIndex);
                int i = 0;
                for (UIComponent rowComponent : row.getChildren()) {
                    UIColumn column = (UIColumn) rowComponent;
                    String value = null;
                    if (facetType.equalsIgnoreCase("header")) {
                        value = column.getHeaderText();
                    } else {
                        value = column.getFooterText();

                    }
                    int rowSpan = column.getRowspan();
                    int colSpan = column.getColspan();

                    Cell cell = xlRow.getCell(i);

                    if (rowSpan > 1 || colSpan > 1) {
                        if (rowSpan > 1) {
                            cell = xlRow.createCell((short) i);
                            Boolean rowSpanFlag = false;
                            for (int j = 0; j < sheet.getNumMergedRegions(); j++) {
                                CellRangeAddress merged = sheet.getMergedRegion(j);
                                if (merged.isInRange(sheetRowIndex, i)) {
                                    rowSpanFlag = true;
                                }

                            }
                            if (!rowSpanFlag) {
                                cell.setCellValue(value);
                                cell.setCellStyle(facetStyle);
                                sheet.addMergedRegion(new CellRangeAddress(
                                        sheetRowIndex, //first row (0-based)
                                        sheetRowIndex + (rowSpan - 1), //last row  (0-based)
                                        i, //first column (0-based)
                                        i  //last column  (0-based)
                                ));
                            }
                        }
                        if (colSpan > 1) {
                            cell = xlRow.createCell((short) i);

                            for (int j = 0; j < sheet.getNumMergedRegions(); j++) {
                                CellRangeAddress merged = sheet.getMergedRegion(j);
                                if (merged.isInRange(sheetRowIndex, i)) {
                                    cell = xlRow.createCell((short) ++i);
                                }
                            }
                            cell.setCellValue(value);
                            cell.setCellStyle(facetStyle);
                            sheet.addMergedRegion(new CellRangeAddress(
                                    sheetRowIndex, //first row (0-based)
                                    sheetRowIndex, //last row  (0-based)
                                    i, //first column (0-based)
                                    i + (colSpan - 1)  //last column  (0-based)
                            ));
                            i = i + colSpan - 1;
                        }
                    } else {
                        //TODO TRATAR E VERIRIFICAR SE  O VALUE PODE SER EXIBIDO
                        if (column.isExportable()) {
                            cell = xlRow.createCell((short) i);
                            for (int j = 0; j < sheet.getNumMergedRegions(); j++) {
                                CellRangeAddress merged = sheet.getMergedRegion(j);
                                if (merged.isInRange(sheetRowIndex, i)) {
                                    cell = xlRow.createCell((short) ++i);
                                }
                            }
                            cell.setCellValue(value);
                            cell.setCellStyle(facetStyle);
                        }    
                    }
                    if (column.isExportable()) {
                        i++;
                    }   
                }
            }

        }

    }
}

I managed the report again, but for a period from JAN to MAI, follows evidence:

inserir a descrição da imagem aqui

Browser other questions tagged

You are not signed in. Login or sign up in order to post.