2

I have formatted data as text while report to excel in datatable with below 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] =  data.body[i][j] + '\u200C';
                    }
                }
            }               
            }],

Format data as text when export to excel but, above code included special character(Hidden in Excel, copy cell value and paste to Textpad.exe it has "?" ) My client does not want it. Kindly give me a solution. if any alternate, please provide solution.

2
  • This seems to be an encoding issue. I believe you may have to set the charset to UTF-8 in the button properties: charset: 'UTF-8',. See here: stackoverflow.com/questions/44547622/… Commented Aug 31, 2018 at 14:16
  • I replicated with data like 99909999010000000015, when export it, this is put in Excel file as "99909999010000000000" (I think because of excel interpret like number and change last two numbers for zeros) Commented Jan 22, 2019 at 0:03

1 Answer 1

1

can u try to remove the '\u200C' char to see what happens ?

i think its because notepad can't handle unicode chars or something like that.

thanks

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the reply. if i remove '\u200C' char, the excel is automatically converts the number. (i.e 1234455567777878 to 1234455567777880 ) . so avoiding that only . i am adding unicode ('\u200C) in end of the data. Kindly provide your inputs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.