2
I’m using the Excelbuilderjs to produce an Excel spreadsheet on demand and offer as a download to the customer. Ideally, this needs to be done on the client, not on the server, and the library works very well in this respect.
However I encountered a problem when creating formatted cells as 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 a fiddle who demonstrates it working:
http://jsfiddle.net/6ndTq/
The problem is that when I open the result, I see the following:
Opening the cell formatting, there is the following:
Clearly it was not #,##000
what I typed into the code. If you manually switch to #.##0,00
which is what’s in the code, the format appears as it should be:
I tried some variations of this formatting unsuccessfully. What can I do?