Cristian Muscalu
Cristian Muscalu

Reputation: 9905

Datatables change Export format

I can change values inside a column on Excel export with this code.

var buttonExp = {
    exportOptions: {
        format: {
            body: function (data, column, row){
                return column === 4 ?
                data.replace( 'test', 'REPLACED' ) :
                data;
            }
        }
    }
};
var table = $('#myTable').DataTable({
    dom: 'lfBrtip',
    buttons: [
        $.extend(true, {}, buttonExp, {
            extend: 'excelHtml5',
            text: 'Export xls All',
            exportOptions: {
                modifier: {
                    page: 'current'
                }
            }

How can i change the Excel export format of a Column from this:

enter image description here

To this:

enter image description here

Upvotes: 1

Views: 1011

Answers (1)

Cristian Muscalu
Cristian Muscalu

Reputation: 9905

The only option i could find is changing the export from xlsx to csv.
Exporting in csv gives the desired output.

Upvotes: 2

Related Questions