英文:
Data Exporter for PrimeFaces Extensions Sheet
问题
如何在PrimeFaces Extensions Sheet中导出数据,类似于PrimeFaces DataTable?
我尝试过PrimeFaces DataTable导出器,但它不支持表格。
<p:commandButton value="XLS" styleClass="mr-2 mb-2">
<p:dataExporter type="xls" target="mainForm:sheet" fileName="department"/>
</p:commandButton>
它抛出org.primefaces.extensions.component.sheet.Sheet无法转换为org.primefaces.component.datatable.DataTable
异常。我如何为PrimeFaces Extensions Sheet使用数据导出器。
JSF:2.2.1,PrimeFaces:12.0.0,PrimeFaces Extensions:12.0.5
英文:
How can i export data in PrimeFaces Extensions Sheet like PrimeFaces DataTable?
I tried PrimeFaces DataTable exporter like below but it doesn't support sheet table.
<p:commandButton value="XLS" styleClass="mr-2 mb-2">
<p:dataExporter type="xls" target="mainForm:sheet" fileName="department"/>
</p:commandButton>
It throws org.primefaces.extensions.component.sheet.Sheet cannot be cast to org.primefaces.component.datatable.DataTable
exception. How can I use data exporter for PrimeFaces Extensions Sheet.
JSF: 2.2.1, PrimeFaces: 12.0.0, PrimeFaces Extensions: 12.0.5
答案1
得分: 1
以下是翻译好的部分:
根据异常显示以及文档中所述,p:dataExporter
必须指向一个 PrimeFaces DataTable
。
由于Sheet
没有扩展 DataTable
,因此它不会与 p:dataExporter
一起工作。
使其工作的选项包括:
- 重构
Sheet
以扩展DataTable
。我没有调查过这一点,也不知道是否可能。 - 为表格创建一个导出器。
您可以创建一个问题报告,以请求对表格的导出支持。如果您能提供一个拉取请求,那将更好。
英文:
As the exception shows, and what the documentation states, p:dataExporter
"must point to a PrimeFaces DataTable
".
As Sheet
does not extend DataTable
, p:dataExporter
will not work with it.
Options to get it working are:
- Refactor
Sheet
to extendDataTable
. I did not investigate this, and do not know if this is possible at all. - Create an exporter for sheets.
You could create an issue to request export support for sheets. It would be even better if you would provided a pull request with it.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论