我试图使用PrimeFaces将一个dataTable导出到csv和xls,但是在下载了该文件之后,它没有文件格式。
在我单击导出按钮并将文件保存到磁盘后,它不是保存为daily report.xls,而是将其保存为daily。
奇怪的是,这种情况发生在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>发布于 2016-05-12 16:04:23
删除fileName属性<p:dataExporter>中的空格,例如,代替“每日报告”,提供"DailyReport“。它应该能正常工作。可能是Primefaces对组件的跨浏览器支持中的一个bug,但是这种解决方法应该会在Firefox中找到一个扩展名为适当的文件。
https://stackoverflow.com/questions/37061781
复制相似问题