Export row vertical align top (or middle) keeping cells that got new lines?

Export row vertical align top (or middle) keeping cells that got new lines?

markzzzmarkzzz Posts: 49Questions: 8Answers: 1

Hi there,

I've some table cell with complex data, not only a simple string, but a sort of div-grid table nested into the cell.
So I'm exporting it keeping new lines, in this way, extendings buttons:

$.extend(true, $.fn.dataTable.defaults, {
    buttons: {
        buttons: [
            {
                extend: 'excel',
                exportOptions: {
                    format: {
                        body: function (data, row, column, node) {
                            var result = data;
                            var columnIndex = GetColumnIndexByColumnName("MissingPayments", true);

                            if (column == columnIndex) {
                                result = "";

                                var cellGrid = $(node).find('.cell-grid');
                                var cellGridRows = cellGrid.find('.cell-grid-row.active');

                                cellGridRows.each(function (index, row) {
                                    var cellGridRowsColsArray = $(row).find('.cell-grid-col').map(function () { return $(this).text(); }).get();

                                    var row = cellGridRowsColsArray[0] + ": " + cellGridRowsColsArray[1] + " (" + cellGridRowsColsArray[2] + ")";

                                    result += row + "\r\n";
                                });
                            }

                            return result.trim();
                        }
                    }
                },
                customize: function (xlsx) {
                    var sheet1 = xlsx.xl.worksheets['sheet1.xml'];
                    var columnIndex = GetColumnIndexByColumnName("MissingPayments", true);
                    var columnLetter = GetLetterByNumber(columnIndex).toUpperCase();

                    $('row c[r^="' + columnLetter + '"]', sheet1).attr('s', '55');
                    $('row:first c', sheet1).attr('s', '2'); // overwrite first row, so it keeps bold
                }
            }
        ]
    }
});

It works perfectly, but the row with a single line become vertically aligned to the bottom on the excel.

How can I align them to the top (or middle) keeping the wrap text on the selected column?
Thanks, you are very helping me in these days!

This discussion has been closed.