DataTables Excel Export - How to remove HTML tags from the export
By default, DataTables include HTML tags in an Excel export if you have links or text styles on your View columns. With the help of the code snippet below, you'll be able to remove those tags from your Excel export files.
document.addEventListener("DOMContentLoaded",()=>{wp.hooks.addFilter("gk.datatables.options","gv-strip-html-excel",t=>(t.buttons=t.buttons.map(t=>("excel"===t.extend&&(t.exportOptions=t.exportOptions||{},t.exportOptions.stripHtml=!0,t.exportOptions.format=t.exportOptions.format||{},t.exportOptions.format.body=(t,o,e,p)=>p?p.innerText:t.replace(/<[^>]*?>/g,"")),t)),t))});
This code has been minified to make it easy to copy. Here's a link to the full code.
This JavaScript code should be copied and pasted, as it is, on the Custom JavaScript editor that sits inside View Editor > View Settings metabox > Custom Code tab.