Issue when exporting to EXCEL
Issue when exporting to EXCEL
Giu171
Posts: 2Questions: 1Answers: 0
Hello!
First of all, sorry for my English, as it is not my mother language.
When I export my table to excel, I format numbers to portuguese.
For example, 1000,00 = 1.000,00.
However, in EXCEL the number gets an apostrophe in the beginning ('1.000,00).
How can I avoid this?
Follows:
$('#listaVendas').dataTable({
dom: "lfrtBpi",
aaSorting: [[0, "desc"]],
bFilter: false,
bLengthChange: false,
iDisplayLength: 50,
pagingType: "simple",
bRetrieve: true,
buttons: [
{
extend: "excelHtml5",
text: "Excel",
title: "PedidosVenda",
exportOptions: {
columns: [0, 1, 2, 3, 4, 5],
format: {
body: function (data, row, column, node) {
data = $('<p>' + data + '</p>').text();
return $.isNumeric(data.replace(',', '.')) ? data.replace(',', '.') : data;
}
}
}
},
{
extend: "pdfHtml5",
text: "PDF",
title: "PedidosVenda",
exportOptions: {
columns: [0, 1, 2, 3, 4, 5]
}
}
],
columnDefs: [
{
type: "date-uk",
targets: 1
},
{
type: "formatted-num",
targets: 4
}
],
columns: [
{
"name": "0",
"orderable": true
},
{
"name": "1",
"orderable": true
},
{
"name": "2",
"orderable": true
},
{
"name": "3",
"orderable": true
},
{
"name": "4",
"orderable": true
},
{
"name": "5",
"orderable": true
},
{
"name": "6",
"orderable": false
}
]
});
Thank you very much.
This discussion has been closed.
Answers
There are a number of other discussions on this topic if you search the forum - for example.
Currently this is a limitation in the i18n support for the Excel file creation.
Allan