Export to Excel format output data problem when remove commas
Export to Excel format output data problem when remove commas
touchlife
Posts: 4Questions: 3Answers: 0
I followed this way https://datatables.net/extensions/buttons/examples/html5/outputFormat-function.html
and it's return all column, body from
Transaction Amount
Withdraw Saving 1,000.00
to
Transaction Amount
<span id="ContentPlaceHolder1_GridView1_Label3_0">Withdraw Saving</span> <span id="ContentPlaceHolder1_GridView1_Label7_0">1,000.00</span>
on export Excel
this what i tried
var buttonCommon = {
exportOptions: {
format: {
body: function (data, column, row, node) {
return column === 9 ?
data.replace(/[,]/g, '') :
data;
}
}
}
};
$('#<%= GridView1.ClientID %>').dataTable({
//dom: 'Blfrtip',
dom: "<'row'<'col-sm-6'lB><'col-sm-6'f>><'row'<'col-sm-12'tr>><'row'<'col-sm-5'i><'col-sm-7'p>>",
paging: true,
buttons: [
{
extend: "colvis",
text: 'Show columns',
className: "btn-sm",
postfixButtons: ['colvisRestore'],
columns: ':gt(0)'
},
{
extend: "copy",
className: "btn-sm",buttonCommon
},
$.extend( true, {}, buttonCommon, {
extend: "excelHtml5",
className: "btn-sm",
title: "TL" + tdate
}),
{
extend: "print",
className: "btn-sm",
title: "TL" + tdate
}
],
//--Hide Column NO
//columnDefs: [
// {
// targets: 0,
// visible: false
// }
//],
"lengthMenu": [[20, 30, 40, -1], [20, 30, 40, "All"]],
colReorder: true,
responsive: false
});
document.getElementById("xcon").style.display = "block";
I don't know why it's just remove a 'Comma' on Column Amount but it's effect all column
This discussion has been closed.
Answers
Happy to take a look at it if you post a link to a test case showing the issue.
Allan