I am using ExcelBuilderJS to produce an Excel spreadsheet on demand and download it to the customer. Ideally, this needs to be done on the client, not the server, and the library works very well in that respect.
However, I encountered a problem when creating cells formatted as an accounting. My code can be summarized in the following:
var workbook = Excel.createWorkbook();
var sheet = workbook.createWorksheet({name: "Teste de Moeda"});
workbook.addWorksheet(sheet);
var currency = workbook.getStyleSheet().createFormat({
format: "#.##0,00"
});
var data = [[ // Essa é a célula A1
{value: 1234567.89, // Deve exibir como "1.234.567,89" no excel
metadata: {style: currency.id}}
]];
sheet.setData(data);
sheet.setColumns([{width: 15}]);
saveAs(Excel.createFile(workbook, {type: "blob"}), "moeda.xlsx");
Here's a fiddle that shows it working:
link
The problem is that when I open the result, I see the following:
Openingtheformattingofthecell,therearethefollowing:
Clearly it was not #,##000
what I typed in the code. If you manually change to #.##0,00
which is what is in the code, the format appears as it should:
I tried some variations of this format without being successful. What can I do?