【问题标题】:Primefaces <p:dataExporter> downloads with no formatPrimefaces <p:dataExporter> 下载无格式
【发布时间】:2016-05-05 23:15:20
【问题描述】:

我正在尝试使用 PrimeFaces 将数据表导出为 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>

【问题讨论】:

    标签: jsf primefaces


    【解决方案1】:

    删除&lt;p:dataExporter&gt; 的fileName 属性中的空格,例如代替“每日报告”,提供“每日报告”。它应该工作得很好。可能是 Primefaces 对该组件的跨浏览器支持中的一个错误,但这种解决方法应该会在 Firefox 中为您提供一个具有适当扩展名的文件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-07-04
      • 1970-01-01
      • 1970-01-01
      • 2021-09-04
      • 1970-01-01
      • 2022-12-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多