title: Export value with Linebreaks into single cell in Excel. jQuery Datatables
body: <p>I am successfully exporting HTML tables from a web application to excel using jQuery DataTables. However one particular column has values containg line breaks and tabs. I have managed to display the data correctly on the HTML table by replacing new lines (\n) and tabs (\t) with <code>&lt;br&gt;</code> and &amp;nbsp;(x5) respectively.</p>
  
  <p>The issue is when exporting to excel i need to have the line breaks back in but keep all the value in one cell.</p>
  
  <p>here is my jquery code:</p>
  
  <pre class="lang-js prettyprint-override"><code>    $('#papercliptable').dataTable({
      "sDom": 'T&lt;"clear"&gt;lfrtip',
      "tableTools": {
          "aButtons": [{
              "sExtends": "xls",
              "sButtonText": "Excel",
              "fnCellRender": function (sValue, iColumn, nTr, iDataIndex) {
                  console.log("sValue = " + sValue);
                  console.log("iColumn = " + iColumn);
                  return sValue.replace(/&lt;br\s*\/?&gt;/ig, "\r\n");
              },
              "sNewLine": "\r\n"
          }, {
              "sExtends": "print",
              "sMessage": "Metrics"
          }]
      }
  });
  </code></pre>
  
  <p>Credit: <a href="https://stackoverflow.com/questions/20934876/jquery-datatables-export-with-newline-break-in-cell-using-jquery">post</a></p>
  
  <p>It does not seem to work for me. All value goes to single cell but not with new line characters.</p>
  
  <p>Any help would be greatly appreciated.
  Thanks</p>
  
  <p>Tried using: </p>
  
  <pre><code>return sValue.replace(/&lt;br\s*\/?&gt;/ig, "\x0B");
  </code></pre>
  
  <p>produces the following 
  <img src="https://i.stack.imgur.com/HDCyi.jpg" alt="enter image description here"></p>