PrimeFaces 12 dataexporters十进制数xls



更新到PrimeFaces 12时,dataexporters在格式化xls中的十进制数字时出现错误。例如:50.00正在打印5000注意:下面的尝试在本地(win10)解决了问题,但在服务器上问题仍然存在。

<f:facet name="header">
<div align="center">
<p:outputPanel style="float: right;">
<h:commandLink id="gerarXls" styleClass="table-button generateXls">
<p:graphicImage name="/images/table-icons/file-xls.svg"/>
<p:dataExporter type="xls" target="datatableOrdemServico" fileName="Ordens de Servico"
options="#{dataExporterCustomizedView.excelOpt}"/>
</h:commandLink>
</p:outputPanel>
</div>
</f:facet>
<p:column width="50" style="text-align: right"
sortBy="#{ordemServico.totalGeral}" filterMatchMode="contains" filterBy="#{ordemServico.totalGeral}">
<f:facet name="header">
<h:outputText value="Total OS"/>
</f:facet>
<h:outputText value="#{ordemServico.totalGeral}" >
<f:convertNumber minFractionDigits="2" locale="pt-BR"/>
</h:outputText>
</p:column>
public class DataExporterCustomizedView implements Serializable {
private ExcelOptions excelOpt;
@PostConstruct
public void init() {
excelOpt = new ExcelOptions();
excelOpt.setFacetBgColor("#F88017");
excelOpt.setFacetFontSize("10");
excelOpt.setFacetFontColor("#0000ff");
excelOpt.setFacetFontStyle("BOLD");
excelOpt.setCellFontColor("#00ff00");
excelOpt.setCellFontSize("8");
excelOpt.setStronglyTypedCells(true);
excelOpt.setNumberFormat(new DecimalFormat("#,##0.00"));
excelOpt.setCurrencyFormat((DecimalFormat) DecimalFormat.getCurrencyInstance(new Locale("pt", "BR")));
}
public ExcelOptions getExcelOpt() {
return excelOpt;
}
}

从此票:https://github.com/primefaces/primefaces/issues/8961

不支持设置自定义的每个单元格基础,并且超出了范围

目前,dataexporters检测功能只考虑属性"CurrencyFormat"或";DecimalFormat"在ExcelOptions中,如果不是定义,在faces-config.xml中。

或者在faces-config.xml中设置faces-config.xml

<locale-config>
<default-locale>pt_BR</default-locale>
</locale-config>

我的猜测:您的服务器处于不同的语言环境中,这就是Faces的默认设置,因为您在Faces -config.xml中缺少显式的语言环境设置。

最新更新