Defining the table header values to use when exporting a table

Defining the table header values to use when exporting a table

MagicSquaresMagicSquares Posts: 22Questions: 7Answers: 0

I have a table where the table header contains one row, with column headers. However, those the table cells those column headers also include JavaScript code that displays a tool tip when the mouse hovers over the column header label.

When I export the table, it is including the tool tips with the exported data.

Is there a way to force the export functions to use only the column header (or to provide my own data value that it should use instead of what is displayed in the table?

This question has an accepted answers - jump to answer

Answers

  • rf1234rf1234 Posts: 2,899Questions: 87Answers: 414
    Answer ✓

    Use exportOptions, format, header like this for example:

    exportOptions: {
        format: {
            header: function ( data, column, node ) {
                //replace html tags with one space
                return data.replace(/<[^>]*>/g, ' ');
            }
        }
    }
    

    https://datatables.net/reference/button/excel

    Search for "exportOptions" and follow the links provided.

Sign In or Register to comment.