我得到了使用过滤器的 primefaces 数据表。一切正常。但是当我将数据表导出到 excel 文件时,没有显示标题。
这里我使用 external remoteCommand 来处理服务器端的事件。
这是xhtml代码:
<h:form>
<p:commandButton value="#{dictionary['export_to_excel']}" icon="ui-icon-calculator" ajax="false">
<p:dataExporter type="xls" target=":gwsReportAllPartForm:gwsReportAllPartListDataTable" fileName="analytics"/>
</p:commandButton>
</h:form>
<h:form id="gwsReportAllPartForm">
<p:remoteCommand name="updateFilters" update=":gwsReportAllPartForm:gwsReportAllPartListDataTable"></p:remoteCommand>
<p:dataTable id="gwsReportAllPartListDataTable"
value="#{viewAllAnalyticsBean.gwsReportPartTwoList}"
var="report"
paginator="true"
rows="100"
paginatorTemplate="{PageLinks} {CurrentPageReport}"
currentPageReportTemplate="{currentPage} #{dictionary['out_of']} {totalPages}"
emptyMessage="#{dictionary['nothing_is_here']}"
scrollable="true"
scrollWidth="1050"
scrollHeight="500">
<p:ajax event="filter" listener="#{viewAllAnalyticsBean.onFilterDataTable}" oncomplete="updateFilters()"/>
<p:column headerText="#{dictionary['reporting_period']}" styleClass="columnCustomClass" style="width: 90px;position:relative; padding-bottom: 30px;">
<h:outputText value="#{report.gwsReportPartOne.year}, #{report.gwsReportPartOne.quarter}"/>
</p:column>
<p:column headerText="#{dictionary['subsoil_user_contract_register_number']}" styleClass="columnCustomClass" style="width: 90px;position:relative; padding-bottom: 30px;" filterBy="#{report.gwsReportPartOne.contractNumber}" filterMatchMode="contains" filterStyle="width:80px; position:absolute; bottom:4px;" filterValue="">
<h:outputText value="#{report.gwsReportPartOne.contractNumber}"/>
</p:column>
<p:column headerText="#{dictionary['gws_type']}" styleClass="columnCustomClass" style="width: 40px;position:relative; padding-bottom: 30px;" filterBy="#{report.gwsReportPartOne.gwsType.code}" filterMatchMode="contains" filterStyle="width:30px; position:absolute; bottom:4px;">
<h:outputText value="#{report.gwsReportPartOne.gwsType.code}" />
</p:column>
<p:column id="tender_code" headerText="#{dictionary['gws_code_by_skp']}" width="100" style="position:relative; padding-bottom: 30px;" styleClass="columnCustomClass" filterBy="#{report.skp.code}" filterMatchMode="contains" filterStyle="width:90px; position:absolute; bottom:4px;">
<h:outputText value="#{report.skp.code}"/>
</p:column>
<p:column headerText="#{dictionary['item_name_and_short_description_of_purchased_gws']}" styleClass="columnCustomClass" style="width: 150px; position:relative; padding-bottom: 30px;" filterBy="#{report.description}" filterMatchMode="contains" filterStyle="width:140px; position:absolute; bottom:4px;">
<h:outputText value="#{report.description}" />
</p:column>
<p:column headerText="#{dictionary['purchase_way']}" styleClass="columnCustomClass" style="width: 50px; position:relative; padding-bottom: 30px;" filterBy="#{report.gwsReportPartOne.tenderType.code}" filterMatchMode="contains" filterStyle="width:40px; position:absolute; bottom:4px;">
<h:outputText value="#{report.gwsReportPartOne.tenderType.code}" />
</p:column>
<p:column headerText="#{dictionary['agreement_number']}" styleClass="columnCustomClass" style="width: 80px; position:relative; padding-bottom: 30px;" filterBy="#{report.gwsReportPartOne.agreementNumber}" filterMatchMode="contains" filterStyle="width:70px; position:absolute; bottom:4px;">
<h:outputText value="#{report.gwsReportPartOne.agreementNumber}" />
</p:column>
<p:column headerText="#{dictionary['tender_result_date']}" styleClass="columnCustomClass" style="width: 80px; position:relative; padding-bottom: 30px;" filterBy="#{report.gwsReportPartOne.resultDate}" filterMatchMode="contains" filterStyle="width:70px; position:absolute; bottom:4px;">
<h:outputText value="#{report.gwsReportPartOne.resultDate}" >
<f:convertDateTime pattern="dd.MM.yyyy"/>
</h:outputText>
</p:column>
<p:column headerText="#{dictionary['agreement_conclusion_date']}" styleClass="columnCustomClass" style="width: 80px; position:relative; padding-bottom: 30px;" filterBy="#{report.gwsReportPartOne.agreementStartDate}" filterMatchMode="contains" filterStyle="width:70px; position:absolute; bottom:4px;">
<h:outputText value="#{report.gwsReportPartOne.agreementStartDate}" >
<f:convertDateTime pattern="dd.MM.yyyy"/>
</h:outputText>
</p:column>
<p:column headerText="#{dictionary['agreement_deadline_date']}" styleClass="columnCustomClass" style="width: 80px; position:relative; padding-bottom: 30px;" filterBy="#{report.gwsReportPartOne.agreementEndDate}" filterMatchMode="contains" filterStyle="width:70px; position:absolute; bottom:4px;">
<h:outputText value="#{report.gwsReportPartOne.agreementEndDate}" >
<f:convertDateTime pattern="dd.MM.yyyy"/>
</h:outputText>
</p:column>
<p:column headerText="#{dictionary['agreement_status']}" styleClass="columnCustomClass" style="width: 50px; position:relative; padding-bottom: 30px;" filterBy="#{report.gwsReportPartOne.agreementStatus.code}" filterMatchMode="contains" filterStyle="width:40px; position:absolute; bottom:4px;">
<h:outputText value="#{report.gwsReportPartOne.agreementStatus.code}" />
</p:column>
<p:column headerText="#{dictionary['total_sum_of_agreement_without_vat']}, #{viewAllAnalyticsBean.getThTengeOrUsd()}" styleClass="columnCustomClass" style="width: 80px; position:relative; padding-bottom: 30px;" filterBy="#{report.gwsReportPartOne.agreementSum}" filterMatchMode="contains" filterStyle="width:70px; position:absolute; bottom:4px;">
<h:outputText value="#{viewAllAnalyticsBean.convertValueToCurrentCurrency(report.gwsReportPartOne.agreementSum)}">
<f:convertNumber pattern="0.00#" locale="ru-RU"/>
</h:outputText>
</p:column>
<p:column headerText="#{dictionary['planned_sum_in_gpz_without_vat']}, #{viewAllAnalyticsBean.getThTengeOrUsd()}" styleClass="columnCustomClass" style="width: 80px; position:relative; padding-bottom: 30px;" filterBy="#{report.gwsReportPartOne.plannedSum}" filterMatchMode="contains" filterStyle="width:70px; position:absolute; bottom:4px;">
<h:outputText value="#{viewAllAnalyticsBean.convertValueToCurrentCurrency(report.gwsReportPartOne.plannedSum)}" >
<f:convertNumber pattern="0.00#" locale="ru-RU"/>
</h:outputText>
</p:column>
<p:column headerText="#{dictionary['actually_paid_sum_for_report_period_of_agreement_without_vat']}, #{viewAllAnalyticsBean.getThTengeOrUsd()}" styleClass="columnCustomClass" style="width: 80px; position:relative; padding-bottom: 30px;" filterBy="#{report.gwsReportPartOne.actuallyPaidSum}" filterMatchMode="contains" filterStyle="width:70px; position:absolute; bottom:4px;">
<h:outputText value="#{viewAllAnalyticsBean.convertValueToCurrentCurrency(report.gwsReportPartOne.actuallyPaidSum)}" >
<f:convertNumber pattern="0.00#" locale="ru-RU"/>
</h:outputText>
</p:column>
<p:column headerText="#{dictionary['tender_volume_without_vat_in_price']}, #{viewAllAnalyticsBean.getThTengeOrUsd()}" styleClass="columnCustomClass" style="width: 100px; position:relative; padding-bottom: 30px; background-color: #{two.gwsSumWithoutVatColor}" filterBy="#{report.gwsSumWithoutVat}" filterMatchMode="contains" filterStyle="width:90px; position:absolute; bottom:4px;">
<h:outputText value="#{viewAllAnalyticsBean.convertValueToCurrentCurrency(report.gwsSumWithoutVat)}">
<f:convertNumber pattern="0.00#" locale="ru-RU"/>
</h:outputText>
</p:column>
<p:column headerText="#{dictionary['supplier_bin_iin']}" styleClass="columnCustomClass" style="width: 80px; position:relative; padding-bottom: 30px;" filterBy="#{report.gwsReportPartOne.supplierBinOrIin}" filterMatchMode="contains" filterStyle="width:70px; position:absolute; bottom:4px;">
<h:outputText value="#{report.gwsReportPartOne.supplierBinOrIin}" />
</p:column>
<p:column headerText="#{dictionary['supplier_gws_name']}" styleClass="columnCustomClass" style="width: 150px; position:relative; padding-bottom: 30px;" filterBy="#{report.gwsReportPartOne.supplierName}" filterMatchMode="contains" filterStyle="width:140px; position:absolute; bottom:4px;">
<h:outputText value="#{report.gwsReportPartOne.supplierName}" />
</p:column>
<p:column headerText="#{dictionary['supplier_gws_country']}" styleClass="columnCustomClass" style="width: 60px; position:relative; padding-bottom: 30px;" filterBy="#{report.gwsReportPartOne.supplierCountry.code}" filterMatchMode="contains" filterStyle="width:50px; position:absolute; bottom:4px;">
<h:outputText value="#{report.gwsReportPartOne.supplierCountry.code}" />
</p:column>
<p:column headerText="#{dictionary['local_content_piece']}, %" styleClass="columnCustomClass" style="width: 80px; position:relative; padding-bottom: 30px;" filterBy="#{report.kazcontent}" filterMatchMode="contains" filterStyle="width:70px; position:absolute; bottom:4px;">
<h:outputText value="#{report.kazcontent}" >
<f:convertNumber pattern="0.00#" locale="ru-RU"/>
</h:outputText>
<ui:remove><h:outputText value="#{report.kazcontentInService}" >
<f:convertNumber pattern="0.00#" locale="ru-RU"/>
</h:outputText></ui:remove>
</p:column>
<p:column headerText="#{dictionary['procurement_sum_of_local_content_of_tru']}, #{viewAllAnalyticsBean.getThTengeOrUsd()}" styleClass="columnCustomClass" style="width: 80px; position:relative; padding-bottom: 30px;" filterBy="#{report.procurementSumOfLocalContentOfGws}" filterMatchMode="contains" filterStyle="width:70px; position:absolute; bottom:4px;">
<h:outputText value="#{viewAllAnalyticsBean.convertValueToCurrentCurrency(report.procurementSumOfLocalContentOfGws)}" >
<f:convertNumber pattern="0.00#" locale="ru-RU"/>
</h:outputText>
</p:column>
<p:columnGroup type="footer">
<p:row>
<p:column footerText="#{dictionary['totals']}: " style="text-align:right"/>
<p:column footerText="" />
<p:column footerText="" />
<p:column footerText="" />
<p:column footerText="" />
<p:column footerText="" />
<p:column footerText="" />
<p:column footerText="" />
<p:column footerText="" />
<p:column footerText="" />
<p:column footerText="" />
<p:column footerText="#{viewAllAnalyticsBean.totalAgreementSum}" />
<p:column footerText="#{viewAllAnalyticsBean.totalPlannedSum}" />
<p:column footerText="#{viewAllAnalyticsBean.totalActualPaid}" />
<p:column footerText="#{viewAllAnalyticsBean.totalGwsSum}" />
<p:column footerText="" />
<p:column footerText="" />
<p:column footerText="" />
<p:column footerText="#{viewAllAnalyticsBean.averageKazContent} %" />
<p:column footerText="#{viewAllAnalyticsBean.totalGwsLocalContent}" />
</p:row>
</p:columnGroup>
</p:dataTable>
</h:form>