custom header when exporting to excel

When exporting, is there a global variable that contains the value of header in the same position on the datatable?

For example if datatable looks like this:

header 1
header 2

data

on export i would like to just customize the text for the first header row but not the second. something like:

custom header 1
header 2

data

If my datatable has 20 columns, and the header is comprised of 3 rows, wanting to just customize 1 header column would be a lot of work.

is it possible to customize only the first header row and not the second header row when exporting to excel? Also when customizing the text for the header row, is it possible to specify the colspan? I couldn’t find anyway to merge and center 3 cells in the header when exporting.

Hello,

Yes, it’s possible to use colspans during export. For these needs you should not only define a colspan value for a column header, but also define null header for the columns that are included into this colspan.

In fact header configuration consists of an array of header rows:

year:{
      header:[{ text:"New Year", colspan:2 }, {text:"Header2"}]
},
votes:{
      header:[null, {text:"Votes"}]
}

The same way you can configure multiline headers.

There’s no global variable of the kind you are interested in, but you can get to a header of any column by using:

 $("$datatable2").getColumnConfig("votes").header[0].text;

fantastic. thank you so much