title: How to align text to Top in first column in excel when exported from Datatables
body: <p>here i want to align text of column <strong>A</strong> top aligned in excel sheet  when i export it from data tables. iam new programmer any help is appreciated.<br />
  this what iam getting <a href="https://i.stack.imgur.com/i7dAC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/i7dAC.png" alt="enter image description here" /></a></p>
  <p>the result i want is the column <strong>A</strong> in excel should be Top aligned  when i export it this is the result i want.as you can see Column <strong>A</strong> texts is top aligned
  <a href="https://i.stack.imgur.com/MZCbP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MZCbP.png" alt="enter image description here" /></a></p>
  <p>this Top align feature in MS excel as  show in pic below .but i want it in datatable code
  <a href="https://i.stack.imgur.com/s4ZHX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/s4ZHX.png" alt="enter image description here" /></a></p>
  <p>here is my code used  to export so far `</p>
  <pre><code>    {
                extend: 'excelHtml5',
                footer: true,
                text: 'Save as Excel',
                pageSize: 'A4',
                title:'shop',
                filename:'shop',
                
                
                customize: function (xlsx) {
      
                  
                              var sheet = xlsx.xl.worksheets['sheet1.xml'];
                              var style = xlsx.xl['styles.xml'];
                         
                
                             var tagName = style.getElementsByTagName('sz');
                            
                             $('row c[r^=&quot;A&quot;]', sheet).attr( 's', '2' );
                              $('row c[r^=&quot;B&quot;]', sheet).attr( 's', '55' );
                              $('row[r=2] c', sheet).attr( 's', '32' );
                              $('row[r=1] c', sheet).attr( 's', '51' );
      
                              $('xf', style).find(&quot;alignment[horizontal='center']&quot;).attr(&quot;wrapText&quot;, &quot;1&quot;);
            
                              $('row', sheet).first().attr('ht', '40').attr('customHeight', &quot;1&quot;);
                              
                              
                              
                              
                            
                           
      
                              var col = $('col', sheet);
                              $(col[0]).attr('width', 8);
                              $(col[1]).attr('width', 25);
                              $(col[2]).attr('width', 8);
                              $(col[3]).attr('width', 9);
                              $(col[4]).attr('width', 7);
                              $(col[5]).attr('width', 6);
                              $(col[6]).attr('width', 7);
                              $(col[7]).attr('width', 8);
                              $(col[8]).attr('width', 8);
                              $('row* ', sheet).each(function (index) {
                                  if (index &gt; 0) {
                                      $(this).attr('ht', 32);
                                      $(this).attr('customHeight', 1);
                                    
                                  }
                              });
      
                              
      
                              var ranges = buildRanges(sheet);
                              ranges.push( &quot;A1:I1&quot; );
                              
                              // build the HTML string:
                              var mergeCellsHtml = '&lt;mergeCells count=&quot;' + ranges.length + '&quot;&gt;';
                              ranges.forEach(function(range) {
                                  mergeCellsHtml = mergeCellsHtml + '&lt;mergeCell ref=&quot;' + range + '&quot;/&gt;';
                              })
                              mergeCellsHtml = mergeCellsHtml + '&lt;/mergeCells&gt;';
      
                              $( 'sheetData', sheet ).after( mergeCellsHtml );
                              // don't know why, but Excel auto-adds an extra mergeCells tag, so remove it:
                              $( 'mergeCells', sheet ).last().remove(); 
                              
      
      
      
                          },
                exportOptions: {
                  columns: [1, 2, 3, 4, 5, 6, 7, 8, 9],
                  
                  
                  rows: function (idx, data, node) {
                    return data[6] + data[7] &gt; 0 ?
                      true : false;
                      
                  }
                }
              }`
   function buildRanges(sheet) {
  
  let prevCat = ''; // previous category
  let currCat = ''; // current category
  let currCellRef = ''; // current cell reference
  let rows = $('row', sheet);
  let startRange = '';
  let endRange = '';
  let ranges = [];
  
  rows.each(function (i) {
    if (i &gt; 0 &amp;&amp; i &lt; rows.length) { // skip first (headings) row
      let cols = $('c', $(this));
      cols.each(function (j) {
        if (j == 0) { // the &quot;Category&quot; column
          currCat = $(this).text(); // current row's category
          currCellRef = $(this).attr('r'); // e.g. &quot;B3&quot;
          if (currCat !== prevCat) {
            if (i == 0) {
              // start of first range
              startRange = currCellRef;
              endRange = currCellRef;
              prevCat = currCat;
            } else {
              // end of previous range
              if (endRange !== startRange) {
                // capture the range:
                ranges.push( startRange + ':' + endRange );
                
              }
               // start of a new range
              startRange = currCellRef;
              endRange = currCellRef;
              prevCat = currCat;
            }
          } else {
            // extend the current range end:
            endRange = currCellRef;
          }
          //console.log( $(this).attr('r') );
        }
      });
      if (i == rows.length -1 &amp;&amp; endRange !== startRange) {
        // capture the final range:
        ranges.push( startRange + ':' + endRange );
       
      }
    }
  });
  return ranges;
  }
  </code></pre>