0

i need to merge first row of excel sheet exported using datatables this my JavaScript

{
          extend: 'excelHtml5',
          footer: true,
          text: 'Save as Excel',
          pageSize: 'A4',
          title:'',
          filename:'shop',
          messageTop: 'shop',
          
          customize: function (xlsx) {
                        var sheet = xlsx.xl.worksheets['sheet1.xml'];
                   
            $('row:first c', sheet).attr( 's', '2' ); // first row is bold
                      
                        $('row c[r^="A"]', sheet).attr( 's', '2' );
                        $('row c[r^="B"]', sheet).attr( 's', '55' );
                        $('row[r=2] c', sheet).attr( 's', '2' );
                      
                     

                        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 > 0) {
                                $(this).attr('ht', 32);
                                $(this).attr('customHeight', 1);
                              
                            }
                        });

                        

                       
                        
                        
                        



                    }

now output I got is like this at first row cells are not merged and its left aligned

enter image description here

the output i want is something like this first row where title is center aligned and all cells in the first row is merged

enter image description here

gopal
  • 99
  • 1
  • 9
  • 1
    This looks like a hard-coded range `A1:J1` (or whatever you need). So you can just add that to your array of ranges that I assume you [built for your Category column](https://stackoverflow.com/a/73269961/12567365): `ranges.push( "A1:J1" );`. – andrewJames Aug 08 '22 at 16:34
  • yes i did thanks for that. any help in merging cells of first column – gopal Aug 09 '22 at 04:25

0 Answers0