Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsf 从primefaces数据表导出的excel文件中不显示标题_Jsf_Primefaces_Data Export - Fatal编程技术网

Jsf 从primefaces数据表导出的excel文件中不显示标题

Jsf 从primefaces数据表导出的excel文件中不显示标题,jsf,primefaces,data-export,Jsf,Primefaces,Data Export,我有一个这样的数据表。但它不会将标题导出到excel: <h:form id="formOptionList"> <p:dataTable id="OptionTable" var="Options" widgetVar="OptionTable" value="#{managedBean.options}" filteredValue="#{managedBean.filt

我有一个这样的数据表。但它不会将标题导出到excel:

<h:form id="formOptionList">
<p:dataTable id="OptionTable"
             var="Options"
             widgetVar="OptionTable"
             value="#{managedBean.options}"
             filteredValue="#{managedBean.filteredOptions}"
             emptyMessage="No  Options found."
             rendered="#{managedBean.userPreferences.showTable}"
             paginator="true"
             rows="10"
             paginatorTemplate="{FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
             rowsPerPageTemplate="20,50,100"
             >

<p:column id="id" headerText="ID" filterBy="id" filterMatchMode="exact" width="12%" rendered="#{managedBean.userPreferences.showID}" >
        <h:outputText value="#{options.optionID}" />
</p:column>
....
....

</p:dataTable>

<h:panelGrid columns="1">
    <p:panel header="Export All Data">
        <h:commandLink>
            <p:graphicImage value="../resources/images/menuicons/options.png" />
            <p:dataExporter type="xls" target="OptionTable" fileName="Options" />
        </h:commandLink>
    </p:panel>
</h:panelGrid>

 </h:form>  

....
....
所以我把它改成了

 <p:column id="id" filterBy="id" filterMatchMode="exact" width="12%" rendered="#{managedBean.userPreferences.showID}" >
    <f:facet name="header>">
        <h:outputText value="Option ID"/>
   </f:facet>
   <h:outputText value="#{Options.OptionID}" /> 
</p:column>

我仍然没有在excel文件中看到标题。有什么想法吗

从primefaces数据表导出的excel文件中不显示标题

是否在
后添加

<p:column>
    <f:facet name="header">
        <h:outputText value="Your Column Name" />
    </f:facet>
    <h:outputText value="Your value" />
</p:column> 

试试这个:

<p:column id="id" filterBy="#{Options.OptionID}" filterMatchMode="exact" width="12%" rendered="#{managedBean.userPreferences.showID}" >
    <f:facet name="header>">
        <h:outputText value="Option ID"/>
    </f:facet>
    <h:outputText value="#{Options.OptionID}" /> 
</p:column>

您可以在显示无的情况下放置一个新列,只需在现有列中放置一个导出器false即可

<p:column id="id" filterBy="# Options.OptionID}"filterMatchMode="exact" width="12%" rendered="#anagedBean.userPreferences.showID}"exporter="false">
        <f:facet name="header>">
                    <h:outputText value="Option ID" />
        </f:facet>
                <h:outputText value="#{Options.OptionID}" />
</p:column>

添加显示无的新列,并删除所有排序、筛选和渲染

<p:column exporter="true" style="display:none;">
    <f:facet name="header>">
        <h:outputText value="Option ID"/>
   </f:facet>
   <h:outputText value="#{Options.OptionID}" /> 
  </p:column>


这非常有效。

您是否能够在导出的
ExCEL
文件中至少查看
您的数据?是的,我能够导出数据。我只是在excel表格中看不到标题。我知道这个问题有点老了,但这里的主要问题是
中有一个打字错误。