Excel not breaking.

Excel not breaking.

cicjrcicjr Posts: 7Questions: 2Answers: 0

"buttons": {
buttons: [
{ extend: 'csv',
title: exportFileName,
exportOptions: {
columns: ':visible', stripHtml: true,
modifier: {
// DataTables core
search: 'applied',
order: 'current',
page: 'all'
}
},

            format: {
                body: function ( data, column, row, node ) {
                // replace <BR> to "/"
                return column === 11 ?
                    data.replace( /<br\s*\/?>/ig, "\n" ) : data;

                return column === 12 ?
                    data.replace( /<br\s*\/?>/ig, "\n" ) : data;

                return column === 13 ?
                    data.replace( /<br\s*\/?>/ig, "\n" ) : data;

                return column === 14 ?
                    data.replace( /<br\s*\/?>/ig, "\n" ) : data;

                return column === 15 ?
                    data.replace( /<br\s*\/?>/ig, "\n" ) : data;

Answers

  • F12MagicF12Magic Posts: 109Questions: 0Answers: 28

    Hi @cicjr,

    did you already try:

    data.replace(/<br.*?>/gmi, '\u2028')

  • cicjrcicjr Posts: 7Questions: 2Answers: 0

    Thank you F12Magic.
    With that:
    columns: ':visible', stripHtml: true,
    modifier: {
    // DataTables core
    search: 'applied', // 'none', 'applied', 'removed'
    order: 'current', // 'current', 'applied', 'index', 'original'
    page: 'all' // 'all', 'current'
    }

    I won't be able replace it. What I need is to break the string and add "," after 5 digits.
    Let's say:
    1000130003
    It should export as :smile:
    10001, 30003

    Thank you again !

  • F12MagicF12Magic Posts: 109Questions: 0Answers: 28

    Could you clarify your question, or provide a working example?
    You want a csv export and split the values of certain columns. Is it that what you want?

This discussion has been closed.