Printer file Excel from datatable without

Printer file Excel from datatable without

Francesco_25Francesco_25 Posts: 1Questions: 1Answers: 0

Hi, how can I delete from Excel the following code present in HTML:
<td class="text-lef"><span class="badge"><?=$array_01[$i]['CDTEST'] ?></span></td> that is, all the code with the <span></span> tags. Thanks

Answers

  • rf1234rf1234 Posts: 2,990Questions: 87Answers: 421

    What is "Printer file Excel"?

    You could use exportOptions and manipulate the data exported to Excel like this:

    buttons: [
        {   extend: "excel",
                exportOptions: {
                    format: {
                        body: function ( data, row, column, node ) {
                            //replace ampersands and other special chars
                            data = data.replace(/&gt;/g, '>')
                                       .replace(/&lt;/g, '<')
                                       .replace(/&amp;/g, '&')
                                       .replace(/&quot;/g, '"')
                                       .replace(/&#163;/g, '£')
                                       .replace(/&#39;/g, '\'')
                                       .replace(/&#10;/g, '\n');
                            //replace html tags with one space
                            data = data.replace(/<[^>]*>/g, ' ');
                            //replace multiple spaces and tabs etc with one space
                            return data.replace(/\s\s+/g, ' ');
                        },
                        header: function ( data, column ) {
                            //replace html tags with one space
                            return data.replace(/<[^>]*>/g, ' ');
                        }
                    }
                }
            },
    

    Just replace this code with what you need to get rid of your span.

  • franco1968franco1968 Posts: 2Questions: 0Answers: 0

    Ok thank you

Sign In or Register to comment.