use*_*009 5 java jsf primefaces
我有一个<p:dataTable>:
<p:dataTable id="contracttblenone" var="contract" value="#{reportController.listcontract}" rowKey="#{contract.id}" paginator="true" rows="10" paginatorPosition="bottom" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" rowsPerPageTemplate="5,10,15" resizableColumns="true" emptyMessage="">
<p:column>
<f:facet name="header">
<h:outputText value="?"/>
</f:facet>
<h:outputText value="#{contract.id}"/>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Firma Ad?"/>
</f:facet>
<h:outputText value="#{contract.name}"/>
</p:column>
<p:columns width="60" value="#{contract.liscolumn}" var="column">
<f:facet name="header">
<h:outputText value=" #{column.header} "/>
</f:facet>
<h:outputText value=" #{column.property} " />
</p:columns>
<f:facet name="header">
<h:outputText value="Sirket Sozlesmeler"/>
</f:facet>
</p:dataTable>
Run Code Online (Sandbox Code Playgroud)
这是我的commandLink:
<h:commandLink>
<p:graphicImage value="../img/xls.png" />
<p:dataExporter type="xls" target=":formreport:contracttblenone"
fileName="report" />
</h:commandLink>
Run Code Online (Sandbox Code Playgroud)
以下是dataTable的外观

但是导出的xls是不同的.它正在修改所有的rowas,因为最后一个是来自excel的snaphsot:

嗯,我在使用 primefaces 的导出到 Excel 功能时也遇到了一些问题。我在 stackoverflow 和 primefacesForums 上搜索了很多,但刚刚知道这是一个 primefaces 相关的版本问题。顺便说一下,我已经制作了自己的函数,现在可以完美运行也可以根据导出为其他格式进行修改。
<p:commandLink id="back" value="Export to Excel" action="#{agendaBean.exportToExl}" immediate="true"
ajax="false" style="color: #086A87;" ></p:commandLink>
Run Code Online (Sandbox Code Playgroud)
单击链接后,将在具有以下内容的 bean 中调用 exportToExl 方法。
public String exportToExl() {
ExportToExcel expExlBean = new ExportToExcel();
List<String> columnNames = new ArrayList<String>();
columnNames.add("Agenda ID");
columnNames.add("Matter");
columnNames.add("Item");
columnNames.add("OrderNo");
columnNames.add("AccessPrivilegeString");
columnNames.add("DocumentNameDisplay");
columnNames.add("DocumentFolderPath");
List<String> columnType = new ArrayList<String>();
columnType.add(FrameWorkConstants.DO_NOT_FORMAT);
columnType.add(FrameWorkConstants.DO_NOT_FORMAT);
columnType.add(FrameWorkConstants.DO_NOT_FORMAT);
columnType.add(FrameWorkConstants.DO_NOT_FORMAT);
columnType.add(FrameWorkConstants.DO_NOT_FORMAT);
columnType.add(FrameWorkConstants.DO_NOT_FORMAT);
columnType.add(FrameWorkConstants.DO_NOT_FORMAT);
String companyFolderPath = new AgendaIMPL()
.getCompanyFolderPath(meetingID);
if (agendaList != null) {
for (int i = 0; i < agendaList.size(); i++) {
agendaList.get(i).setDocumentFolderPath(companyFolderPath);
}
}
List expList = agendaList;
if (expList == null || expList.isEmpty()) {
ResourceBundle rb = ResourceBundle
.getBundle("resources.error1");
if (rb != null) {
Utils.addMessage(rb.getString("34").trim(),
FacesMessage.SEVERITY_ERROR);
return null;
}
}
String strVOName = "com.ultimatix.boardAdmin.vo.AgendaVO";
FacesContext fc = FacesContext.getCurrentInstance();
HttpServletResponse response = (HttpServletResponse) fc
.getExternalContext().getResponse();
String flagStart = FrameWorkConstants.SINGLE;
expExlBean.exportToExcel(columnNames, columnType, response,
expList, strVOName, flagStart);
fc.responseComplete();
return null;
}
Run Code Online (Sandbox Code Playgroud)
这里的 AgendaList 是您在数据表中使用的列表,用于填充要在 Excel 工作表中打印的行。
如果您有任何更关心的问题,请告诉我。
| 归档时间: |
|
| 查看次数: |
3704 次 |
| 最近记录: |