我使用的是rich:extendedDataTable组件,而不是dataTable。我可以将Bean中的dataModelList导出为excel文件
但是,我想打开浏览器下载面板,并在单击“导出”按钮时看到其excel导出图标。
public class Bean extends ListBean {
public void writeToExcel() {
ExcelUtils.writeToExcel("../test.xlsx", modelList);
}
}
public class ExcelUtils {
public static <T> void writeToExcel(String fileName, List<T> data) {
// .....
}
}
<rich:extendedDataTable width="100%" selection="#{Bean.selection}"
selectionMode="multipleKeyboardFree" id="modelList" value="#{bean.modelList}" var="model" rows="#{bean.dataTableRowCountEachPage}" rendered="#{loginBean.selectPriv()}" rowClasses="odd-row,even-row" >
</rich:extendedDataTable>
<h:commandButton value="Export XLSX" ajax="false" action="#{bean.writeToExcel())}">