When updating to PrimeFaces 12, DataExporter presented an error in formatting decimal numbers in xls. Example: 50.00 is being printed 5,000 Note: the attempt below solved the problem locally (win10), but the problem persists on the server.
<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;
}
}
From this ticket: https://github.com/primefaces/primefaces/issues/8961
Or by setting it in faces-config.xml faces-config.xml
My Guess: Your server is in a differnet locale so that is what Faces is defaulting to because you are missing the explicit locale setting in your faces-config.xml.