body: function(data, row, column, node) {
// Assuming the problematic column is at index 6 (seventh column)
if (column === 6) {
return data ? data : ''; // Force conversion to string to maintain the integrity of the 16-digit number
}
return data;
}
on the column 6 there are 16 digit value number, due to that when i export, the value is rounded off or any special character are added in the beginning of the 16 digit number.
what can be the solution
The test case doesn't appear to show a table or export buttons?
Forcing the column to be a string sounds like a good plan though, although return data ? data : ''; doesn't appear to do that? data.toString() perhaps?
i almost tried this much thing non of them work
return \${data}; output:2223703360068248
return \u200B${data}; output: 2223703360068248
return data.toString(); output: 2223703360068250
return "${data}"; output: "2223703360068248"
return '${data}; output: '2223703360068248
var file_name = '<?php echo $file_name_excel ?>';
$('#dynamic_table').DataTable({
dom: 'Bifrtp',
bPaginate: false,
ordering: true,
buttons: [{
extend: 'excel',
footer: true,
title: file_name,
className: 'excel-buttonNAD',
exportOptions: {
columns: ':visible',
format: {
header: function(mDataProp, columnIdx) {
var htmlText = '<span>' + mDataProp + '</span>';
var jHtmlObject = jQuery(htmlText);
jHtmlObject.find('div').remove();
var newHtml = jHtmlObject.text();
return newHtml;
},
body: function(data, row, column, node) {
// Assuming the problematic column is at index 6 (seventh column)
if (column === 6) {
return `\`${data}`; // Force conversion to string to maintain the integrity of the 16-digit number
}
return data;
}
}
}
}, {
className: 'colVisBAT',
extend: 'colvis',
text: 'Column Visibility',
collectionLayout: 'fixed two-column'
}]
});
the code is huge i cant make it running here.
the problem is i have to upload the excel in a portial, which has 16 digit.
we have to do something to make it to string
because in number it is automatically rounding off.
Answers
body: function(data, row, column, node) {
// Assuming the problematic column is at index 6 (seventh column)
if (column === 6) {
return data ? data : ''; // Force conversion to string to maintain the integrity of the 16-digit number
}
return data;
}
on the column 6 there are 16 digit value number, due to that when i export, the value is rounded off or any special character are added in the beginning of the 16 digit number.
what can be the solution
The test case doesn't appear to show a table or export buttons?
Forcing the column to be a string sounds like a good plan though, although
return data ? data : '';
doesn't appear to do that?data.toString()
perhaps?Allan
i almost tried this much thing non of them work
return
\
${data}; output:
2223703360068248return
\u200B${data}
; output: 2223703360068248return data.toString(); output: 2223703360068250
return
"${data}"
; output: "2223703360068248"return
'${data}
; output: '2223703360068248Can you update the test case to be running and show the issue so I can try to debug it?
Allan
the code is huge i cant make it running here.
the problem is i have to upload the excel in a portial, which has 16 digit.
we have to do something to make it to string
because in number it is automatically rounding off.
We don't want the full code for a test case. The test case should be reduced done to the code and data that replicate the issue.
There are a couple different ways to try resolving this presented in this thread. Let us know if one of those helps. If you still need help then please provide a simple test case showing the issue.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
Ok, thanks i will check and let you know about the update