Line Breaks not happening in the cells when using Export to Excel Button in Datatables

Line Breaks not happening in the cells when using Export to Excel Button in Datatables

vishyvishy Posts: 1Questions: 1Answers: 0
edited April 2019 in Free community support

Hi,

I'm using render columns option in the columns to show the data with Line breaks in one of the columns in the grid.
But when i use the Export to Excel button functionality, all data is being populated in one line on the cell in the excel sheet even thought orthogonal in export options is default as display.

This is the code in datatable initialisation

buttons: [
                      {
                          extend: 'excel', text: 'Export to Excel', filename: 'Data export', exportOptions: {

                              orthogonal: {
                                  display: ':null'
                              }
                          }
                      }],
 "columns": [
                               {
                                   "data": null,
                                   "defaultContent": "<button id >Add</button>",
                               },
                               { "data": "company", "autoWidth": true },
                               {
                                   "data": "notes", "autoWidth": true,

                                   
                               "render": function (data, type, row) {
                                   return data.split(", ").join("<br>");
                                   console.log(data);
                               }

I have attached the images related to the grid and excel.
I'm not sure what i'm missing here. Any help would be appreciated.

Thanks,
Vishy

Answers

  • feroz533feroz533 Posts: 2Questions: 0Answers: 0

    Hi, I am also facing same issue. Please let me know if it is resolved.

  • AZIIZAZIIZ Posts: 2Questions: 0Answers: 0

    I'm using this to force line break in excel :

    exportOptions: {
        format: {
            body: function ( data, row, column, node ) {
                return data.replace(/<br\s*\/?>/ig, "\r\n");
            }
        }
     }
    
    
This discussion has been closed.