1

Is there a way to top align all the cells in excel when using export feature of datatables? I am able to wrap the text in excel as well as I have marked "stripNewlines" as false. It works, however the cells are bottom aligned, so it is very hard for the user to read. Is there a way to top align the cells? Thanks.

Here is my code:

customize: function( xlsx ) {
                var sheet = xlsx.xl.worksheets['sheet1.xml'];

               $('row c[r^="B"]', sheet).attr( 's', '55' );
                 $('row c[r^="C"]', sheet).attr( 's', '55' );
                 $('row c[r^="A"]', sheet).attr( 's', '55' );
                 $('row c[r^="D"]', sheet).attr( 's', '55' );
                 $('row c[r^="E"]', sheet).attr( 's', '55' );
                 $('row c[r^="F"]', sheet).attr( 's', '55' );            
            $('row:nth-child(2) c', sheet).attr('s', '2');
              $('row:nth-child(1) c', sheet).attr( 's', '2' );
         $('row c[r^="A1"]', sheet).attr( 's', '51' );    
            },
                exportOptions: {
                    columns: ':visible',
                    stripNewlines: false

                                    }
            },
newuser
  • 245
  • 1
  • 1
  • 8
  • 1
    Not an answer, but may point you in the right direction. Take a look at the approach [here](https://stackoverflow.com/a/73793683/12567365). Ignore code relating to fonts and fills (not relevant to you). Look at the `cellXfTmplt` string. In your case, you want a slightly different template - something like this: ``. Use this to create a new style, and then apply that to your cells. – andrewJames Apr 19 '23 at 14:27
  • 1
    You can explore these XML formats for yourself by creating an Excel file using Excel, and then unzipping it to see all the XML files it contains. I find doing this is easier than trying to read the [specs](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-xlsx/2c5dee00-eff2-4b22-92b6-0738acd4475e?redirectedfrom=MSDN). – andrewJames Apr 19 '23 at 14:31

0 Answers0