2016-05-05 30 views
0

我想使用PrimeFaces將數據表導出到csv和xls,但文件下載後,它沒有文件格式。Primefaces <p:dataExporter>下載沒有格式

我點擊導出按鈕,將文件保存到我的磁盤,而不是被保存爲日常的report.xls它只是將其保存爲每天後。

奇怪的是這種情況發生在Firefox上,當我使用chrome時,它以文件格式正確地導出文件。我正在使用PrimeFaces 5.1

下面是我對導出按鈕

  <p:commandLink id="exportExcel" title="Export to Excel" ajax="false"> 
       <p:dataExporter type="xls" target="report" fileName="daily report" /> 
       <h:graphicImage library="img" name="icons/excel-file-icon.svg" styleClass="icon-medium" /> 
      </p:commandLink> 
      <p:commandLink id="exportCsv" title="Export to CSV" ajax="false"> 
       <p:dataExporter type="csv" target="report" fileName="daily report" /> 
       <h:graphicImage library="img" name="icons/csv-file-icon.svg" styleClass="icon-medium" /> 
      </p:commandLink> 

回答

0

代碼的<p:dataExporter>例如文件名屬性刪除空間而不是「每日報告」,提供「每日報告」。它應該工作得很好。可能是組件的Primefaces跨瀏覽器支持中的一個錯誤,但是此解決方法應該爲您提供一個在Firefox中具有適當擴展名的文件。