首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >没有格式的Primefaces <p:dataExporter>下载

没有格式的Primefaces <p:dataExporter>下载
EN

Stack Overflow用户
提问于 2016-05-05 23:15:20
回答 1查看 845关注 0票数 0

我试图使用PrimeFaces将一个dataTable导出到csv和xls,但是在下载了该文件之后,它没有文件格式。

在我单击导出按钮并将文件保存到磁盘后,它不是保存为daily report.xls,而是将其保存为daily

奇怪的是,这种情况发生在firefox上,当我使用chrome时,它用文件格式正确地导出文件。我使用的是PrimeFaces 5.1

下面是导出按钮的代码

代码语言:javascript
复制
            <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>
EN

回答 1

Stack Overflow用户

发布于 2016-05-12 16:04:23

删除fileName属性<p:dataExporter>中的空格,例如,代替“每日报告”,提供"DailyReport“。它应该能正常工作。可能是Primefaces对组件的跨浏览器支持中的一个bug,但是这种解决方法应该会在Firefox中找到一个扩展名为适当的文件。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37061781

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档