---
title: "DataTables Excel Export &#8211; How to remove HTML tags from the export"
date: 2026-04-23
author: "GravityKit"
link: "https://www.gravitykit.com/docs/gravityview-pro/datatables/datatables-excel-export-how-to-remove-html-tags-from-the-export/"
---

![Excel sheet with HTML tags in "Type of Incident" and "Date of Incident" columns](https://www.gravitykit.com/wp-content/uploads/2025/10/file-aZsIkkRvAQ.png)
*!*[Excel table showing incident types with corresponding dates](https://www.gravitykit.com/wp-content/uploads/2025/10/file-mzEKoUkgBC.png)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))});
```

```
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](https://gist.github.com/rafaehlers/6fcc2c4deecf0fea201ace93bb41d287).

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.

![Custom JavaScript settings for removing HTML tags during DataTables Excel export](https://www.gravitykit.com/wp-content/uploads/2025/10/file-cANL5x1er4.png)