Need to format output data excel to show yes for 1 and no for 0

Need to format output data excel to show yes for 1 and no for 0

narbehmovsesiannarbehmovsesian Posts: 2Questions: 1Answers: 0

Hello,

I currently have
exportOptions: {
format: {
body: function ( data, column, row ) {
return column === 7 ?
data.replace (1 , 'YES') :
data;
}
}

This works fine, but my problem is that I also need to do data.replace( 0 , 'NO' ) on the same row.

Thank you

Answers

  • narbehmovsesiannarbehmovsesian Posts: 2Questions: 1Answers: 0

    After trying different approaches I found the solution to this problem

                format: {
                        body: function ( data, column, row ) {              
                            if(data == 1){
                                return data.replace(data,'YES');
                            }
                            else if (data == 0){
                                return data.replace(data,'NO');
                            }
                            else if (data == 2){
                                return data.replace(data,'TBD');
                            }
                            else if (column === 5){         
                                return data.replace( /[<p></p>]/g, ' ' )
                            }
                            else {
                                return data;
                            }  
                         },
                        }
    
  • allanallan Posts: 61,985Questions: 1Answers: 10,162 Site admin

    Yes, this is the correct approach at the moment. You can also use orthogonal data as another approach.

    Allan

This discussion has been closed.