Click here to Skip to main content
14,735,364 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello,

I am using DataTable to export into Excel.
In one of my cell using a long number which is automatically rounding off when exported to Excel.

EG.
1921213425466648
This number converted to
1921213425466650


I need to keep it as it is.

What I have tried:

$('#divDetailedSBP').DataTable({
                "order": [],
                dom: 'Bfrtip',
                buttons: [
                    
                        {
                        extend: 'excel',
                        text: 'Excel',
                       

                    }
                ]
                               
            });
Posted
Updated 17-Nov-20 7:38am
v3
Comments
CHill60 17-Nov-20 12:31pm
   
I have updated your question to remove the all-capital letters. All capitals is considered to be shouting on the Internet, and is rude. Please remember to use proper case when asking questions in future, more people will be willing to try to help you
faisal23 17-Nov-20 12:35pm
   
Thanx buddy
I will.

1 solution

Hello,
I solved it using the below line of code.

"buttons": [{
           extend: 'excel',
           exportOptions: {
               orthogonal: 'sort'
           },
           customizeData: function ( data ) {
               for (var i=0; i<data.body.length; i++){
                   for (var j=0; j<data.body[i].length; j++ ){
                       data.body[i][j] = '\u200C' + data.body[i][j];
                   }
               }
           }
           }],
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900